PDA

View Full Version : Image scale with OpenGL



zhigang.yao
07-10-2005, 08:39 PM
In a real-time image system, To scale image cost lots of CPU circles, for every image frame, a resample process needed.

So , my question is:
could the image-scale done by GPU, if so , please show a little bit guides on how to do it with openGL?

Image scale:
To resize a picture or image from original size to another size without obvious information lost. when we ajust the replayer/window-media-player 's window size, we do a image scale.

T101
07-10-2005, 11:08 PM
It all depends on what you want to do with it.

If all you're interested in is displaying a (relatively static) picture, you only need to render one textured quad:

1. Upload texture, specify minification/magnification options (texture filtering) - you'll probably want to use GL_LINEAR.

2. When refreshing the screen, render a textured quad.

If you want to retrieve the results, you can use glReadPixels, but it's a slow operation.

If you want to get more advanced filtering (more advanced than simple linear interpolation), you might be able to use a fragment program for it, but it's more complex to get that to work.

zhigang.yao
07-11-2005, 04:44 PM
Thanks.

In fact, I want to scale an real-time video image(25Frames/second), so I need so fast scale operation. could texture quad work?

Thanks again.

T101
07-11-2005, 11:25 PM
In principle: yes. One textured quad won't be a problem at all.

But it all depends on how fast textures can be read in and uploaded to the card.
You'll probably not want to create mipmaps, since those cost performance to create.

zhigang.yao
07-11-2005, 11:41 PM
Thanks T101,

I have tried , create and read a 1024*512 2D_texture cost 5ms on my PC.

But I dont know how to scale the 2D_texture and dispaly it on the screen.

hope for your guide.

T101
07-11-2005, 11:56 PM
http://www.rush3d.com/reference/opengl-redbook-1.1/chapter09.html