我现在使用的代码针对大约300张图像是有效的,但我需要合并超过一千张。
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);
}
}
它会抛出以下异常:
An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll
Additional information: A generic error occurred in GDI+.
有人可以帮忙吗?