[英]Drawing a dot with Windows GDI
I am very familiar with the Windows GDI graphics API and there is a function I have been missing for ages: how to draw a dot ? 我对Windows GDI图形API非常熟悉,并且有一个很久以来我一直都缺少的功能:如何绘制点?
By a dot, I mean a small pattern of pixels, say a 3x3 or 5x5 square (possibly with corners omitted), all the same color. 用点表示的是一小块像素图案,例如3x3或5x5正方形(可能省略了边角),所有颜色均相同。
My constrains are that I want to do this efficiently and with as little resources as possible. 我的约束是我想以尽可能少的资源高效地执行此操作。
I could use the SetPixel
function as many times as required (25 calls for a 5x5 square). 我可以根据需要多次使用
SetPixel
函数(25次调用需要5x5平方)。
I could probably use the MoveTo
/ LineTo
calls with a thick pen twice on the same coordinates. 我可能可以在相同的坐标上用粗笔两次使用
MoveTo
/ LineTo
调用。 But I am unsure that this will generate a full dot, and I don't like the idea of creating a dedicated pen. 但是我不确定这会产生一个完整的点,并且我不喜欢创建专用笔的想法。
I can also use the Rectangle
or Ellipse
function, but these ones draw the outline and fill the inside and must be an overkill for such a tiny shape. 我也可以使用
Rectangle
或Ellipse
函数,但是这些函数会绘制轮廓并填充内部,因此对于这样一个微小的形状来说肯定是过大了。 (Not counting the fact that they require a dedicated pen and a dedicated brush.) (不包括他们需要专用笔和专用画笔的事实。)
Do you have any insight on what could be an efficient and handy approach ? 您对什么是有效且便捷的方法有什么见解? How would you do that ?
你会怎么做?
At least as far as I know, none of the available options is really ideal. 至少据我所知,没有可用的选项是真正理想的。 That given, it seems to me that
FillRect
is probably the least problematic. 鉴于此,在我看来
FillRect
可能是问题最少的。
This requires that you create a brush of the correct color, but at least that's all it requires. 这要求您创建正确颜色的画笔,但至少仅此而已。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.