如何创建白色的1024x1024 RGB位图图像? [英] How to create 1024x1024 RGB bitmap image of white?
本文介绍了如何创建白色的1024x1024 RGB位图图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问这个问题很尴尬,却找不到答案。
It's embarrassing to ask this question but can't find an answer.
我徒劳地尝试了这个。
Image resultImage = new Bitmap(image1.Width, image1.Height, PixelFormat.Format24bppRgb);
using (Graphics grp = Graphics.FromImage(resultImage))
{
grp.FillRectangle(
Brushes.White, 0, 0, image1.Width, image1.Height);
resultImage = new Bitmap(image1.Width, image1.Height, grp);
}
我基本上想在C#中用白色填充1024x1024 RGB位图图像。我该怎么办?
I basically want to fill a 1024x1024 RGB bitmap image with white in C#. How can I do that?
推荐答案
您正在将新图像分配给 resultImage
,从而覆盖您之前创建白色图像的尝试(顺便说一句,应该会成功)。
You are assigning a new image to resultImage
, thereby overwriting your previous attempt at creating a white image (which should succeed, by the way).
因此,只需删除该行
resultImage = new Bitmap(image1.Width, image1.Height, grp);
这篇关于如何创建白色的1024x1024 RGB位图图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文