Permalink
Browse files

png export button for tilesets

  • Loading branch information...
movAX13h committed Mar 30, 2018
1 parent 870d062 commit 538ae1d3287d269e32a101a11007169305515716
Showing with 51 additions and 17 deletions.
  1. +14 −0 Tool/TilesForm.Designer.cs
  2. +37 −17 Tool/TilesForm.cs
  3. BIN Tool/bin/Release/RiptideDissected.exe

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -18,38 +18,43 @@ public TilesForm(Map map)
draw();
}
private void draw()
private void draw(bool original = false)
{
Bitmap bmp = new Bitmap(40 * 8 * currentZoom, 13 * 8 * currentZoom);
int zoom = original ? 1 : currentZoom;
Bitmap bmp = new Bitmap(40 * 8 * zoom, 13 * 8 * zoom);
Graphics gfx = Graphics.FromImage(bmp);
gfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
gfx.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
int i = 0;
foreach(MapTile tile in map.Tiles)
{
int x = (i % 40) * 8 * currentZoom;
int y = (int)Math.Floor((i / 40f)) * 8 * currentZoom;
gfx.DrawImage(tile.Bitmap, new Rectangle(x, y, 8 * currentZoom, 8 * currentZoom), new Rectangle(0, 0, 8, 8), GraphicsUnit.Pixel);
int x = (i % 40) * 8 * zoom;
int y = (int)Math.Floor((i / 40f)) * 8 * zoom;
gfx.DrawImage(tile.Bitmap, new Rectangle(x, y, 8 * zoom, 8 * zoom), new Rectangle(0, 0, 8, 8), GraphicsUnit.Pixel);
//gfx.DrawString(i.ToString(), SystemFonts.MenuFont, Brushes.White, x, y);
i++;
}
Pen gridPen = new Pen(Color.FromArgb(50, 0, 0, 0));
if (!original)
{
Pen gridPen = new Pen(Color.FromArgb(50, 0, 0, 0));
int w = 40 * 8 * currentZoom;
int h = 13 * 8 * currentZoom;
int w = 40 * 8 * zoom;
int h = 13 * 8 * zoom;
for (int x = 0; x <= 40; x++)
{
int gx = x * 8 * currentZoom;
gfx.DrawLine(gridPen, gx, 0, gx, h);
}
for (int x = 0; x <= 40; x++)
{
int gx = x * 8 * zoom;
gfx.DrawLine(gridPen, gx, 0, gx, h);
}
for (int y = 0; y <= 13; y++)
{
int gy = y * 8 * currentZoom;
gfx.DrawLine(gridPen, 0, gy, w, gy);
for (int y = 0; y <= 13; y++)
{
int gy = y * 8 * zoom;
gfx.DrawLine(gridPen, 0, gy, w, gy);
}
}
//gfx.DrawRectangle(Pens.Black, new Rectangle(0, 0, bmp.Width, bmp.Height));
@@ -63,5 +68,20 @@ private void zoomDropDown_DropDownItemClicked(object sender, ToolStripItemClicke
zoomDropDown.Text = e.ClickedItem.Text;
draw();
}
private void pngButton_Click(object sender, EventArgs e)
{
using (SaveFileDialog dialog = new SaveFileDialog())
{
dialog.Filter = "PNG Image (*.png)|.png";
dialog.FileName = map.Entry.Filename + ".png";
if (dialog.ShowDialog() == DialogResult.OK)
{
draw(true);
canvasBox.Image.Save(dialog.FileName);
draw();
}
};
}
}
}
Binary file not shown.

0 comments on commit 538ae1d

Please sign in to comment.