Bitmap img = new Bitmap("C:\\temp\\images\\file.jpg");img.PixelFormat是Format24bppRgb
当我在做深度复制的时候
Bitmap img2 = new Bitmap(img);img.PixelFormat改为Format32bppArgb
为什么它改变像素格式?如果对象不做深拷贝,如何为其制作深拷贝?
发布于 2013-11-18 09:59:19
您可以像这样克隆位图,这将创建一个深拷贝:
Bitmap img = new Bitmap("C:\\temp\\images\\file.jpg");
// Clone the bitmap.
Rectangle cloneRect = new Rectangle(0, 0, img.Width, img.Height);
System.Drawing.Imaging.PixelFormat format =
img.PixelFormat;
Bitmap img2 = img.Clone(cloneRect, format);发布于 2013-11-18 09:58:39
只是找到了解决方案,而新的位图(Img)使用Bitmap img2 = (Bitmap) img.Clone();并不知道它是正确的解决方案,但它做的工作。
https://stackoverflow.com/questions/20044431
复制相似问题