c#使用自定义像素绘制文本

我想知道这是否可能:我的ac#应用程序有一个类似于在表单上绘制的大约11000个圆圈的显示。

我想要实现的是能够在该显示器上绘制文本,但不使用“真实”像素,而是使用在表单上绘制的圆圈(矩形)作为像素。

编辑1:

在c#中绘制文本时,您可以使用Graphics.DrawString(...)类的东西,为方法提供一个矩形(如此坐标),其中应该绘制文本。然后使用屏幕在该矩形中绘制该文本像素。 我想要做的是绘制文本,但不使用屏幕像素,但我的显示组成的自定义像素。

编辑2

用于在表单上绘制圆圈的方法; Circles是由Circle对象组成的列表,其中circleRectangle返回应绘制圆的坐标, Filled告诉方法是否应填充圆。

  public void DrawCircles(Graphics g) { graphics = g; graphics.SmoothingMode =System.Drawing.Drawing2D.SmoothingMode.AntiAlias; Pen pen = new Pen(Color.Black, penthickness); SolidBrush brush = new SolidBrush(Color.White); for (int j = 0; j < Circles.Count;j++ ) { graphics.DrawEllipse(pen, Circles[j].CircleRectangle); if (Circles[j].Filled) brush.Color = fillColor; else brush.Color = Color.White; graphics.FillEllipse(brush, Circles[j].CircleRectangle); } } 

这是可能的,如果是的话,我该怎么做?

您可以使用DrawText方法在不可见的BitMap上书写,然后扫描位图的像素并打开相应的圆圈。

这是上周与DataGridView的单元格。 很容易。

这是一些代码:

  public void drawText(string text, Font drawFont) { Bitmap bmp = new Bitmap(canvasWidth, canvasHeight); Graphics G = Graphics.FromImage(bmp); SolidBrush brush = new SolidBrush(paintColor); Point point = new Point( yourOriginX, yourOriginY ); G.DrawString(text, drawFont, brush, point); for (int x = 0; x < canvasWidth; x++) for (int y = 0; y < canvasHeight; y++) { Color pix = bmp.GetPixel(x, y); setCell(x, y, pix); //< -- set your custom pixels here! } bmp.Dispose(); brush.Dispose(); G.Dispose(); } 

编辑 :当然,您可以使用尺寸和原点作为DrawString