Example #1
0
        private void ReadPalettedBgra16Pixel <TPixel>(byte[] palette, int index, int colorMapPixelSizeInBytes, ref TPixel color)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            Bgra5551 bgra = default;

            bgra.FromBgra5551(Unsafe.As <byte, Bgra5551>(ref palette[index * colorMapPixelSizeInBytes]));

            if (!this.hasAlpha)
            {
                // Set alpha value to 1, to treat it as opaque.
                bgra.PackedValue = (ushort)(bgra.PackedValue | 0x8000);
            }

            color.FromBgra5551(bgra);
        }
Example #2
0
        private void ReadPalettedBgr16Pixel <TPixel>(byte[] palette, int colorMapPixelSizeInBytes, int x, TPixel color, Span <TPixel> pixelRow)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            int      colorIndex = this.currentStream.ReadByte();
            Bgra5551 bgra       = default;

            bgra.FromBgra5551(Unsafe.As <byte, Bgra5551>(ref palette[colorIndex * colorMapPixelSizeInBytes]));
            if (!this.hasAlpha)
            {
                // Set alpha value to 1, to treat it as opaque for Bgra5551.
                bgra.PackedValue = (ushort)(bgra.PackedValue | 0x8000);
            }

            color.FromBgra5551(bgra);
            pixelRow[x] = color;
        }