C#2003 Graphics画图内存不足
hzpdh 2013-12-07 12:01:33 我在做一个两张图片合并处理,小图片设置一定透明度覆盖在大图上。报错代码位置在g.DrawImage(小图(Image), new Rectangle(intX, intY, iWidth, iHeight), 0, 0, iWidth, iHeight, GraphicsUnit.Pixel,ImgAtt); 提示内存不足。
关键就是在这个ImgAtt上(我一加上就提示,去掉就不提示,这段是设置透明度的) ImgAtt设置如下:
ImageAttributes ImgAtt = new ImageAttributes();
ColorMap colorMap = new ColorMap();
colorMap.OldColor = Color.FromArgb(255, 0, 255, 0);
colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);
ColorMap[] remapTable = { colorMap };
imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);
float[][] colorMatrixElements = {
new float[] {1.0f, 0.0f, 0.0f, 0.0f, 0.0f},
new float[] {0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
new float[] {0.0f, 0.0f, 1.0f, 0.0f, 0.0f},
new float[] {0.0f, 0.0f, 0.0f, (float)iDiaphaneity/100f, 0.0f},
new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}};
ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements);
ImgAtt.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); 请高手帮我看一下。
补充:我没画越界,涉及到的相关Bitmap、Image、Graphics参数是放在最后释放的。