Jump to content
  • Advertisement
Sign in to follow this  
mark-w

scaling image

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I've created a small app to display 2d images. So far I have panning the image around the screen supported. I also have scaling the image from its center point supported too. Instead of simply scaling the image from its center point wherever it happens to lie in space, I would like to achieve the effect of scaling looking like I'm actually moving the 'camera' into the viewport. I thought I could achieve this by introducing a fudged pan offset in the x/y directions, so that when you're zooming in, the image is shifted in the x/y directions to look like you're really zooming in, not just scaling the image from its center point. Opengl does this beautifully, however I cannot use opengl, any ideas? Thanks

Share this post


Link to post
Share on other sites
Advertisement
maybe its just me, but im not sure what you mean by scaling from the center point or any other point. Scaling is normally defined simply by a scalar, not a scalar and a point.

Maybe you could explain or give some screen shots of what you want from each...

Share this post


Link to post
Share on other sites
Hi Dwiel,

First thanks for the response. I took some screen shots about what I'm talking about. The screen shots are really small, like 2k each.

The first screen shot shows the 2D viewport I set up. The red cross hair is the origin of my viewport. The yellow wireframe quad is the image. Its center point is green.

first one

Now the next screen shot shows that if I scale the quad, it gets scaled about its center point, which happens to be the viewport centerpoint as well here.

second one

Now if I had first translated the quad up to the left a bit...

third one

And now I scale, you can see its just simply scaling still around the quad center point.

fourth one

I would like instead to introduce some pan offset to make it appear as if I'm not really just scaling the quad, but moving into the viewport. So in this last screen shot, the quad should have perfectly increased along the two axes instead, since the camera movement should really just be zooming into the center point of the viewport.

fifth one

[Edited by - mark-w on September 8, 2005 11:45:41 PM]

Share this post


Link to post
Share on other sites
You have to scale the translation as well.. so if you have panned with (10,10) and after that you scale by 2 then your new panning is (20,20).

Share this post


Link to post
Share on other sites
Ok Winograd you got me the rest of the way. Scaling the transform was the key to getting the illusion down. I actually ended up *not* scaling the transform, but keeping two additional variables that would act as the difference between unscaled and scaled transforms, then added this onto the unaltered transform. Scaling the transform directly resulted in a snowball effect of rounding errors. This way when I scale up and down I always get back to the starting point from which I started the scale.

Thanks everyone, it looks awesome!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!