Esempio n. 1
0
        public void Write(byte[] data, CharLayout layout, uint offset, uint ch)
        {
            uint charOffset = (8 * offset) + (layout.Stride * ch);

            for (uint y = 0; y < Height; y++)
            {
                uint rowOffset = charOffset + layout.YOffset(data, y);
                for (uint x = 0; x < Width; x++)
                {
                    uint pixOffset = rowOffset + layout.XOffset(data, x);
                    uint planeBit  = 1U << (int)(layout.Planes - 1);
                    for (uint plane = 0; plane < layout.Planes; plane++, planeBit >>= 1)
                    {
                        uint bitOffset  = pixOffset + layout.PlaneOffset(data, plane);
                        uint byteOffset = bitOffset / 8;
                        //byte mask = (byte)(0x0080U >> (int)(7 - (bitOffset % 8)));
                        byte mask = (byte)(0x0080U >> (int)(bitOffset % 8));
                        if ((Pixels[x + (Width * y)] & planeBit) != 0)
                        {
                            data[byteOffset] |= mask;
                        }
                        else
                        {
                            data[byteOffset] &= (byte)(~mask);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public GfxElement(byte[] data, CharLayout layout, uint offset, uint ch)
        {
            Width  = layout.Width;
            Height = layout.Height;
            Pixels = new uint[Width * Height];
            uint charOffset = (8 * offset) + (layout.Stride * ch);

            for (uint y = 0; y < Height; y++)
            {
                uint rowOffset = charOffset + layout.YOffset(data, y);
                for (uint x = 0; x < Width; x++)
                {
                    uint pixOffset = rowOffset + layout.XOffset(data, x);
                    uint pixel     = 0;
                    uint planeBit  = 1U << (int)(layout.Planes - 1);
                    for (uint plane = 0; plane < layout.Planes; plane++, planeBit >>= 1)
                    {
                        uint bitOffset = pixOffset + layout.PlaneOffset(data, plane);
                        if (((data[bitOffset / 8] >> (int)(7 - (bitOffset % 8))) & 1U) != 0)
                        {
                            pixel |= planeBit;
                        }
                    }
                    Pixels[x + (Width * y)] = pixel;
                }
            }
        }