Centralize the bitmap location

Expert

I want to show a bitmap to screen. Its size is much larger than the screen size.

if i have the coordinates of some interest regions let say(x1,y1),(x2,y2)..................

Are there any easy way to centralize the coordinate of the interest region on the screen (i show the image in actual size, those region out of the screen size will not be showed) and show the interest region one by one.


Many thanks
LVL 3
smalleeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Amritpal SinghCommented:
if i got u right then this link may be of any help

http://www.codeproject.com/miscctrl/wndimg.asp
0
Amritpal SinghCommented:
0
RuskialtCommented:
As far as I remember, the CDC::StretchBlt() function can copy interesting parts of your image to the screen (it will stretch the interesting part of an image to fit the screen, if you use it correctly). It takes both source coordinates, and destination coordinates. That is "from where, to where" do we need to copy the pixels. So get the coordinates of the "rectangle of interest" in your image, then stretch blit this section to the client area of the window.

For now, try to read the StretchBlt() documentation, and see if it's something you can use?

Do you need to zoom too, or is pan sufficient for you?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

smalleeAuthor Commented:
Ruskialt

I knew how to use StretchBlt to display my interest region

But i have a problem. i use OnDraw to print the bitmap to screen. After it was printed on the screen. I use OnFocus to reprint the interest region. But the new printed region just covered on the old print region.  The old print region was still  at here.

Any step i am missing?

void CMFCView::OnDraw(CDC* pDC)
{
...
...
pDC->StretchBlt(0, 0, iClientWidth, iClientHeight, &dcMemory, 0, 0, iBpWidth, iBpHeight, SRCCOPY);
}

void CMFCView::OnFocus()
{
...
...
CDC* pDC
pDC = this->GetDC();
pDC->StretchBlt(0, 0, iClientWidth, iClientHeight, &dcMemory, iRegionX, iRegionY, 240, 320, SRCCOPY);
}
0
RuskialtCommented:
I'm not sure if I understand your problem.. Dont draw anything like this in OnFocus(), call Invalidate() from OnLButtonDown() instead to have OnDraw() called again. Please explain again, what yo want to do..??
0
smalleeAuthor Commented:
Ruskialt

Actually, i am writting a image browser in pocket pc.

what i want to do
1) Display the image in fit screen scale first.
2) Press a button to calculate the interest region ( return a interest coordinate)
3) then i want to display the specific region based on this interest coordinate.   (my question)

i am wondering whether i should use stretchBlt to display the image again or any other method can do that?

Many thanks!
0
RuskialtCommented:
So you want to zoom to a particular place in the image?

As my previous post suggests:

Handle OnLButtonDown(), and from here save the mouse coordinate and call Invalidate(). This will lead to a new call to OnDraw(). In OnDraw() draw the image zoomed. You probably want your view to hold information on zoom factor and position of "current view". In your OnLButtonDown() update those parameters, so that next OnDraw() will zoom to the correct place..

Any of this making sence to you?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.