![]() |
| | #1 |
| Registered User Join Date: Feb 2009
Posts: 1
| workarround with CreateDIBSection i would like to scan a certain range of my desktop for a certain pixel colour in always recurring distances. The whole should run in the background (i use WinXP Prof) and as fast as possible. First i tried it with "GetPixel" (see the code with GetPixel) and i could do it successfully. But the handicap is that with bigger ranges "GetPixel" is simply to slow! In the meantime i have read that there is a quicker possibility with "CreateDIBSection" Now i tried to do the same work with "CreateDIBSectio" but i couldnt resovlve that problem. Can anybody help me and give me a codesnippet that do the same work as the GetPixel-code-example? It would be very very nice :-) regards, rommi (C++ Beginner) ****** code with GetPixel ************ Code: int x, y;
HDC dc = GetDC(0);
int seekpix = 16777215;
while(true)
{
for(x=100; x < 500; x++)
{
for(y=200; y < 800; y++)
{
//=========== Desktop-Pixelfarbe ermitteln
COLORREF deskpix = GetPixel(dc, y, x);
//=========== Desktop-Pixelfarbe mit Suchpixel vergleich
if(deskpix == seekpix)
{
//execute further code
}
}
}
}
Code: // Deklaration HDC hdc_screen; BITMAPINFO bmi; LPBYTE pBits; int x=500; int y=800; // window-id HWND desktopHandle = GetDesktopWindow(); // device-context hdc_screen = GetDC(desktopHandle); // clean ZeroMemory(&bmi, sizeof(bmi)); // Parameter DIBSection bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth = x; bmi.bmiHeader.biHeight = y; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 24; bmi.bmiHeader.biCompression = BI_RGB; // Create DibSection HBITMAP hdcBmp = CreateDIBSection(hdc_screen, &bmi, DIB_RGB_COLORS, (void **)&pBits, NULL, 0); // ?????? // ?????? |
| rommi is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CreateDIBSection() returning NULL | arjunajay | Windows Programming | 5 | 07-26-2006 09:54 AM |
| MapViewOfFile and CreateDIBSection problem with bitmaps | LuckY | Windows Programming | 2 | 08-18-2004 08:37 AM |
| Loading bitmaps with createfile() +CreateDIBSection | Stevo | Windows Programming | 7 | 05-13-2004 09:22 PM |