public Bitmap GetImage()
        {
            if (!this.HasPalette)
            {
                PalReader r = new PalReader();
                this.paletteData = r.GetPalette(pathtoCol + "\\VICEROY.PAL");
            }
            // Create Bitmap
            Bitmap bmp = new Bitmap(this.width, this.height);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    // Find index in array
                    int pos = (y * width) + x;
                    // Get index for this pixel
                    int idx = imageData[pos];
                    // Get RGB values for this index
                    int a, r, g, b;

                    if (idx == 255)
                    {
                        a = r = g = b = 0;
                    }
                    else
                    {
                        a = 255;

                        //r = paletteData[idx * 3] * 2;
                        //g = paletteData[(idx * 3) + 1] * 2;
                        ////b = paletteData[(idx * 3) + 1] * 2;
                        // @BUGFIX
                        //b = paletteData[(idx * 3) + 2] * 2;

                        r = paletteData[idx * 3] * 4;
                        g = paletteData[(idx * 3) + 1] * 4;
                        b = paletteData[(idx * 3) + 2] * 4;
                    }


                    // Set this pixel color in image
                    bmp.SetPixel(x, y, Color.FromArgb(a, r, g, b));
                }
            }
            return(bmp);
        }
Exemple #2
0
        public Bitmap GetImage(int index)
        {
            if (!this.hasPalette())
            {
                PalReader r = new PalReader();
                this.setPaletteData(r.GetPalette(pathtoCol + "\\VICEROY.PAL"));
            }

            byte[] imageData = uncompressRLEimageData(spriteImageData, startOffsets[index], lengths[index], heights[index], widths[index]);

            // Create Bitmap
            Bitmap bmp = new Bitmap(this.widths[index], this.heights[index]);

            for (int y = 0; y < this.heights[index]; y++)
            {
                for (int x = 0; x < this.widths[index]; x++)
                {
                    // Find index in array
                    int pos = (y * this.widths[index]) + x;
                    // Get index for this pixel
                    int idx = imageData[pos];
                    // Get RGB values for this index

                    // @BUGFIX
                    //int a = idx == 255 || idx == 0 ? 0 : 255;
                    int a = idx == TRANSPARENT_COLOUR_INDEX ? 0 : TRANSPARENT_COLOUR_INDEX;

                    int r = this.getPaletteData()[idx * 3] * 4;
                    int g = this.getPaletteData()[(idx * 3) + 1] * 4;
                    int b = this.getPaletteData()[(idx * 3) + 2] * 4;
                    // Set this pixel color in image
                    bmp.SetPixel(x, y, Color.FromArgb(a, r, g, b));
                }
            }
            return(bmp);
        }