c#的内存不足问题,经典问题了吧,就是不会解决啊!帮忙
代码如下:
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();
}
会出现内存不足的提示,但是代码没啥问题啊,帮助看看吧。谢谢了高手们。
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();
}
会出现内存不足的提示,但是代码没啥问题啊,帮助看看吧。谢谢了高手们。
...全文
相关推荐
C#经典范例50例
本书是介绍面向对象的程序开发语言C#语言的专题书籍,C#语言能够使程序员在微软提供了.NET开发平台上快速开发出种类丰富的应用程序。书中通过50个经典实例详细介绍了用C#语言开发应用的方法与技巧……
告别手动配置!用Docker镜像5分钟搞定CAD Exchanger SDK开发环境(C++/C#/Java/Python全支持)
本文介绍如何利用CAD Exchanger SDK的Docker镜像快速部署全语言开发环境(C++/C#/Java/Python),5分钟即可完成配置。通过容器化方案解决传统环境配置的痛点,提升开发效率,支持多语言开发实战和企业级应用集成,适用于CAD数据处理领域。
C#图片处理经典方法,图片绝对不会失真!
我做项目的是用它:C#图片处理经典方法,图片绝对不会失真!
c#解决汉诺塔问题-经典算法。
用c#写的算法,求解汉诺塔问题,经典的递归算法。业界的经典,看了一定叫绝,。作为算法来说这算法还是很好的,有空可以联系我QQ1424687997
C#经典编程-220例
C#经典编程-220例 超经典的C#编程教程,免费下载


