C++中怎么把位图输出到窗口
展开全部
#include <windows.h>
int PaintBitmap (HWND hwnd ,HBITMAP hBitmap)
{
RECT rect ;
BITMAP bitmap ;
HDC hdcSrc = GetDC (hwnd) ;
HDC hdcBmp = CreateCompatibleDC (hdcSrc) ;
SelectObiect (hdcBmp ,hBitmap) ;
GetClientRect (hwnd ,&rect) ;
GetObject (hBitmap ,sizeof (BITMAP) ,bitmap) ;
Stretchblt (hdcSrc ,0 ,0 ,rect.right - rect.left ,rect.bottom - rect.top ,hdcBmp ,0 ,0 ,bitmap.bmWight ,bitmap.bmHeight) ;
DeleteDC (hdcBmp) ;
ReleaseDC (hwnd ,hdcSrc) ;
return 0 ;
}
/*
不懂追问
*/
int PaintBitmap (HWND hwnd ,HBITMAP hBitmap)
{
RECT rect ;
BITMAP bitmap ;
HDC hdcSrc = GetDC (hwnd) ;
HDC hdcBmp = CreateCompatibleDC (hdcSrc) ;
SelectObiect (hdcBmp ,hBitmap) ;
GetClientRect (hwnd ,&rect) ;
GetObject (hBitmap ,sizeof (BITMAP) ,bitmap) ;
Stretchblt (hdcSrc ,0 ,0 ,rect.right - rect.left ,rect.bottom - rect.top ,hdcBmp ,0 ,0 ,bitmap.bmWight ,bitmap.bmHeight) ;
DeleteDC (hdcBmp) ;
ReleaseDC (hwnd ,hdcSrc) ;
return 0 ;
}
/*
不懂追问
*/
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询