Log in

View Full Version : ZOOM option in VisualC++ (MFC)


Episodio1
21st April 2009, 15:22
Hi!

Im new with VC++ and I'm developing with .NET compact (PDA/mobiles) and I'd like to know how can I add a zoom option when I load an image.

This is my current code to show image:


CBitmap *bk,*old;
HBITMAP a;
DWORD d;
a=::SHLoadImageFile(_T("c:\\a.png")); // LoadImage() doesnt work in WinCE.

bk=CBitmap::FromHandle (a);
CRect rec;
CDC Mem;
Mem.CreateCompatibleDC(&dc);

old=Mem.SelectObject(bk);

BITMAP bmpInfo;
bk->GetBitmap(&bmpInfo);

this->GetClientRect(rec);
dc.StretchBlt(0,0,rec.right,rec.bottom,&Mem,0,0,bmpInfo.bmWidth,bmpInfo.bmHeight ,SRCCOPY);

Mem.SelectObject(old);

Nic
28th April 2009, 08:20
When you zoom can't you re-do the stretch blit but make your source rectangle a smaller sub-section of the source image? Or is that too slow for your needs on a CE device?

-Nic

Episodio1
28th April 2009, 20:10
No, it's OK.

I've been learning a bit more about graphics since then, and I've zoomed playing with "strechblt" command, but there are no scrollbars to move all over the image when I have zoomed-in.

Or what are the commands to handle events from touchscreen, so I can zoom-in exactly where user wants.