[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Centralize the bitmap location

Posted on 2004-11-28
7
Medium Priority
?
269 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:smallee
  • 3
  • 2
  • 2
7 Comments
 
LVL 6

Expert Comment

by:Amritpal Singh
ID: 12693594
if i got u right then this link may be of any help

http://www.codeproject.com/miscctrl/wndimg.asp
0
 
LVL 6

Expert Comment

by:Amritpal Singh
ID: 12693623
0
 
LVL 2

Accepted Solution

by:
Ruskialt earned 1200 total points
ID: 12695274
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:smallee
ID: 12717701
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
 
LVL 2

Expert Comment

by:Ruskialt
ID: 12719588
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
 
LVL 3

Author Comment

by:smallee
ID: 12719682
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
 
LVL 2

Expert Comment

by:Ruskialt
ID: 12723626
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month19 days, 14 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question