D'abord je mexcuse au pret des admins je suis pas du tout sur d'etre au bon endroit, mais comme les gens d'ici font de l'image...

Alors voilà mon probleme, j'aimerai faire une copie de bitmap en memoie pour afficher :
Un qui n'est pas touché
Un qui est simplement tourné d'un angle X

Une copie simple peut ce faire comme ça (elle marche)

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
HBITMAP CopyBitmap( HBITMAP hbm) {
    HDC hdcSrc = CreateCompatibleDC(NULL);
    HDC hdcDst = CreateCompatibleDC(NULL);
    HBITMAP hbmOld, hbmOld2, hbmNew;
    BITMAP bm;
    GetObject(hbm, sizeof(bm), &bm);
    hbmOld = SelectObject(hdcSrc, hbm);
    hbmNew = CreateBitmap( bm.bmWidth, bm.bmHeight, bm.bmPlanes, bm.bmBitsPixel,
            NULL);
    hbmOld2 = SelectObject(hdcDst, hbmNew);
    BitBlt(hdcDst, 0, 0, bm.bmWidth, bm.bmHeight, hdcSrc, 0, 0, SRCCOPY);
    SelectObject(hdcSrc, hbmOld);
    DeleteDC(hdcSrc);
    DeleteDC(hdcDst);
    return hbmNew;
}
le truc c'est que ce code me donne pas un acces "correcte" aux valeurs de pixels de l'image, alors pour avoir le controle total des pixels je fais une copie plus compliquée avec CreateDIBSection
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
82
83
84
85
86
87
88
89
90
91
92
HBITMAP CRotate::SimpleCopie(HDC hDC, HBITMAP hSourceBitmap)
{
	/*
	HDC hdcSrc = CreateCompatibleDC(NULL);
    HDC hdcDst = CreateCompatibleDC(NULL);
    HBITMAP hbmOld, hbmOld2, hbmNew;
    BITMAP bm;
    GetObject(hSourceBitmap, sizeof(bm), &bm);
    hbmOld = (HBITMAP) SelectObject(hdcSrc, hSourceBitmap);

    hbmNew = CreateBitmap( bm.bmWidth, bm.bmHeight, bm.bmPlanes, bm.bmBitsPixel,NULL);

    hbmOld2 = (HBITMAP) SelectObject(hdcDst, hbmNew);
    BitBlt(hdcDst, 0, 0, bm.bmWidth, bm.bmHeight, hdcSrc, 0, 0, SRCCOPY);
    SelectObject(hdcSrc, hbmOld);
    DeleteDC(hdcSrc);
    DeleteDC(hdcDst);
    return hbmNew;
	*/
	//2. Getting bimap size.
	BITMAP bm;
	GetObject(hSourceBitmap, sizeof(BITMAP), &bm);


	//3. Creating new bitmap and receive pointer to it's bits.
	HBITMAP hTargetBitmap;
	void *pBuffer;

	//3.1 Initilize DIBINFO structure
	BITMAPINFO bi = {0};
	bi.bmiHeader.biBitCount = 32;
	bi.bmiHeader.biClrImportant = 0;
	bi.bmiHeader.biClrUsed = 0;
	bi.bmiHeader.biCompression = 0;
	bi.bmiHeader.biHeight = bm.bmHeight;
	bi.bmiHeader.biPlanes = 1;
	bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);;
	bi.bmiHeader.biSizeImage = bm.bmWidth*bm.bmHeight*3;
	bi.bmiHeader.biWidth = bm.bmWidth;
	bi.bmiHeader.biXPelsPerMeter = 3780;
	bi.bmiHeader.biYPelsPerMeter = 3780;
	bi.bmiColors[0].rgbBlue = 0;
	bi.bmiColors[0].rgbGreen = 0;
	bi.bmiColors[0].rgbRed = 0;
	bi.bmiColors[0].rgbReserved = 0;


	//3.2 Create bitmap and receive pointer to points into pBuffer
	hTargetBitmap = CreateDIBSection(
		hDC,
		&bi,
		DIB_RGB_COLORS,
		(void**)&pBuffer,
		NULL,
		0);


	//4. Copy source bitmap into the target bitmap.

	//4.1 Create 2 device contexts 
	HDC memDc = CreateCompatibleDC(NULL);
	HDC targetDc = CreateCompatibleDC(NULL);

	//4.2 Select source bitmap into one DC, target into another
	HBITMAP hOldBitmap1 = (HBITMAP)::SelectObject(memDc, hSourceBitmap);
	HBITMAP hOldBitmap2 = (HBITMAP)::SelectObject(targetDc, hTargetBitmap);

	//4.3 Copy source bitmap into the target one
	BitBlt(memDc,0, 0, bm.bmWidth, bm.bmHeight, memDc, 0, 0, SRCCOPY);

	//4.4 Restore device contexts
	::SelectObject(memDc, hOldBitmap1);
	::SelectObject(targetDc, hOldBitmap2);
	DeleteDC(memDc);
	DeleteDC(targetDc);

	//Here we can bitmap bits: pBuffer. Note:
	// 1. pBuffer contains 3 bytes per point
	// 2. Lines ane from the bottom to the top!
	// 3. Points in the line are from the left to the right
	// 4. Bytes in one point are BGR (blue, green, red) not RGB
	// 5. Don't delete pBuffer, it will be automatically deleted 
	//    when delete hTargetBitmap

	//DeleteObject(hSourceBitmap);
	//DeleteObject(hTargetBitmap);
	return hTargetBitmap;



}
Mais voilà si le bitmap retourné à bien la bonne taille, il est tout noir !! (pixels = 0 je suppose) donc ma question est la suivante,
Ba pourquoi ???

Alors je sais que l'on est directx ici mais mois je suis avec des API windows de base pas de MFC, c'est une simple copie que je cherche a faire (pas de truc complexes non plus je develloppe sur un telephone portable !) et non il ne connait pas GetDIBits