c#的内存不足问题,经典问题了吧,就是不会解决啊!帮忙

vcfansli vcfansli 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
代码如下:
public void AddShuiYinPic(string path, string Path_syp, string Path_sypf)
{
path = path.Replace(@"\\",@"\");
path = path.Replace("/",@"\");

System.Drawing.Image image = System.Drawing.Image.FromFile(path);
//string changedImage = string.Empty;
if (IsPixelFormatIndexed(image.PixelFormat))
{
MemoryStream ms = new MemoryStream();
Bitmap bmp = new Bitmap(image);//生成位图
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
image.Dispose();
image = System.Drawing.Image.FromStream(ms, true);
bmp.Dispose();
ms.Close();
ms.Dispose();
}

//System.Drawing.Image image = System.Drawing.Image.FromFile(path);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
g.DrawImage(copyImage, new System.Drawing.Rectangle(image.Width - copyImage.Width, 0, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel);
g.Dispose();

image.Save(Path_syp);
image.Dispose();
copyImage.Dispose();
}

会出现内存不足的提示,但是代码没啥问题啊,帮助看看吧。谢谢了高手们。
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
vcfansli
C# 111,129 成员 642,539 内容