Introduction
A picture is worth a thousand words! So imagine a frame on your wall arranging a matrix of hundreds of you best pictures?!? Or many frames arranging different photo albuns?!? Cool isnt it?
We know, we know, soon or later someone will comment below here why to do this, there are some programs over the web which do the same and bla bla bla... Well I will answer, we like to program, it is our hobby : )
More considerations... It is only a prototype, so for sure there may have issues and sure many features that can be incorporated, so... do not loose much time trying to scratch issues, because surely you will find!!! : )
Background
Once we have created a program to make a frame here at home which is about 40x25 inches and displays about 400 of our best pictures and it became a fever on friends asking for we have decided to publish it.
Our poster at home with > 400's pictures printed in dull paper
and framed with anti reflective glass
Using the code
The code is pretty simple, it loads a set of images redimension them and rearrange in a new bigger image, feel free to modify it according to your needings.
Yes, it can be smarter and fill the empty spaces in the end of the final image, calculate heights and work resizing vertical pictures preserving ratio etc etc etc.
string[] files = Directory.GetFiles(strFolder);
int count = 0;
foreach (string file in files)
{
string lowerfile = file.ToLower();
if (lowerfile.Contains(".gif") || lowerfile.Contains(".png") || lowerfile.Contains(".jpg") || lowerfile.Contains(".jpeg"))
{
count++;
}
}
ImageIt(count, files);
private void ImageIt(int count, string[] files)
{
double w = 64.0 * 4.0;
double h = 48.0 * 4.0;
double f = w / h;
int iw = (int)Math.Sqrt((double)count / f);
int ih = (int)((double)iw * f);
Bitmap newb = new Bitmap(iw * (int)w + (iw + 1) * 5, ih * (int)h + (ih + 1) * 5);
Graphics g = Graphics.FromImage(newb);
g.Clear(Color.Black);
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
int i = 0, j = 0, iCount = 0;
foreach (string file in files)
{
string lowerfile = file.ToLower();
if (lowerfile.Contains(".gif") || lowerfile.Contains(".png") || lowerfile.Contains(".jpg") || lowerfile.Contains(".jpeg"))
{
try
{
Bitmap bmp = new Bitmap(lowerfile);
Image img = Image.FromFile(lowerfile);
Image thumb = img.GetThumbnailImage((int)w, (int)h, myCallback, IntPtr.Zero);
g.DrawImage(thumb, new Point(5 + (int)w * i + 5 * i, 5 + (int)h * j + 5 * j));
g.Flush();
i++;
iCount++;
if (i % iw == 0) { j++; i = 0; }
if (iCount == count) break;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
public static bool ThumbnailCallback()
{
return false;
}
Points of Interest
It is incredible the quantity of friends who likes to have their own poster, so this is why we have decided to make it public. Enjoy!
History
It is in a very raw version, 1.0, maybe in the future we make some improvements to the tool. Any ideia for feature is very welcome.