Created
February 9, 2013 14:19
-
-
Save adrianseeley/4745395 to your computer and use it in GitHub Desktop.
Removes horizontal and vertical lines from tilesets (in.png -> out.png)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Drawing; | |
using System.IO; | |
namespace fixs | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Bitmap b = (Bitmap)Bitmap.FromFile("in.png"); | |
Bitmap o = new Bitmap(b.Width, b.Height); | |
int r_x = 0, r_y = 0; | |
for (int x = 0; x < b.Width; x++) | |
{ | |
r_y = 0; | |
for (int y = 0; y < b.Height; y++) | |
{ | |
if (b.GetPixel(x, y).A == 0) continue; | |
else | |
{ | |
o.SetPixel(x, r_y, b.GetPixel(x, y)); | |
r_y++; | |
} | |
} | |
} | |
b = o; | |
o = new Bitmap(o.Width, o.Height); | |
r_x = 0; r_y = 0; | |
for (int y = 0; y < b.Height; y++) | |
{ | |
r_x = 0; | |
for (int x = 0; x < b.Width; x++) | |
{ | |
if (b.GetPixel(x, y).A == 0) continue; | |
else | |
{ | |
o.SetPixel(r_x, y, b.GetPixel(x, y)); | |
r_x++; | |
} | |
} | |
} | |
o.Save("out.png"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment