PDA

View Full Version : Drawing A Bitmap From File



Bobalandi
03-01-2008, 01:29 PM
Is there an easy way to be able to draw a bitmap from file at specific coordinates on the screen? Thanks.

-NiCo-
03-01-2008, 02:30 PM
Yes, with drawpixels (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/drawpixels.html) and rasterpos (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/rasterpos.html)

Bobalandi
03-01-2008, 04:17 PM
I've seen that, but I was wondering how to use it...

ruysch
03-01-2008, 05:16 PM
You would properly also like to use glOrtho2D to set the model-view matrix for 2D rendering.
And then use glDrawPixels, like below (i.e pixels is a STL vector of your data)

glDrawPixels(512,512,GL_RGB,GL_UNSIGNED_BYTE, &pixels[0]);

Bobalandi
03-01-2008, 06:46 PM
well, yes, but what I am asking is how do I do it when I have a bitmap file

-NiCo-
03-01-2008, 06:53 PM
You first have to read the file and convert it to a data container in system memory before you can download it to the GPU.
Non-compressed file formats (bmp,ppm,...) usually take only a few lines of code to do this.
If you're reading compressed textures (jpg,...) you'll need an image library such as DevIL (http://openil.sourceforge.net/),imageMagick (http://www.imagemagick.org) or whatever image library you prefer (these also work for non compressed image formats).

RGHP
03-02-2008, 02:07 PM
How to laod them?

Look at the end of this thread:

http://www.opengl.org/discussion_boards/...3307#Post233307 (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Main=46341&Number=233307#Post233307)

The data from GetBits() is what yopu have to put in glDrawPixels.

navand
03-03-2008, 11:52 AM
Hey
Have a look at
http://www.cs.ucdavis.edu/~amenta/s06/proj0/portrait.html

It might be of some help