我试图用C#窗体中的图片框显示图像。有许多图像,比如100s,它们的平均大小约为1 MB。所以我想在加载到图片框之前压缩或减小它们的大小。现在,它抛出了'outofmemory exception'。请问我该怎么做到这一点?帮我。
我的代码看起来像
List<string> imgPaths = new List<string>();
foreach(string imgName in imgPaths)
{
Image img = Image.FromFile(imgName);
// I want to compress the image, but I don't know how to
PictureBox picBox = new PictureBox();
picBox.Image = imgCompressed;
.....
.....
}