小编Cow*_*Boy的帖子

字符转换为位图图像 C#

例如,我需要一个字符串数组:a[] = {A,B,C,...,Z}然后从数组中随机选择一个字母并在其上应用 windows 目录中的字体,然后以具有特定宽度和高度的位图图像的形式向用户呈现该特定字母(例如在我的表单中的图像框中将其显示为位图图像)。

c# arrays fonts character bitmap

2
推荐指数
1
解决办法
3803
查看次数

我应该添加什么参考来修复GetPixel错误?

在我尝试编写一些代码时,我收到了这个错误:

错误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)

c#

2
推荐指数
1
解决办法
1012
查看次数

如何在"for循环"中延迟?

如何编写代码以在"for循环"结束时延迟,以便在通过下一个循环之前产生例如1毫秒的延迟?

c# loops for-loop delay

0
推荐指数
1
解决办法
4196
查看次数

标签 统计

c# ×3

arrays ×1

bitmap ×1

character ×1

delay ×1

fonts ×1

for-loop ×1

loops ×1