Exemplo n.º 1
0
        protected static void DrawImageData256(RendererContext context, SmallGlyphMetrics smallMetrics, byte[] data)
        {
            Bitmap bitmap = context.Bitmap;
            Color  color  = Color.Black;
            int    width  = smallMetrics.width;
            int    height = smallMetrics.height;
            int    bx     = (int)context.DX + context.X + smallMetrics.bearingX;
            int    by     = (int)context.DY;
            int    dx     = 0;
            int    dy     = 0;
            int    length = data.Length;

            for (int i = 0; i < length; i++)
            {
                if (dx >= width)
                {
                    dx = 0;
                    dy++;
                    if (dy >= height)
                    {
                        break;
                    }
                }
                if (bx + dx > bitmap.Width)
                {
                    dx++;
                    continue;
                }
                byte alpha = data[i];
                bitmap.SetPixel(bx + dx, by + dy, Color.FromArgb(alpha, color));
                dx++;
            }
            //context.NextGlyph();
            context.X += smallMetrics.advance;
        }
Exemplo n.º 2
0
        public static GlyphBitmapData2 Read(BinaryReaderFont reader, int byteSize)
        {
            GlyphBitmapData2 value = new GlyphBitmapData2 {
                smallMetrics = SmallGlyphMetrics.Read(reader)
            };

            byteSize       -= SmallGlyphMetrics.ByteSize;
            value.imageData = reader.ReadBytes(byteSize);
            return(value);
        }
Exemplo n.º 3
0
        public static GlyphBitmapData17 Read(BinaryReaderFont reader)
        {
            GlyphBitmapData17 value = new GlyphBitmapData17 {
                glyphMetrics = SmallGlyphMetrics.Read(reader),
                dataLen      = reader.ReadUInt32()
            };

            value.data = reader.ReadBytes((int)value.dataLen);
            return(value);
        }
Exemplo n.º 4
0
        public static GlyphBitmapData8 Read(BinaryReaderFont reader)
        {
            GlyphBitmapData8 value = new GlyphBitmapData8 {
                smallMetrics  = SmallGlyphMetrics.Read(reader),
                pad           = reader.ReadByte(),
                numComponents = reader.ReadUInt16()
            };

            value.components = EbdtComponent.ReadArray(reader, value.numComponents);
            return(value);
        }
Exemplo n.º 5
0
        protected static void DrawImageData(RendererContext context, BitDepth bitDepth, SmallGlyphMetrics smallMetrics, byte[] data)
        {
            switch (bitDepth)
            {
            case BitDepth.BlackWhite:
                DrawImageData2(context, smallMetrics, data);
                break;

            case BitDepth.Gray4:
                DrawImageData4(context, smallMetrics, data);
                break;

            case BitDepth.Gray16:
                DrawImageData16(context, smallMetrics, data);
                break;

            case BitDepth.Gray256:
                DrawImageData256(context, smallMetrics, data);
                break;
            }
        }