I'm trying to reproduce ' https://www.c-sharpcorner.com/article/solution-for-a-graphics-object-cannot-be-created-from-an-im/ '
(我正在尝试复制' https://www.c-sharpcorner.com/article/solution-for-a-graphics-object-can-be-be-created-from-an-im/ ')
I'm trying to create and save a Bitmap with Pixel Format set to Dont care ,but i keep getting Parameter not valid exception.
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");
2.1m questions
2.1m answers
60 comments
57.0k users