Exemple #1
0
 public FDPalette(string fileFullName)
 {
     paletteColors = new Bit24Color[256];
     using (FileStream streamData = new FileStream(@".\color", FileMode.Open, FileAccess.Read))
     {
         using (BinaryReader reader = new BinaryReader(streamData, Encoding.UTF8))
         {
             for (int i = 0; i < 256; i++)
             {
                 paletteColors[i]       = new Bit24Color();
                 paletteColors[i].Blue  = reader.ReadByte();
                 paletteColors[i].Green = reader.ReadByte();
                 paletteColors[i].Red   = reader.ReadByte();
             }
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// This is the function to generate the Bitmap for exporting
        /// </summary>
        /// <param name="palette"></param>
        /// <returns></returns>
        public FDBitmap GenerateBitmap(FDPalette palette)
        {
            FDBitmap bitmap = new FDBitmap(this.Width, this.Height);

            for (int i = 0; i < this.Width * this.Height; i++)
            {
                byte colorIndex = this.RawData[i];
                if (colorIndex > 0)
                {
                    Bit24Color color = palette.At(colorIndex);
                    bitmap.WriteData((byte)(color.Red << 2), (byte)(color.Green << 2), (byte)(color.Blue << 2), 255);
                }
                else
                {
                    bitmap.WriteData(0, 0, 0, 0);
                }
            }

            return(bitmap);
        }