Extracting bitmaps, how?

Started by
7 comments, last by Wodzu 14 years ago
Guys my problem is like this. I want to use bitmap fonts in a cross-platform application. I know how to create bitmap fonts under Windows (NeHe OpeNGL #13 tutorial). Of course this won't work under Linux and so on and I really don't want to use different OS function on each platform to create the same font. So I am having an idea: I will create a set of fonts under Windows and extract them somehow from OpenGL to the binary file for further reuse. However I have no clue how to do this in an easy way. The fonts are compiled into to display lists. Is it possible?
Just started...
Advertisement
Assuming you are talking about images .bmp files. You can't extract bitmaps, they are not compressed. They are plain rgb color data. You could write your own function to read them, it's even easy, but you don't have to. There's already tons of open-source cross-platform libraries allowing you to read image files of all formats. DevIL is a common one (http://openil.sourceforge.net/).

I don't understand your idea, you wan to pre-create OpenGL display list and save them in binary format so you can reload them later? Usually doing that for game data class if called serializing, but that's not really what you want there. Especially since I think display lists are saved in the video card memory.
Thank you for your answer.

I am not talking about the images like for example the ones in .BMP format.

I am talking about bitmaps. Bitmaps consist a single bit of information about each pixel. (Check chapter 8th of OpenGL programming guide: "Drawing Pixels, Bitmaps, Fonts and Images" )


Quote:Original post by Dunge
I don't understand your idea, you wan to pre-create OpenGL display list and save them in binary format so you can reload them later? Usually doing that for game data class if called serializing, but that's not really what you want there. Especially since I think display lists are saved in the video card memory.


More or less I want to do this.

I have an external function which creates me bitmaps of letters compiled into the display list. I want to take back those bitmaps from OpenGL server and store on a hard disk. The reason why I want to do this is that the function for generating letters is *not* cross-platform.

I don't care about the display lists, but the bitmaps are compiled into display lists by the function. I care only about the bitmaps (map of bits, not BMP format).

Thanks for your time.

Just started...
You're using glBitmap to draw fonts?
Open 24-bit bitmap. Allocate width*height/8 (rounded up) bytes. For each 24bpp pixel, convert to a boolean value. Set the next bit in your array of bytes to this boolean value. Serialise the array of bytes and the image width/height to a file. You've just converted a 24bpp bitmap to a 1bpp bitmap.

Something like:
unsigned char* bitmap24 = Get24BppBitmapData(...);int numBytes = (width*height + 7)/8;unsigned char* bitmap1  = new unsigned char[numBytes];memset( bitmap1, 0, numBytes );for( int i=0; i<width*height; ++i ){  unsigned char r = bitmap24[i*3    ];  unsigned char g = bitmap24[i*3 + 1];  unsigned char b = bitmap24[i*3 + 2];  unsigned char rgbTo1bpp = ( r > 127 || g > 127 || b > 127 ) ? 1 : 0;   int byteIndex = i/8;  int bitIndex  = i%8;  bitmap1[byteIndex] |= rgbTo1bpp << bitIndex;}
Just use BMFont and a public domain font, then you'll have everything you need.

http://www.angelcode.com/products/bmfont/
First of all, thank you guys for answering me.

HuntsMan:

Yes, that is what "I am" using. glBitmap is used internally by Windows function wglUseFontBitmaps(); But the only thing which I know is the number of a display list under which the given letter is compiled.

Hodgman: Thanks, but this is not I wanted.

Daaark: Thanks, I will try. This could help in solving my problem.
Just started...
Well, you're out of luck. Display lists are opaque data structures, you cannot access what's inside them, there is no interface to do that.

Also, glBitmap paints directly into the screen, so you can't fetch that either.
Thanks, for letting me know.
Just started...

This topic is closed to new replies.

Advertisement