Archived

This topic is now archived and is closed to further replies.

Tokage

Bitmaps Annoy Me

Recommended Posts

Is there a way to load bitmaps whose widths aren''t powers of 2? This problem has been annoying me to no end and I really need to find a way. The user needs to supply an image, so resizing my bitmaps won''t cut it.

Share this post


Link to post
Share on other sites
i assume you mean for OpenGL or D3D. the problem is that graphics cards expect textures to be power-of-two sized, so you are stuck with it.

you can always load the bitmap into memory, and then resize it to a power-of-two, or load it into a power-of-two sized chunk of memory and adjust texture coordinates so the unused space around the image isn''t displayed.

Share this post


Link to post
Share on other sites
With a bit of experimentation, I found out the problem, but not the solution. The bitmap has to fit into an even byte. Which means that it''s not power of 2 that matters, it''s multiple of 8. Is there any way to fix this?

Share this post


Link to post
Share on other sites
Pad the data at the end of each row. The extra bytes are ignored.

BTW, the pitch (width of a row in bytes) has to be a multiple of 4 bytes, not 2 or 8.

[edited by - JohnBolton on July 27, 2003 4:01:15 AM]

Share this post


Link to post
Share on other sites