Saving OpenGL output as Fixed Dimension JPG

Hi there,
I am rendering some objects as a scene. After i am done displaying it i want to save it as JPEG file.
I am able to save it to JPEG file by reading pixels by using glReadPixels() method.
Considering i know the bounding rectangle of my object being displayed, now i want to save the JPG file as fixed dimension ( M X N) where M and N will be constant and also i want my object to cover large area with some frame on it.
for example:-
If I want image of dimension 20002000 and my object bounding rectangle is 700550 then i want to scale that to 1800*1800 and remaining outer pixels as the border of image.

How can i achieve this?

thank you

What makes you think that JPEG has something to do with OpenGL?
You obviously have to find an appropiate library that can help you with this.

yes… openGL doesn’t do that. But i was thinking of using FBO and scale the content of it and then save it. But i am not sure if FBO is the right choice or not or if this is the right way to go ?

let me know your thoughts.

You can render to a FBO with the dimensions that you desire.
You could of course use texture filtering to do your scaling, but that would be of a low quality and messy.

The best way to do this is to use a dedicated scaling functionality of an image library.

Another option might be to just use gluScaleImage on the data that you’ve captured via glReadPixels.

hi guys,

thanks for all the suggestions…
i tried using gluScaleImage and it works fine but again it is dependent on the size of window as i will be taking pixels from glReadPixels() so this approach seems to be temporary solution to my problem.

I think i need to use FBO. Can anyone point me to right direction or simple example on how do i use FBO and how to do scaling using it?

thank you so much for your help.