Click here to Skip to main content
15,897,704 members

Comments by Lam Giang (Top 3 by date)

Lam Giang 5-Jun-12 23:52pm View    
Yes, it really helps.
Lam Giang 5-Jun-12 9:44am View    
This is the code snippet I tested
<pre lang="c++">

CImage img;
CImage sm_img;
img.Load(jpgFileName);

CDC *screenDC = GetDC();
CDC *pMDC = new CDC;
pMDC->CreateCompatibleDC(screenDC);

CBitmap *pb = new CBitmap;

int iNewWidth = 80;
int iNewHeight = 60;

pb->CreateCompatibleBitmap(pMDC, iNewWidth, iNewHeight);
//SetStretchBltMode(pMDC->m_hDC,COLORONCOLOR);
img.StretchBlt(pMDC->m_hDC,0, 0, iNewWidth, iNewHeight, SRCCOPY);


// The next two lines test the image on a picture control.
// The output has wrong color palette, like my initial version

HDC hdcpic = ::GetDC(m_ClipPreview.m_hWnd);
img.StretchBlt( hdcpic,0, 0, iNewWidth, iNewHeight, SRCCOPY);

CBitmap *pob = pMDC->SelectObject(pb);

// The next lines create a black image

sm_img.Attach((HBITMAP)(*pb));
sm_img.Save(sjpgFileName);
img.Detach();
ReleaseDC(screenDC);

</pre>

I am running VS2005 on Windows 7, screen resolution 1280x800, 32 color bit
Lam Giang 5-Jun-12 8:46am View    
In the first version, I got a bad image, but in the version using your solution
I've got a black one. Still do not understand