Bonjour,
J'ai un nouveau problème sur l'impression d'un Bitamp ...
ça coince toujours au niveau du GetDIBits() et je ne m'en sors pas !
Je me retrouve avec un petit carré noir sur l'imprimante ... Normal tant que je n'aurais pas les Bits de couleurs ...

Voilà la procedure :
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
                      memset(&pd,0,sizeof(PRINTDLG));
				      pd.lStructSize = sizeof(pd);
				      pd.hwndOwner = hwnd;
				      pd.Flags = PD_RETURNDC | PD_PRINTSETUP;
                      if(PrintDlg(&pd))  {
                        memset( &di, 0, sizeof(DOCINFO) );
                        di.cbSize = sizeof(DOCINFO); 
                        di.lpszDocName = "Bitmap Printing Test"; 
                        di.lpszOutput = (LPTSTR) NULL; 
                        di.lpszDatatype = (LPTSTR) NULL; 
                        di.fwType = 0; 
                        hbmp = LoadImage(hInst,szFileBmp, 0,0,0, LR_LOADFROMFILE);
                        lpbmi=CreateBitmapInfoStruct(hwnd, hbmp);
                        pbih = (PBITMAPINFOHEADER) lpbmi;
                        lpBits = (LPBYTE)GlobalAlloc(GMEM_FIXED,pbih->biSizeImage);

                        if (!GetDIBits(pd.hDC, hbmp, 0, (WORD) pbih->biHeight, lpBits, lpbmi, DIB_RGB_COLORS))
                            MessageBox( NULL, "erreur GetDIBits", "Error", MB_OK | MB_ICONINFORMATION );

                        if(StartDoc(pd.hDC,&di) > 0) {
                          if(StartPage(pd.hDC) > 0) {
                            if (pbih->biClrUsed)
	            	          NumColors = (UINT)pbih->biClrUsed;
	                        else {
					          switch(pbih->biBitCount)
							  {
						        case 1:
						          NumColors = 2;
						          break;
                                case 2:
						          NumColors = 4;
						          break;
						        case 4:
						          NumColors = 16;
						          break;
						        case 8:
						          NumColors = 256;
						          break;
						        default:
						          NumColors = 0;
						          break;
							  }
							}
                            nBytesLine = (UINT)((((pbih->biWidth * pbih->biBitCount) + 31) >> 5) << 2);
						    if(pbih->biXPelsPerMeter == 0)
						      pbih->biXPelsPerMeter = (GetDeviceCaps(pd.hDC,HORZRES) * 1000L) / GetDeviceCaps(pd.hDC,HORZSIZE);
						    scale = (GetDeviceCaps(pd.hDC,HORZRES) * 100000L) / (GetDeviceCaps(pd.hDC,HORZSIZE) * pbih->biXPelsPerMeter);
						    nLines = (0x400000L / (scale * nBytesLine)) * scale;
                            x = Disk.left/10;
						    y = Disk.top/10;
						    bmp.left = (int)((x * GetDeviceCaps(pd.hDC,HORZRES)) / (GetDeviceCaps(pd.hDC,HORZSIZE) * 10));
                            bmp.left = bmp.left - GetDeviceCaps(pd.hDC,PHYSICALOFFSETX);
						    bmp.top = (int)((y * GetDeviceCaps(pd.hDC,VERTRES)) / (GetDeviceCaps(pd.hDC,VERTSIZE) * 10));
                            bmp.top = bmp.top - GetDeviceCaps(pd.hDC,PHYSICALOFFSETY);
						    bmp.right = bmp.left + (UINT)((pbih->biWidth * scale) / 100);
						    bmp.bottom = bmp.top + (UINT)((pbih->biHeight * scale) / 100);

                            StretchDIBits(pd.hDC, bmp.left, bmp.top, bmp.right - bmp.left,bmp.bottom - bmp.top,
									              0,0,(UINT)pbih->biWidth,(UINT)pbih->biHeight,lpBits, lpbmi, DIB_RGB_COLORS,SRCCOPY);
							GlobalFree((HGLOBAL)lpBits);
                            EndPage(pd.hDC); 
						  }
						}
                        EndDoc(pd.hDC);
					  }
                      return 0 ;
Une idée ?
merci d'avance