用到GetDIBits出问题了
void StretchDesktop(HWND hMyWnd,HINSTANCE hInstance)
{
HDC hMyDC;
HDC hMemDC;
HBITMAP hBmp;
BITMAPINFO bmpInfo;
TCHAR *lpBuf;
HANDLE hp;
hMyDC=GetDC(hMyWnd);
hMemDC=CreateCompatibleDC(hMyDC);
hBmp=(HBITMAP)LoadImage(hInstance,_T("abc.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
SelectObject(hMemDC,hBmp);
BitBlt(hMyDC,0,0,300,225,hMemDC,0,0,SRCCOPY);
bmpInfo.bmiColors[0].rgbRed=8;
bmpInfo.bmiColors[0].rgbGreen=8;
bmpInfo.bmiColors[0].rgbBlue=8;
bmpInfo.bmiColors[0].rgbReserved=0;
bmpInfo.bmiHeader.biBitCount=24;
bmpInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biClrImportant=0;
bmpInfo.bmiHeader.biClrUsed=0;
bmpInfo.bmiHeader.biCompression=BI_RGB;
bmpInfo.bmiHeader.biHeight=225;
bmpInfo.bmiHeader.biWidth=300;
bmpInfo.bmiHeader.biPlanes=1;
bmpInfo.bmiHeader.biSizeImage=0;
bmpInfo.bmiHeader.biXPelsPerMeter=0;
bmpInfo.bmiHeader.biYPelsPerMeter=0;
hp=GetProcessHeap();
lpBuf=(TCHAR *)HeapAlloc(hp,HEAP_ZERO_MEMORY,225*300*3);
if(GetDIBits(hMemDC,hBmp,0,225,lpBuf,&bmpInfo,DIB_RGB_COLORS))
MessageBox(NULL,_T("GetDIBits失败"),_T(""),MB_OK);
if(lpBuf==NULL)
MessageBox(NULL,_T("lpBuf填充失败"),_T(""),MB_OK);
TextOut(hMyDC,0,0,lpBuf,lstrlen(lpBuf));
//GetDIBits(hMemDC,hBmp,0,
DeleteObject(hBmp);
ReleaseDC(hMyWnd,hMyDC);
HeapFree(hp,0,lpBuf);
}
结果GetDIBits成功,lpBuf填充也成功,TextOut的时候却没有输出,什么问题呢?大家看看