如何在png上实现Hittest [英] How to implement Hittest on png's

查看:117
本文介绍了如何在png上实现Hittest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:-)



我有Cwnd,我在其中绘制一个.png文件。 (首先我将其转换为CBitmap,然后我绘制它)



现在我需要一个hittest-function:如果用户点击png-Image,是否有一个找到像素的方法,他点击了吗?



对我有什么帮助:



如果例如,在png中有一个圆圈,有没有办法在屏幕坐标中找到这个圆圈的区域,或者是否有一种方法可以找到,如果png图像上有一个点击在这个圆圈内?



thx任何帮助!

hi all:-)

I have Cwnd in which i draw a .png-file. (First i convert it to a CBitmap, then i draw it)

Now i need a hittest-function: If a user clicks on the png-Image, is there a way to find the pixel, he clicked on?

What would help me too:

If there is for example a circle in the png, is there a way to find the area of this circle in screen-coordinates, or is there a method to find, if a click on the png-image was inside this circle?

thx for any help!

推荐答案

您必须处理鼠标消息。为此,您必须覆盖窗口中的消息处理程序。这是Microsoft 文档,用于显示鼠标消息。您必须获取点击坐标,然后使用图片的坐标进行检查。
You must handle the mouse messages. For that you must overwrite the message handler in your window. Here is the Microsoft documentation for the mouse messages. You must fetch the click coordinates and than check it with the coordinates of your picture.


这篇关于如何在png上实现Hittest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆