Home > Software engineering >  Be effective screen area pixel value complete code
Be effective screen area pixel value complete code

Time:09-24

The rectangular area screen pixel values stored in two dimensional array to calculate characteristics identification number

Don't know much about the setting parameters, directly give me the complete code can read 2 times per second, under the VS2017 compiled through

CodePudding user response:

Is about the application of the GetDIBits
http://blog.csdn.net/iamshuke/article/details/5749948



CodePudding user response:

Refer to the http://www.autohotkey.comImageSearch function corresponding to the source code,

CodePudding user response:

See you another post

CodePudding user response:

See you move

CodePudding user response:

Is
CreateCompatibleDC
CreateDIBSection//take directly to the pixel data pointer
From the screen BitBlt to establish the DC
Read pixels directly from pointer
Every minute, even what complete code
Junction post rate: 0% but credibility is not high, oh

CodePudding user response:

Great, very well, thank your share

CodePudding user response:

 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* \ function name:
* CopyScreenToDIB
*
* \ input parameters:
* LPRECT LPRECT - need to copy the screen area
* * pDibDest CDib - pointer to the target object of CDib
*
* \ return value:
* BOOL - if the operation is successful, it returns TRUE
*
* \ description:
* this function will be within the specified rectangle in the screen contents copied to source in the DIB data copies of CDib class pDibSrc into pDibDst
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
BOOL CopyScreenToDIB (LPRECT LPRECT, CDib * pDibDest)
{
//screen device context and memory device context handle
HDC hScrDC hMemDC;
//statement handle to the BITMAP BITMAP handle and temporarily before
HBITMAP HBITMAP hOldBitmap;
//palette handle
HPALETTE HPALETTE.
//for rectangle coordinates
Int nX, nY, nX2 nY2;
//the height and width of the DIB image
Int nWidth, nHeight;
//screen resolution
Int xScrn yScrn;
//if the given rectangle is empty, is not for further processing
If (IsRectEmpty (lpRect)) return FALSE.
//get a screen device context
HScrDC=CreateDC (" DISPLAY ", NULL, NULL, NULL);
//create and screen equipment compatible with the memory device context
HMemDC=CreateCompatibleDC (hScrDC);
//get the rectangle area coordinates
NX=lpRect - & gt; The left;
NY=lpRect - & gt; Top;
NX2=lpRect - & gt; Right;
NY2=lpRect - & gt; Bottom;
//get the resolution of the screen, so that the back of the judgment at
XScrn=GetDeviceCaps (hScrDC HORZRES);
YScrn=GetDeviceCaps (hScrDC VERTRES);
//to determine whether a rectangular area beyond the screen
If (nX & lt; NX=0, 0).
If (nY & lt; NY=0, 0).
If (nX2 & gt; NX2=xScrn xScrn);
If (nY2 & gt; NY2=yScrn yScrn);
//calculate the DIB image height and width of the
NWidth=nX2 - nX;
NHeight=nY2 - nY.
//create a compatible with screen device context of DDB bitmap
HBitmap=CreateCompatibleBitmap (hScrDC, nWidth, nHeight);
//will be elected to DDB bitmap memory device context
HOldBitmap=(HBITMAP) SelectObject (hMemDC HBITMAP);
//to the designated area in the screen image transfer to a memory device context
BitBlt (hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY);
//then to elected to a previous image, and get the screen area of DDB image handle
HBitmap=(hBitmap) SelectObject (hMemDC hOldBitmap);
//delete temporary device context
DeleteDC (hScrDC);
DeleteDC (hMemDC);
//get the current system palette
HPalette=GetSystemPalette ();
//will be DDB images into a DIB image
PDibDest - & gt; ConvertFromDDB (hBitmap, hPalette);
//delete temporary objects
DeleteObject (hPalette);
DeleteObject (hBitmap);

Return TRUE;
}

CodePudding user response:

CreateDIBSection bright!

CodePudding user response:


CodePudding user response:

Ha ha, remember there's a CDib class can finish it all

CodePudding user response:

Use the CreateDIBSection, DC to BitBlt window data into memory and then direct memory operation

CodePudding user response:

refer to 12 floor OExpress reply:
ha ha, remember there's a CDib class can finish it all

A ma3 jia3,

CodePudding user response:

Ma3 jia3 everyone will wear, each have subtly different,
  • Related