是否可以使用“填充颜色” Delphi 的图像组件上的函数?
我的表单上有一个 TImage 组件。我需要实现以下功能:(
如果鼠标指针位于红色点上,则对该点应用“填充绿色”)
这里的“填充颜色”是指 Paint 的功能“填充颜色”。 TImage中有类似的东西吗?还是我应该自己实现这个功能?
你
谢谢 我用的是德尔福7
I have a TImage component on the form. I need to implement the following functionality:
(If mouse pointer is over point with red color, then apply "Fill with color green" to that point)
Here by "Fill with color" I mean Paint's function "Fill with color". Is there anything similar in TImage? Or should I implement this function myself?
Thank you
P.S. I use Delphi 7
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我猜你说的是“洪水填充”。不久前,我根据维基百科文章编写了自己的实现。我将位图表示为
TRGBQuad
像素的二维数组。完整代码为
项目文件
为了方便起见,您可以下载整个来自
的项目示例位图。
I guess you are talking about "flood fill". Some time ago, I wrote my own implementation of this based on the Wikipedia article. I represent the bitmap as a two-dimensional array of
TRGBQuad
pixels.The complete code is
Project files
For your convenience, you can download the entire project from
Don't forget the sample bitmap.
TImage
中没有内置任何内容来执行您所要求的操作。您可以自己实现,尽管您可能不会从
TImage
开始。或者,您可能会很幸运地寻找能够提供您所需功能的第三方绘画组件。There's nothing built in to
TImage
to do what you ask.You could implement yourself although you would probably not start from
TImage
. Or perhaps you might have some fortune searching for a 3rd party painting component that offered the functionality you need.实际上我设法使用 Image1.Canvas.FloodFill 函数来实现这一点。我只需使用 (Image1.ClientWidth/Image1.Picture.Bitmap.Width) 比率(高度相同)缩放坐标。获得新坐标后,我可以使用 Image1.Canvas.Pixels 矩阵和缩放坐标来获取点的颜色。似乎对我来说工作得很好,不需要额外的功能。
Actually I managed to implement this using Image1.Canvas.FloodFill function. I just had to scale the coordinates using (Image1.ClientWidth/Image1.Picture.Bitmap.Width) ratio (same for height). After getting new coordinates I could get the color of point by using Image1.Canvas.Pixels matrix and scaled coordinates. Seems to work fine with me, and no need for additional functions.