Exemplo n.º 1
0
 public void ExportToMAP(PAL pal, String filename)
 {
     using (BinaryWriter bw = new BinaryWriter(new FileStream(filename, FileMode.Create)))
     {
         bw.Write(Encoding.ASCII.GetBytes("map"));
         bw.Write(new byte[] { 0x1A, 0x0D, 0x0A, 0x00, 0x00 });
         bw.Write((short)Width);
         bw.Write((short)Height);
         bw.Write(Code);
         bw.Write(Encoding.ASCII.GetBytes(Name));
         bw.Write(pal.RawData());
         bw.Write(new byte[] { 0x00, 0x00 });
         if (ControlPoints.Count > 0)
         {
             bw.Write((short)ControlPoints.Count);
             foreach (KeyValuePair<int, Point> kv in ControlPoints)
             {
                 bw.Write((short)kv.Value.X);
                 bw.Write((short)kv.Value.Y);
             }
         }
         bw.Write(Data1D);
     }
 }
Exemplo n.º 2
0
 public void ExportToPNG(PAL pal, String filename)
 {
     if(Width > 0 && Height > 0)
         using (Bitmap bmp = new Bitmap(Width, Height))
         {
             using (Graphics g = Graphics.FromImage(bmp))
             {
                 for (int y = 0; y < Height; y++)
                     for (int x = 0; x < Width; x++)
                         g.FillRectangle(new SolidBrush(pal.Palette[Data2D[y, x]]), x, y, 1, 1);
             }
             bmp.Save(filename);
         }
 }