XCom.Interfaces.Base.IMap_Base.SaveGif C# (CSharp) Method

SaveGif() public method

Not yet generic enough to call with custom derived classes other than XCMapFile
public SaveGif ( string file ) : void
file string
return void
		public void SaveGif(string file)
		{
			Palette curPal = null;

			for (int h = 0; h < mapSize.Height; h++)
				for (int r = 0; r < mapSize.Rows; r++)
					for (int c = 0; c < mapSize.Cols; c++)
						if (((XCMapTile)this[r, c, h]).Ground != null)
						{
							curPal = ((XCMapTile)this[r, c, h]).Ground[0].Palette;
							goto outLoop;
						}
		outLoop:

			Bitmap b = Bmp.MakeBitmap((mapSize.Rows + mapSize.Cols) * (PckImage.Width / 2), (mapSize.Height - currentHeight) * 24 + (mapSize.Rows + mapSize.Cols) * 8, curPal.Colors);

			Point start = new Point((mapSize.Rows - 1) * (PckImage.Width / 2), -(24 * currentHeight));

			int curr = 0;

			if (mapData != null)
				for (int h = mapSize.Height - 1; h >= currentHeight; h--)
					for (int row = 0, startX = start.X, startY = start.Y + (24 * h); row < mapSize.Rows; row++, startX -= hWid, startY += hHeight)
						for (int col = 0, x = startX, y = startY; col < mapSize.Cols; col++, x += hWid, y += hHeight, curr++)
						{
							foreach (XCTile t in this[row, col, h].UsedTiles)
								Bmp.Draw(t[0].Image, b, x, y - t.Info.TileOffset);

							Bmp.FireLoadingEvent(curr, (mapSize.Height - currentHeight) * mapSize.Rows * mapSize.Cols);
						}
			try
			{
				Rectangle rect = Bmp.GetBoundsRect(b, Bmp.DefaultTransparentIndex);

				Bitmap b2 = Bmp.Crop(b, rect);

				b2.Save(file, System.Drawing.Imaging.ImageFormat.Gif);
			}
			catch
			{
				b.Save(file, System.Drawing.Imaging.ImageFormat.Gif);
			}
		}
	}