Beispiel #1
0
        public override Bitmap DecodeImage(Stream stream, uint width, uint height, Stream data, int type)
        {
            Bitmap image = new Bitmap((int)width, (int)height);

            EndianReader reader = new EndianReader(stream, Endianness.BigEndian);

            EndianReader datareader = new EndianReader(data, Endianness.BigEndian);
            List <Color> palette    = new List <Color>();

            try {
                for (int i = 0; i < 0x10; i++)
                {
                    palette.Add(CI8.ReadPaletteColour(datareader.ReadUInt16(), type));
                }
            } catch { }             // We can't be sure of the palette size thanks to this f*****g format.

            for (int y = 0; y < height; y += 8)
            {
                for (int x = 0; x < width; x += 8)
                {
                    for (int y1 = 0; y1 < 8; y1++)
                    {
                        int ypixel = y + y1;
                        for (int x1 = 0; x1 < 8; x1 += 2)
                        {
                            byte pixel = reader.ReadByte();
                            for (int x2 = 0; x2 < 2; x2++)
                            {
                                int xpixel = x + x1 + x2;
                                if (ypixel < height && xpixel < width)
                                {
                                    image.SetPixel(xpixel, ypixel, palette[(pixel >> (4 * (1 - x2))) & 0x0F]);
                                }
                            }
                        }
                    }
                }
            }

            return(image);
        }
Beispiel #2
0
        public override Bitmap DecodeImage(Stream stream, uint width, uint height, Stream data, int type)
        {
            Bitmap image = new Bitmap((int)width, (int)height);

            EndianReader reader = new EndianReader(stream, Endianness.BigEndian);

            EndianReader datareader = new EndianReader(data, Endianness.BigEndian);
            List <Color> palette    = new List <Color>();

            try {
                for (int i = 0; i < 0x4000; i++)
                {
                    palette.Add(CI8.ReadPaletteColour(datareader.ReadUInt16(), type));
                }
            } catch { }             // We can't be sure of the palette size thanks to this f*****g format.

            for (int y = 0; y < height; y += 4)
            {
                for (int x = 0; x < width; x += 4)
                {
                    for (int y1 = 0; y1 < 4; y1++)
                    {
                        for (int x1 = 0; x1 < 4; x1++)
                        {
                            ushort pixel = reader.ReadUInt16();

                            int pixelx = x + x1;
                            int pixely = y + y1;
                            if (pixelx < width && pixely < height)
                            {
                                image.SetPixel(pixelx, pixely, palette[pixel & 0x3FFF]);
                            }
                        }
                    }
                }
            }

            return(image);
        }