Пример #1
0
        private static void LoadFontTest(
            int expectedWidth,
            int expectedHeight,
            int bitsPerPixel,
            string name,
            Func <FontContext, IImage> getter)
        {
            var expectedLength = expectedWidth * expectedHeight * bitsPerPixel / 8;

            var fontContext = new FontContext();
            var entry       = new Bar.Entry
            {
                Name   = name,
                Type   = Bar.EntryType.RawBitmap,
                Stream = CreateStream(expectedLength)
            };

            fontContext.Read(new Bar.Entry[] { entry });

            var image = getter(fontContext);

            Assert.NotNull(image);
            Assert.Equal(expectedWidth, image.Size.Width);
            Assert.Equal(expectedHeight, image.Size.Height);
            Assert.Equal(expectedLength, entry.Stream.Position);
        }
Пример #2
0
        private void LoadFontInfo(string fileName)
        {
            var bar = _dataContent.FileOpen(fileName)
                      .Using(stream => Bar.Read(stream));

            FontContext.Read(bar);
        }
Пример #3
0
        private static IEnumerable <IImageRead> ReadKh2Font(Stream inputStream)
        {
            var fontContext = new FontContext();

            fontContext.Read(Bar.Read(inputStream.SetPosition(0))
                             .Where(x => x.Type == Bar.EntryType.RawBitmap));

            return(new[]
            {
                fontContext.ImageSystem,
                fontContext.ImageSystem2,
                fontContext.ImageEvent,
                fontContext.ImageEvent2,
                fontContext.ImageIcon
            }.Where(x => x != null));
        }