我想复制 https://www.c-sharpcorner.com/article/solution-for-a-graphics-object-cannot-be-created-from-an-im/ '
我正在尝试创建和保存像素格式设置为 Dont care ,但我一直在 Parameter not valid 例外。
Dont care
Parameter not valid
Bitmap orig = new Bitmap(500,500); Bitmap clone = new Bitmap(orig.Width, orig.Height, System.Drawing.Imaging.PixelFormat.DontCare); using (Graphics gr = Graphics.FromImage(clone)) { gr.DrawImage(orig, new Rectangle(0, 0, clone.Width, clone.Height)); } clone.Save("test.png");