Advertisement

01.28.2005 at 02:33AM PST, ID: 21292287
[x]
Attachment Details

Using StretchBlt to reduce a bitmap size by 50%

Asked by oliverUK in Microsoft Visual C++.Net

Tags: stretchblt, bitmap

I want to view a loaded 8bit bitmap on the screen.  

I want to shrink the bitmap by 50%

Using the StretchBlt (in code below) I specify the bitmap height and width of the destination to be 1/2 that of the source.

The bitmap is drawn however the quality is reduced why? How can I retain the quality to the naked eye?



void CImageDialog::ShowBitmap(CPaintDC* pdc)
{
      CDemoDlg * pWnd = (CDemoDlg*)GetParent();
      BITMAP bm;
      CDC dcMem;
      CRect rRect;


      pWnd->m_bmpBitmap.GetBitmap(&bm);
      dcMem.CreateCompatibleDC(pdc);
      dcMem.SelectObject(pWnd->m_bmpBitmap);
      
      GetClientRect(rRect);
      rRect.NormalizeRect();
      
      
      pdc->StretchBlt(0,0,bm.bmWidth/2,bm.bmHeight/2,&dcMem,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
      }Start Free Trial
 
Loading Advertisement...
 
[+][-]01.28.2005 at 04:31AM PST, ID: 13162509

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.28.2005 at 04:32AM PST, ID: 13162511

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual C++.Net
Tags: stretchblt, bitmap
Sign Up Now!
Solution Provided By: AlexFM
Participating Experts: 3
Solution Grade: A
 
 
[+][-]01.28.2005 at 07:20AM PST, ID: 13163886

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32