如何在图片框中显示时压缩或缩小图像的大小?

时间:2014-02-02 08:33:53

标签: c# winforms image compression picturebox

我试图用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;
  .....
  .....
}

0 个答案:

没有答案