Image Resize???

Started by
3 comments, last by SakirSoft 16 years, 9 months ago
Anyone know of an easy way to resize an Image in c++ and win32? The image will be a 24bit .tga. If it matters Ill be using opengl Thanks
Advertisement
Apart from using either a library or using your own code, I don't see any way to resize an image.

Library you can use:
ImageMagick (OSS)
Intel Intergrated Performance Primitives (IPP) (200$, but damn fast on intel processors, and contains many other things)

There are tons of other possibilities - I just let you google to find some.

If you want to implement the magnification algorithm by yourself, Aramini's paper is what you search (cubic splines resampling). It's quite easy to implement - it might take some time to get something fast, but that's definitely possible. I implemented it 7 years ago, and the final implementation was nearly as fast as what Intel was doing - and that was without using any kind of SIMD code.
There's also GDI+, which comes with Windows XP and later, and is available as a redistributable for Win98 and later. It's not hard to resize an image with the Bitmap class. There's an example of scaling in the API documentation.

On the other hand, if you're using OpenGL, then usually you don't need to scale images independently.
There's a resize implementation in my Bitmap class. It doesn't do cubic spline resampling and it's not that fast. Having said that it does work well and should be easy enough to understand.
http://www.dhpoware.com
Quote:Original post by hahaha
Anyone know of an easy way to resize an Image in c++ and win32? The image will be a 24bit .tga. If it matters Ill be using opengl

Thanks



Do you want to resize the image on the fly ?
If so you can use OpenGl for it.
Load you tga file as an OpenGL texture.
Setup a quad of your desired image dimension and bind your loaded texture.


your code should look like this.


glBindTexture(GL_TEXTURE_2D, tex);
glBegin(GL_TRIANGLE_STRIP);


glTexCoord2f(0,0); //Left upper corner of your texture
glVertex2f (x, y); //x and y are the begining coords of your quad

glTexCoord2f(1,0); //Right upper corner of your texture
glVertex2f (x + w, y); //w is the width of your texture

glTexCoord2f(0,1); //Left down corner of your texture
glVertex2f (x , y + h); //h is the Highth of your texture

glTexCoord2f(1,1); //Right down corner of your texture
glVertex2f (x+w , y + h);


glEnd ();

This topic is closed to new replies.

Advertisement