Skip to content

Instantly share code, notes, and snippets.

@Lucas7yoshi
Last active November 26, 2018 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lucas7yoshi/91e642901a073f276a32286d4adb980b to your computer and use it in GitHub Desktop.
Save Lucas7yoshi/91e642901a073f276a32286d4adb980b to your computer and use it in GitHub Desktop.
// Make a variable of: List<Image>
// I'm not going to give any support other than saying that you need to run this in a form app in c#
// It assumes a image size of 256 x 256, change the values at will.
var numperrow = 4;
var w = 256 * numperrow;
int h = int.Parse(Math.Ceiling(double.Parse(imgs.Count.ToString()) / numperrow).ToString()) * 256;
if (imgs.Count * 256 < 256 * numperrow)
{
w = imgs.Count * 256;
}
var num = 1;
var cur_w = 0;
var cur_h = 0;
Bitmap bmp = new Bitmap(w, h);
using (Graphics g = Graphics.FromImage(bmp))
{
foreach (var i in imgs)
{
g.DrawImage(i, new PointF(cur_w, cur_h));
if (num % numperrow == 0)
{
cur_w = 0;
cur_h += 256;
num += 1;
}
else
{
cur_w += 256;
num += 1;
}
}
}
bmp.Save(Directory.GetCurrentDirectory() + "output.png");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment