I'm using the following code right now, and it works for ~300 images, but I have to merge more than one thousand.
private static void CombineThumbStripImages(string[] imageFiles)
{
int index = 0;
using (var result = new Bitmap(192 * imageFiles.Length, 112))
{
using (var graphics = Graphics.FromImage(result))
{
graphics.Clear(Color.White);
int leftPosition = 0;
for (index = 0; index < imageFiles.Length; index++)
{
string file = imageFiles[index];
using (var image = new Bitmap(file))
{
var rect = new Rectangle(leftPosition, 0, 192, 112);
graphics.DrawImage(image, rect);
leftPosition += 192;
}
}
}
result.Save("result.jpg", ImageFormat.Jpeg);
}
}
It throws the following exception:
An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll
Additional information: A generic error occurred in GDI+.
Can somebody help?
Hold down the CMD key as you make your selection to choose multiple images, then right-click and select Open with > Preview. Click-and-drag the photos in the sidebar to rearrange their order. When you're satisfied, select File > Print. In the PDF drop-down menu, choose Save as PDF.
Click the “File” menu and then click the “Save As” command. In the Save As window, choose the JPG format on the “Save As Type” drop-down menu and then click the “Save” button.
Why not use something like xna or opengl to do this?
I know you can with texture2d ... and as i am currently learning opengl id like to think you can with that but do not know how.
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.texture2d_members.aspx (SaveAsJPEG on public)
I have done something similar to make sprite sheets, you basically create a huge texture2d using whatever tesselation or organizing algorithm to optimize space usage. There are lots of ways to do this though.
such as http://xbox.create.msdn.com/en-US/education/catalog/sample/sprite_sheet
would probably only take a couple of hours to do. XNA v easy especially if you are just leaning on the externals. Doing it this was should work pretty well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With