请教QT中怎样在一个图片上画点

weixin_38053088 2019-09-19 12:10:12
小弟已经有一个程序可以把图片显示出来,想在图片上画点,不知改如何实现?希望达人们说的详细点,小弟是新手,谢谢达人们了!
...全文
874 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
小汤- 2022-03-02
  • 打赏
  • 举报
回复

原文:
void setPixel ( const QPoint & position, uint index_or_rgb )Sets the pixel index or color at the given position to index_or_rgb.If the image's format is either monochrome or 8-bit, the given index_or_rgb value must be an index in the image's color table, otherwise the parameter must be a QRgb value.If position is not a valid coordinate pair in the image, or if index_or_rgb >= numColors() in the case of monochrome and 8-bit images, the result is undefined.See also pixel() and Pixel Manipulation.

翻译(DeepL提供):
void setPixel ( const QPoint & position, uint index_or_rgb ) 如果图像的格式是单色或8位,给定的index_or_rgb值必须是图像颜色表中的一个索引,否则参数必须是一个QRgb值。如果位置不是图像中的有效坐标对,或者在单色和8位图像中index_or_rgb>=numColors(),结果是未定义的。另见pixel()和Pixel Manipulation。

weixin_38067167 2019-09-19
  • 打赏
  • 举报
回复
setPixel (x, y, QRgb(r,g,b))即可
weixin_38075729 2019-09-19
  • 打赏
  • 举报
回复
?不好意思,小弟没看懂,可以解释一下这个函数吗?
weixin_38095754 2019-09-19
  • 打赏
  • 举报
回复
void setPixel ( const QPoint & position, uint index_or_rgb ) Sets the pixel index or color at the given position to index_or_rgb.If the image's format is either monochrome or 8-bit, the given index_or_rgb value must be an index in the image's color table, otherwise the parameter must be a QRgb value.If position is not a valid coordinate pair in the image, or if index_or_rgb >= numColors() in the case of monochrome and 8-bit images, the result is undefined.See also pixel() and Pixel Manipulation.
weixin_38112544 2019-09-19
  • 打赏
  • 举报
回复
那个......小弟很菜,英文只看了个一知半解,我想是在图上动态的画点,就是“点哪画哪”那种,不知上面的函数是否能实现?
weixin_38119941 2019-09-19
  • 打赏
  • 举报
回复
既然要动态,你要先得到点的位置,然后再调用1楼的函数。
weixin_38121048 2019-09-19
  • 打赏
  • 举报
回复
都在要paintEvent()函数里面实现吧

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧