例如,我需要一个字符串数组:a[] = {A,B,C,...,Z}然后从数组中随机选择一个字母并在其上应用 windows 目录中的字体,然后以具有特定宽度和高度的位图图像的形式向用户呈现该特定字母(例如在我的表单中的图像框中将其显示为位图图像)。
在我尝试编写一些代码时,我收到了这个错误:
错误1'System.Drawing.Image'不包含'GetPixel'的定义,也没有扩展方法'GetPixel'接受类型'System.Drawing.Image'的第一个参数(你是否缺少using指令或者装配参考?)
有谁知道我需要做什么?
//Create a Image-Object on which we can draw
Image bmp = new Bitmap(100, 100);
//Create the Graphics-Object to paint on the Bitmap
Graphics g = Graphics.FromImage(bmp);
g.Clear(Color.White);
g.DrawString(randomString, myFont, new SolidBrush(Color.Black), new PointF(0, 0));
pictureBox1.Image = bmp;
bmp.Save(@"CAPTCHA.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
var backgroundPixels = 0;
for (int x = 0; x < bmp.Width; x++)
for (int y = 0; y < bmp.Height; y++)
if (bmp.GetPixel(x, y) == Color.White)
backgroundPixels++;
Run Code Online (Sandbox Code Playgroud) 如何编写代码以在"for循环"结束时延迟,以便在通过下一个循环之前产生例如1毫秒的延迟?