View Full Version : I want to save a image (BMP, JPG, ...) from the OpenGL view
05-15-2001, 10:09 PM
I want to save a image (BMP, JPG, ...) from the OpenGL view, but I want to select a size of this image. For example, the size of a view is a 800x600 and i want that the size of image file (BMP, JPG) is of 2000x1000.
With glReadPixels only can save a image file with the same size as the view.
05-15-2001, 10:46 PM
I think, that OpenGL doesn't support resizing. In order to resize your picture, you have to write a piece of code by yourself. Maybe there is any solution?
05-15-2001, 11:40 PM
Although this question is not related to OpenGL, here are some hints how to do it:
(I assume that you are using win32)
1. Get the bitmap from the ogl view in what size is available
2. Create compatible dc contex with the API function CreateCompatibleDC() (we will call it sourceDC)
3. Bind a bitmap to the sourceDc (source Bitmap) with the size of the Ogl view( use API CreateCompatibleBitmap() function) Lets call it sourceBmp
4. Copy the the ogl bitmap to this bitmap -
(you may use SetPixel for example, if you dont want to use direct memory access to the bitmap)
5. Create again compabtible DC contex - use again CreateCompatibleDC() (destDc)
6. Create compatible bitmap using API function CreateComaptibleBitmap - bind it to the dc created above and select the desired size (destBmp)
7. Use the function StrechBlt to copy the bitmap from the sourceDc to the destDc - in destBmp you will have now the bitmap with the desired size.
So this is maybe the slowest way to do it, it is also OS dependent, but it is easy to implement, since I assume that you are unable to make the strech by yourself...
Hope this helps
u could use the gluScaleImage(..) function
just hand it your readpixels data and it'll spit out the resized image
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.