NULL

解决方案 »

  1.   

    如果你用gdiplus 那將是非常容易的事情。
    去看吧。
      

  2.   

    void ShowBMP(HWND hWnd, char *filename) //, TCHAR szFileName[MAX_PATH])
    {

    // TCHAR szHello[MAX_LOADSTRING];
    // LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
    // int height, width; PAINTSTRUCT ps;
    HDC hdc;
    // HWND hWnd = GetWindow(hWnd, NULL);
    hdc = BeginPaint(hWnd, &ps);
     // TODO: Add any drawing code here...
    RECT rt;
    GetClientRect(hWnd, &rt); long lStillWidth = rt.right - rt.left;
        long lStillHeight = rt.bottom - rt.top;
        BITMAPINFOHEADER* lpbi = new BITMAPINFOHEADER;
    BYTE* lpBuf = ReadBMP(lpbi, filename);
    lpbi = (BITMAPINFOHEADER*)lpBuf; int nW= lpbi->biWidth;
    int nH= lpbi->biHeight;
    BYTE* lpData=(BYTE*)lpBuf +  sizeof(BITMAPINFOHEADER);// - 10;// + sizeof(RGBQUAD);
    SetStretchBltMode(hdc, COLORONCOLOR);
    ::StretchDIBits(hdc,0,0,lStillWidth,lStillHeight,0,0,nW,nH,lpData,(BITMAPINFO*)lpbi,DIB_RGB_COLORS,SRCCOPY);// ::StretchDIBits(hdc,250,250,nW,nH,0,0,nW,nH,lpData,(BITMAPINFO*)lpbi, DIB_RGB_COLORS,SRCCOPY);// DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
    EndPaint(hWnd, &ps);
    }
      

  3.   

    void ShowBMP(HWND hWnd, char *filename) //, TCHAR szFileName[MAX_PATH])
    {

    // TCHAR szHello[MAX_LOADSTRING];
    // LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
    // int height, width; PAINTSTRUCT ps;
    HDC hdc;
    // HWND hWnd = GetWindow(hWnd, NULL);
    hdc = BeginPaint(hWnd, &ps);
     // TODO: Add any drawing code here...
    RECT rt;
    GetClientRect(hWnd, &rt); long lStillWidth = rt.right - rt.left;
        long lStillHeight = rt.bottom - rt.top;
        BITMAPINFOHEADER* lpbi = new BITMAPINFOHEADER;
    BYTE* lpBuf = ReadBMP(lpbi, filename);
    lpbi = (BITMAPINFOHEADER*)lpBuf; int nW= lpbi->biWidth;
    int nH= lpbi->biHeight;
    BYTE* lpData=(BYTE*)lpBuf +  sizeof(BITMAPINFOHEADER);// - 10;// + sizeof(RGBQUAD);
    SetStretchBltMode(hdc, COLORONCOLOR);
    ::StretchDIBits(hdc,0,0,lStillWidth,lStillHeight,0,0,nW,nH,lpData,(BITMAPINFO*)lpbi,DIB_RGB_COLORS,SRCCOPY);// ::StretchDIBits(hdc,250,250,nW,nH,0,0,nW,nH,lpData,(BITMAPINFO*)lpbi, DIB_RGB_COLORS,SRCCOPY);// DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
    EndPaint(hWnd, &ps);
    }