salut a tous,

mon programme plante et je ne trouve pas la solution. voici le code de la fonction qui fait planter :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    //largeur de l'écran
    int resolution_x = GetSystemMetrics(SM_CXSCREEN);
    //hauteur de l'écran
    int resolution_y = GetSystemMetrics(SM_CYSCREEN);
 
    //le HDC de l'ecran
    HDC hdcEcran = GetDC(NULL);
    //le HDC mémoire
    HDC hdcMemoire = CreateCompatibleDC(hdcEcran);
    //le HBITMAP de l'image de l'écran
    HBITMAP hbitmap = CreateCompatibleBitmap(hdcEcran, resolution_x, resolution_y);
    //selection de l'objet
    SelectObject(hdcMemoire, hbitmap);
 
    //copie de la surface
    BitBlt(hdcMemoire, 0, 0, resolution_x, resolution_y, hdcEcran, 0, 0, SRCCOPY);
 
    //ici on a un hbitmap valide
 
    //création des variables pour getdiblits
    BITMAP bitmap;
    BITMAPINFO bitmapinfo;
    BYTE *lpBits = NULL;
 
    //initialisation des variables
    ZeroMemory(&bitmap,sizeof(BITMAP));
    ZeroMemory(&bitmapinfo,sizeof(BITMAPINFO));
 
    //
    GetObject(hbitmap, sizeof(BITMAP), (LPSTR)&bitmap);
 
    //initialisation de bitmapinfoheader
    bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bitmapinfo.bmiHeader.biWidth = bitmap.bmWidth;
    bitmapinfo.bmiHeader.biHeight = bitmap.bmHeight;
    bitmapinfo.bmiHeader.biPlanes = 1;
    bitmapinfo.bmiHeader.biBitCount = 32;
    bitmapinfo.bmiHeader.biCompression = BI_RGB;
    bitmapinfo.bmiHeader.biSizeImage = 0;
    bitmapinfo.bmiHeader.biXPelsPerMeter = 0;
    bitmapinfo.bmiHeader.biYPelsPerMeter = 0;
    bitmapinfo.bmiHeader.biClrUsed = 0;
    bitmapinfo.bmiHeader.biClrImportant = 0;
 
    //allocation
    lpBits = new BYTE[bitmapinfo.bmiHeader.biWidth*bitmapinfo.bmiHeader.biHeight*4];
 
    //position du point de pixel
    bool chercher_encore = false;
 
    //on récupere ls données
    if(GetDIBits(hdcEcran, hbitmap, 0, (UINT)bitmapinfo.bmiHeader.biHeight, lpBits, &bitmapinfo, DIB_RGB_COLORS)){
 
        //si GetDIBits à fonctionné
 
        //on lit chaque coef du RGB
        int r = lpBits[4*((pixel.y*bitmapinfo.bmiHeader.biWidth)+pixel.x)+2];
        int g = lpBits[4*((pixel.y*bitmapinfo.bmiHeader.biWidth)+pixel.x)+1];
        int b = lpBits[4*((pixel.y*bitmapinfo.bmiHeader.biWidth)+pixel.x)];
 
        //si on ne trouve pas de pixel bleu
        if(!verifier_couleur_bleu(r,g,b)){
 
            //il faut continuer
            chercher_encore = true;
 
        }
 
    }
 
    //on libere
    delete(&lpBits);
 
    //on supprime le HBITMAP
    DeleteObject(hbitmap);
    //on libere le HDC mémoire
    DeleteDC(hdcMemoire);
    //on libere le HDC de l'ecran
    ReleaseDC(NULL, hdcEcran);
 
    return chercher_encore;
ça plante au niveau du
Code : Sélectionner tout - Visualiser dans une fenêtre à part
lpBits = new BYTE[bitmapinfo.bmiHeader.biWidth*bitmapinfo.bmiHeader.biHeight*4];
j'imagine donc que c'est un problème de mémoire. voyez vous une erreur vous?