Esempio n. 1
0
        protected override void CommitBuffer()
        {
            var luminanceSource = InternalBitmap.CloneAs <L8>();

            for (var page = 0; page < Height / 8; page++)
            {
                var scan = new byte[Width]; // each byte represents 8 pixels in column

                for (var y = 0; y < 8; y++)
                {
                    var luminance = luminanceSource.GetPixelRowMemory(y + page * 8).ToArray();
                    for (var x = 0; x < Width; x++)
                    {
                        if (y == 0)
                        {
                            scan[x] = 0;         // initialize on the first pixel row of the scan
                        }
                        if (luminance[x].PackedValue >= 128)
                        {
                            scan[x] |= (byte)(0x80 >> y);
                        }
                    }
                }
                _device.WritePage(page, scan);
            }
        }
        protected override void CommitBuffer()
        {
            InternalBitmap.Mutate(c => c.Dither().BlackWhite());

            var luminanceSource = InternalBitmap
                                  .CloneAs <L8>();

            var pages = Height / 8;

            for (var pageAddress = 0; pageAddress < pages; pageAddress++)
            {
                var scan = new byte[Width]; // each byte represents 8 pixels in column
                for (var y = 0; y < 8; y++)
                {
                    // row scan inside page
                    var luminance = luminanceSource.GetPixelRowMemory(y + pageAddress * 8).ToArray();
                    for (var x = 0; x < Width; x++)
                    {
                        if (y == 0)
                        {
                            scan[x] = 0;
                        }
                        if (luminance[x].PackedValue >= 128)
                        {
                            scan[x] |= (byte)(0x01 << y);
                        }
                    }
                }
                _device.WritePage(pageAddress, scan);
            }
        }