Stretch bitmap 
Author Message
 Stretch bitmap

I have a bug in this code, but I can't find it. I need to stretch a bitmap
to a small version. But in the picture control I don't see anything. Can
someone tell me what is wrong.

Tanks!

Sorry for my english, i'm not very good! :-(

void CBitmapDlg::AddBitmap(HBITMAP hBitmap, BITMAPINFO BitmapInfo)
{
 CBitmap* pbmpBigBitmap;
 CBitmap bmpSmallBitmap;
 CBitmap* pbmpOldBitmap1;
 CBitmap* pbmpOldBitmap2;
 CDC dcMem1;
 CDC dcMem2;

 dcMem1.CreateCompatibleDC(NULL);
 pbmpBigBitmap = CBitmap::FromHandle(hBitmap);
 pbmpOldBitmap1 = dcMem1.SelectObject(pbmpBigBitmap);

 dcMem2.CreateCompatibleDC(NULL);
 bmpSmallBitmap.CreateCompatibleBitmap(&dcMem2, 100, 100);
 pbmpOldBitmap2 = dcMem2.SelectObject(&bmpSmallBitmap);

// Stretch Bitmap
 BOOL bRet= dcMem2.StretchBlt(0,0,
  100, 100,
  &dcMem1,0,0,
  BitmapInfo.bmiHeader.biWidth,
  BitmapInfo.bmiHeader.biHeight,
  SRCCOPY);

 // Cleaning up
 dcMem1.SelectObject(pbmpOldBitmap1);
 dcMem1.DeleteDC();
 dcMem2.SelectObject(pbmpOldBitmap2);
 dcMem2.DeleteDC();

// Picture control
 m_CImage.SetBitmap((HBITMAP)bmpSmallBitmap.GetSafeHandle());
 m_CImage.RedrawWindow();

Quote:
}



Fri, 05 Mar 2004 23:47:33 GMT  
 Stretch bitmap
Martin!

Many of us are not native English speakers, be satisfied if you manage your
own :-)
As for your problem, perhaps the fact that you use a local variable for the
bitmap gives you trouble? Try to make it a member of the class instead.

Johan Rosengren


Quote:
> I have a bug in this code, but I can't find it. I need to stretch a bitmap
> to a small version. But in the picture control I don't see anything. Can
> someone tell me what is wrong.

> Tanks!

> Sorry for my english, i'm not very good! :-(

> void CBitmapDlg::AddBitmap(HBITMAP hBitmap, BITMAPINFO BitmapInfo)
> {
>  CBitmap* pbmpBigBitmap;
>  CBitmap bmpSmallBitmap;
>  CBitmap* pbmpOldBitmap1;
>  CBitmap* pbmpOldBitmap2;
>  CDC dcMem1;
>  CDC dcMem2;

>  dcMem1.CreateCompatibleDC(NULL);
>  pbmpBigBitmap = CBitmap::FromHandle(hBitmap);
>  pbmpOldBitmap1 = dcMem1.SelectObject(pbmpBigBitmap);

>  dcMem2.CreateCompatibleDC(NULL);
>  bmpSmallBitmap.CreateCompatibleBitmap(&dcMem2, 100, 100);
>  pbmpOldBitmap2 = dcMem2.SelectObject(&bmpSmallBitmap);

> // Stretch Bitmap
>  BOOL bRet= dcMem2.StretchBlt(0,0,
>   100, 100,
>   &dcMem1,0,0,
>   BitmapInfo.bmiHeader.biWidth,
>   BitmapInfo.bmiHeader.biHeight,
>   SRCCOPY);

>  // Cleaning up
>  dcMem1.SelectObject(pbmpOldBitmap1);
>  dcMem1.DeleteDC();
>  dcMem2.SelectObject(pbmpOldBitmap2);
>  dcMem2.DeleteDC();

> // Picture control
>  m_CImage.SetBitmap((HBITMAP)bmpSmallBitmap.GetSafeHandle());
>  m_CImage.RedrawWindow();
> }



Sat, 06 Mar 2004 11:56:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. stretch bitmap

2. Stretch bitmap

3. added lines are too fat when Stretching Bitmap in memory DC

4. How can I have a CFormView with background bitmap (tile or stretch)

5. How to stretch a bitmap for CImageList::Add()?

6. Stretch a bitmap

7. Stretch Blt Bitmap

8. stretching a bitmap to print

9. Prining a Bitmap Stretches it

10. Stretch a loaded bitmap ?

11. bitmap, bitmap, bitmap

12. stretching getopt

 

 
Powered by phpBB® Forum Software