hi,all
In my EVC4 project, I need to show a 800*600 bmp picture to a window which
size is 80*50,
I do it in the window's paint function:

Paint(CDC& dc)
{
CDC memDC;
memDC.CreateCompatibleDC(&dc);
HBITMAP oldBmp = (HBITMAP)::SelectObject(memDC.m_hDC, m_hBitmap);//m_hBitmap
is the my bmp picture's handle

StretchBlt(dc.m_hDC,0, 0, 80, 50 ,
memDC.m_hDC, 0, 0, 800 , 600, SRCCOPY);

memDC.SelectObject(oldBmp);

//Copy the content from Memory DC to current DC
dc.BitBlt(0, 0, 80 , 50, &m_MemDC, 0, 0, SRCCOPY);
//here, the picture was showed. But the size is not exactly as 80*50, it is
about 90*40
}

Does anyone happend it before?
And also, in msdn, in stretchBlt(), it says "The only raster operations
Windows CE supports in the dwRop parameter are SRCCOPY and SRCINVERT. Windows
CE does not support mirroring.

" What does mirroring means?

Thanks

RE: How to use the StretchBlt to display bmp file as a size as I want? by Nicky

Nicky
Mon Oct 04 14:31:03 CDT 2004

There is something wrong in the code I pasted before.
Here is a test I wrote, still have the problem. I use the Imgdecmp.dll on CE.
void CTestDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
if(m_hBitmap == NULL)
return;

//Get the size of picture
BITMAP bmp;
memset(&bmp, 0, sizeof(bmp));
GetObject(m_hBitmap, sizeof(bmp), &bmp);
int m_nWidth = bmp.bmWidth;
int m_nHeight = bmp.bmHeight;// 800*600

//I will draw the picture on this area
CRect rect;
rect.top = 69;
rect.bottom = 242;
rect.left = 12;
rect.right = 230;//218*175

//Draw a frame
CPen pen, *pOldPen;
pen.CreatePen(PS_SOLID, 2, RGB(0, 255, 255));
pOldPen = dc.SelectObject(&pen);

dc.MoveTo(rect.left, rect.top);
dc.LineTo(rect.right, rect.top);
dc.LineTo(rect.right, rect.bottom);
dc.LineTo(rect.left, rect.bottom);
dc.LineTo(rect.left, rect.top);

dc.SelectObject(pOldPen);


CDC memDC;
memDC.CreateCompatibleDC(&dc);
HBITMAP oldBmp = (HBITMAP)::SelectObject(memDC.m_hDC, m_hBitmap);

StretchBlt(dc.m_hDC,
rect.left, rect.top, rect.Width(), rect.Height(),
memDC.m_hDC, 0, 0, m_nHeight, m_nWidth, SRCCOPY);
//Here, the displayed picture size is 218*134, why is not
218*175?

memDC.SelectObject(oldBmp);

// Do not call CDialog::OnPaint() for painting messages
}


"Nicky" wrote:

> hi,all
> In my EVC4 project, I need to show a 800*600 bmp picture to a window which
> size is 80*50,
> I do it in the window's paint function:
>
> Paint(CDC& dc)
> {
> CDC memDC;
> memDC.CreateCompatibleDC(&dc);
> HBITMAP oldBmp = (HBITMAP)::SelectObject(memDC.m_hDC, m_hBitmap);//m_hBitmap
> is the my bmp picture's handle
>
> StretchBlt(dc.m_hDC,0, 0, 80, 50 ,
> memDC.m_hDC, 0, 0, 800 , 600, SRCCOPY);
>
> memDC.SelectObject(oldBmp);
>
> //Copy the content from Memory DC to current DC
> dc.BitBlt(0, 0, 80 , 50, &m_MemDC, 0, 0, SRCCOPY);
> //here, the picture was showed. But the size is not exactly as 80*50, it is
> about 90*40
> }
>
> Does anyone happend it before?
> And also, in msdn, in stretchBlt(), it says "The only raster operations
> Windows CE supports in the dwRop parameter are SRCCOPY and SRCINVERT. Windows
> CE does not support mirroring.
>
> " What does mirroring means?
>
> Thanks

Re: How to use the StretchBlt to display bmp file as a size as I want? by The

The
Thu Oct 07 15:57:09 CDT 2004

> > " What does mirroring means?

means displaying a "mirrored" image. i.e. horizontal mirror means the right
edge is displayed on the left and vice versa. vertical mirror means the top
is displayed at the bottom and vice versa.