Bitblit with WTL
-
Hi, I can't get bitblit to work with WTL. It keeps printing a black square. But the size of the square is equal to the size of the image it should print so i think i'm forgetting something. I'm converting my Win32/SDK app to WTL and in Win32/SDK it works. This is the code i'm using:
//to load: CBitmap Image; Image.LoadBitmap(238); //to paint: CPaintDC dc(m_hWnd); CDC hdc; hdc.CreateCompatibleDC(dc.m_hDC); BITMAP Temp; Image.GetBitmap(&Temp); SelectObject(hdc.m_hDC,&Temp); dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0);
I tried making a filledrect with the same DC object and it worked. Thanks for all help. -
Hi, I can't get bitblit to work with WTL. It keeps printing a black square. But the size of the square is equal to the size of the image it should print so i think i'm forgetting something. I'm converting my Win32/SDK app to WTL and in Win32/SDK it works. This is the code i'm using:
//to load: CBitmap Image; Image.LoadBitmap(238); //to paint: CPaintDC dc(m_hWnd); CDC hdc; hdc.CreateCompatibleDC(dc.m_hDC); BITMAP Temp; Image.GetBitmap(&Temp); SelectObject(hdc.m_hDC,&Temp); dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0);
I tried making a filledrect with the same DC object and it worked. Thanks for all help. -
Hi, I can't get bitblit to work with WTL. It keeps printing a black square. But the size of the square is equal to the size of the image it should print so i think i'm forgetting something. I'm converting my Win32/SDK app to WTL and in Win32/SDK it works. This is the code i'm using:
//to load: CBitmap Image; Image.LoadBitmap(238); //to paint: CPaintDC dc(m_hWnd); CDC hdc; hdc.CreateCompatibleDC(dc.m_hDC); BITMAP Temp; Image.GetBitmap(&Temp); SelectObject(hdc.m_hDC,&Temp); dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0);
I tried making a filledrect with the same DC object and it worked. Thanks for all help.Try replacing: Tommy2k wrote: BITMAP Temp; Image.GetBitmap(&Temp); SelectObject(hdc.m_hDC,&Temp); dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0); with something like:
HBITMAP hOldBitmap = hdc.SelectBitmap ( (HBITMAP) Image );
SIZE dim;
Image.GetBitmapDimension ( &dim );
dc.BitBlt ( 50, 50, dim.cx, dim.cy, (HDC) hdc, 0, 0, SRCCOPY );
dcBW.SelectBitmap ( hOldBitmap );cheers, -B
-
Try replacing: Tommy2k wrote: BITMAP Temp; Image.GetBitmap(&Temp); SelectObject(hdc.m_hDC,&Temp); dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0); with something like:
HBITMAP hOldBitmap = hdc.SelectBitmap ( (HBITMAP) Image );
SIZE dim;
Image.GetBitmapDimension ( &dim );
dc.BitBlt ( 50, 50, dim.cx, dim.cy, (HDC) hdc, 0, 0, SRCCOPY );
dcBW.SelectBitmap ( hOldBitmap );cheers, -B