Créer un DC temporaire, dessiner dedans et récuperer pixels
Bonjour à tous,
je voudrais arriver à dessiner (opérations basiques du GDI) dans un DC temporaire, qui n'a pas pour vocation d'etre affiché.
Ce DC devra pouvoir etre très gros (plus grand que la résolution de l'écran, pour que ca ressemble un peu à un DC d'imprimante)
Après le dessin, j'aimerai récuperer un tableau de pixel, afin de l'analyser.
Voilà ce que je fais :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| BITMAPINFO bmInfo;
memset(&bmInfo.bmiHeader, 0, sizeof(BITMAPINFOHEADER));
bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth = 6714; // big size
bmInfo.bmiHeader.biHeight = 4662;
bmInfo.bmiHeader.biPlanes = 1;
bmInfo.bmiHeader.biBitCount = 24;
LPVOID pBit32;
HBITMAP hBmp = CreateDIBSection(0, &bmInfo, DIB_RGB_COLORS, &pBit32, NULL, 0);
HDC sdc = GetDC(NULL);
HDC memDc = CreateCompatibleDC(sdc);
HBITMAP holdobj = (HBITMAP) SelectObject(memDc, hBmp);
HBRUSH hBrush = CreateSolidBrush (RGB(255,0,0));
RECT rect = {2,0,20,200};
FillRect (memDc, &rect, hBrush) ;
DeleteObject (hBrush) ;
SelectObject(memDc, holdobj);
DeleteDC(hdc);
ReleaseDC(NULL, sdc); |
mais bon, j'ai l'impression que pBit32 contient que des 0, alors qu'il devrait plutot y avoir du rouge ....
Qu'est-ce qui n'est pas bon ? Est-ce la bonne méthode ?
Merci de vos aides