difference between CPaintDC and CClientDC

difference between CPaintDC and CClientDC:i am using MFC for this application
when i am using CClientDC pdc(this),i am able get my image (video)fully (SIF)
but when i use CCpaintDC pdc(this);i am getting the image size less than SIF.
also in the first case m getting some garbage data also at right end along wid image.
#define RESW 384
#define RESH 240

#define STWID 140
#define STHT 50

int m_nStretchWidth = 0;
int m_nStretchHeight = 0;

UCHAR* thisImage = (UCHAR*) video_outbuf1;

CRgn updatergn;
updatergn.CreateRectRgn(0, 0, 320+STWID, 240+STHT);
InvalidateRgn(&updatergn, FALSE);

try
{
m_oImageInfo = new BITMAPINFO;

m_oImageInfo->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
m_oImageInfo->bmiHeader.biWidth = RESW;
m_oImageInfo->bmiHeader.biHeight = -RESH;
m_oImageInfo->bmiHeader.biPlanes = 1;
m_oImageInfo->bmiHeader.biBitCount = 24;
m_oImageInfo->bmiHeader.biCompression = BI_RGB;
m_oImageInfo->bmiHeader.biSizeImage = RESW* RESH* 3;//0;
//m_oImageInfo->bmiHeader.biXPelsPerMeter = 0;
//m_oImageInfo->bmiHeader.biYPelsPerMeter = 0;
//m_oImageInfo->bmiHeader.biClrUsed = 0;
//m_oImageInfo->bmiHeader.biClrImportant = 0;

LPBITMAPINFO poImageInfo = (LPBITMAPINFO)m_oImageInfo;

CClientDC pdc(this);//CPaintDC pdc(this)

if ((poImageInfo != NULL) && (thisImage != NULL))
{
int nHorz = poImageInfo->bmiHeader.biHeight;
int nVert = poImageInfo->bmiHeader.biWidth;
if( nHorz == 240 && nVert == 640 )
{
m_nStretchWidth = 640;
m_nStretchHeight = 480;
}
else if( nHorz == 288 && nVert == 704 )
{
m_nStretchWidth = 768;
m_nStretchHeight = 576;
}
else
{
m_nStretchWidth = poImageInfo->bmiHeader.biWidth;
m_nStretchHeight = poImageInfo->bmiHeader.biHeight;
}


SetStretchBltMode(pdc.m_hDC,3);

if(pdc && pdc.m_hDC)
{
int rc = ::StretchDIBits(pdc.m_hDC,
STWID,
STHT, //poImageInfo->bmiHeader.biHeight,
m_nStretchWidth, //poImageInfo->bmiHeader.biWidth,
-m_nStretchHeight, //-poImageInfo->bmiHeader.biHeight,
0,
0,
poImageInfo->bmiHeader.biWidth,
-poImageInfo->bmiHeader.biHeight,
thisImage,
poImageInfo,
DIB_RGB_COLORS,
SRCCOPY);

}

}
}
catch(...)
{
AfxMessageBox("Exception in CTestDlg::OnRenderMessage");
}


delete(m_oImageInfo);
Last edited on
Topic archived. No new replies allowed.