Home > Software engineering >  How to use the mouse to get Picture Control controls in the pixel position of the Picture?
How to use the mouse to get Picture Control controls in the pixel position of the Picture?

Time:09-16

Pictures in a Picture control is to use CvvImage: : DrawToHDC show,
Now I want to through the mouse to click the position of Picture controls, to get the Picture pixel location Picture controls,

My Picture is 640 * 480 pixels, for example, shown in the Picture control, Picture controls may be 700 * 500;
The mouse to click when I can get a Picture control position, but how to get the Picture control image pixel position (640 * 480),


What's the use of Picture controls and pictures are the mapping relationship?

CodePudding user response:

Move the picture Window size for the picture

CodePudding user response:

The CDC has GetPixel function
the CDC: : GetPixel

CodePudding user response:

refer to the second floor zgl7903 response:

the CDC have GetPixel function the CDC: : GetPixel

You said this function is to get the pixel values of the Picture, I want to get the Picture control corresponding to the position of image pixels,

CodePudding user response:

 
{
The CWnd * pCtrl=GetDlgItem (IDC_PIC_CTRL);
If (pCtrl & amp; & PCtrl - & gt; M_hWnd)
{
The CDC * pDC=pCtrl - & gt; GetDC ();
If (pDC)
{
COLORREF cr=pDC - & gt; GetPixel (x, y);
PCtrl - & gt; The ReleaseDC (pDC);
}
}
}



CodePudding user response:

reference 4 floor zgl7903 response:
 
{
The CWnd * pCtrl=GetDlgItem (IDC_PIC_CTRL);
If (pCtrl & amp; & PCtrl - & gt; M_hWnd)
{
The CDC * pDC=pCtrl - & gt; GetDC ();
If (pDC)
{
COLORREF cr=pDC - & gt; GetPixel (x, y);
PCtrl - & gt; The ReleaseDC (pDC);
}
}
}


Thanks brother reply, I don't need the location of the Rgb values, need is the picture control position corresponding to the image coordinates (namely the image value, at the top left corner as (0, 0))

CodePudding user response:

"Image pixel location" related to image format!

CodePudding user response:

Such as * x x coordinates can be 640/700 to get the image coordinates, probably to I think there should be a more accurate method

CodePudding user response:

If do not have what good idea, or a relationship than column of an almost, gap will not be huge

CodePudding user response:

reference 1st floor schlafenhamster response:
Move picture Window size for the picture

Controls MoveWindow into the size of the picture?

CodePudding user response:

Controls MoveWindow proportion into image size after no problem, but the picture in the ranks of position is related to the image format
Icon Bitmap; PNG...

CodePudding user response:

references to the tenth floor schlafenhamster response:
MoveWindow control proportion into image size after no problem, but the picture in the ranks of position is related to the image format
Icon Bitmap; PNG...

I took one of the most stupid way, change the picture control to the same size and pictures

CodePudding user response:


CodePudding user response:

Pictures to DC, you want to visit the image content, you must BitBlt (DC - equipment & gt; The memory DC) then access memory

CodePudding user response:

Pictures will read in the data in the buffer, and then, according to the mouse point to the location of the from buffer read pixel value corresponding to the position
  • Related