PDA

View Full Version : change a picture's size



randychou
07-20-2002, 08:18 AM
i want to change a picture from 1024x768 to 800x600 and save it to disk, can anyone tell me how to do it in vc++?
thanks a lot!

hkyProgrammer88
07-20-2002, 06:48 PM
What do you mean exactly? Is your picture already stored in an array of size 1024x768?

Anyway, you have choice, since 800x600 is a smaller resolution you will have to drop out some pixels from your image or you'll want to combine some pixels together (smooth or soften image).

If you give more detail then I may be able to help. Also, how does OpenGL fit in to this (are you trying to capture a 1024x768 screen shot and reduce it to 800x600)?

randychou
07-21-2002, 01:18 AM
i want to draw a 3D terrian depend on the picture's color that i load in fist, but the difficult is the picture is too large for my computer to deal with, so i think if there is a method to reduce the picture's size first, just like other software do.

thank you very much!

hkyProgrammer88
07-21-2002, 02:40 PM
When you say the picture is too big for your computer to deal with, do you mean it is to big to load into memory (from a file) before it is sent to OpenGL or it is too big to store in Video Memory or where ever OpenGL stores it?

Also, do you know how to manually load your picture file into OpenGL, (if you do, then write a function to reduce the pictures size before using it for rendering).

One way (not ideal) is to use a painting program and have it reduce your image's size. Most paint programs have sophisticated algorithms to produce the best quality possible at reduced resolution.

*** If you want your program to automatically reduce image size ***
I think my previous post is the way you'll have to go. I am not sure what file format you are using for your picture. Please tell me the file format you're having problems with and if you want, I will write you some easy to understand and documented code (C\C++, VB, Java) which should explain how you can reduce the image size. I will try to enable reduction by simply throwing out some pixels or resampling the picture (like a mip map) to a lower resolution.

Sorry for the long post

[This message has been edited by hkyProgrammer88 (edited 07-21-2002).]

randychou
07-22-2002, 06:01 AM
1. my picture is a bmp format.
2. i can load it to memory, but it is difficult to deal with in opengl. so i want to reduce it before sent to opengl.
3. i use vc++(MFC)

i am sorry that my english is very bad and so thank you for your help!

Deiussum
07-22-2002, 07:44 AM
You can use gluScaleImage.

Just an extra note: If you are trying to use 1024x768 or 800x600 as textures, you're going to end up with problems. Textures need to have dimensions that are a power of 2. If you use gluBuild2DMipmaps you can use any size, as it will resize them to power of 2 dimensions underneath.

nickels
07-23-2002, 11:36 AM
Can't you just load the image into the windows paint program and scale it down there before you load it?

jubei_GL
07-23-2002, 05:56 PM
How about using a PHOTOSHOP ????

randychou
07-24-2002, 04:30 PM
i find i can use stretchDiBits function to reduce the picture to fit the pDC, and use BitBlt function to capture the picture data from the pDC. but i still can't work it out because the stretchDiBits is work in DIB and BitBlt is work in Bitmap.

anyway, thanks every one!