# The Industry's Foundation for High Performance Graphics

1. ## scale an image

Hello people, I need help to get an algoritm which can to calculate the scale, to scale an image,this algoritm must have a progressive behavior.
I have four points( it's the image corners) and I want to scale the image without change the center. I put above a piece of code. I'm doing this in loop,
passing a point of every time.The big problem that I have it is in scale calculation . Maybe with a logarithm it´s possible to do it,but I don't know how to do.And after the scaling I have to had the new image coordinates.
If someone can help me, I will be grateful.
thanks.

bool mainScaleOverlay (double scale,const PointR2& centerOrig,const PointR2& pointOrig,PointR2& pointNew)
{
pointNew.x = (pointOrig.x - centerOrig.x) * scale + centerOrig.x;

pointNew.y = (pointOrig.y - centerOrig.y) * scale + centerOrig.y;

return true;
}

2. ## Re: scale an image

Sorry, OpenGL does not have support for that.

Mikael

3. ## Re: scale an image

I don't seem to get the idea, what ar you trying to do. Could you give more detail?

Anyway I'll try to share my thoughts.

You have an image center, and four points representing four image corners. You need to scale the image and to maintain its current center.

Is this image a square?

This is what I would do.

I would use vectors. The image center is (0; 0). The the four points are:
A(-5; 2)
B( 5; 2)
C( 5;-2)
D(-5;-2)
And you have a scalar, which is the scale factor. s=3
The new point coordinates will be.
A(-15; 6)
B( 15; 6)
C( 15;-6)
D(-15;-6)
And that's it. The image center stays at 0;0

What do you think?

polyethylene

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•