Jump to content
  • Advertisement

Archived

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

Jason2Jason

more bitmap stuff

This topic is 6015 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. In a book, it give an example on loading bitmaps in. Theres a part where it finds out the size of the image data (if no size is specified). Here''s basicly what its doing: (biWidth * biBitCount + 7) / 8 * abs(biHeight) I need to know two things here: What is this doing? I mean, where did the 7 and the 8 come from? and What the function abs(int) (in stdlib.h) does? thx, -J

Share this post


Link to post
Share on other sites
Advertisement
Well i don''t know what the 7 and 8 are but the abs() is absolute value I believe.


What was it when I was in is now no longer that so I am out...

Share this post


Link to post
Share on other sites
Absolute value makes the number positive. Since the height of a bitmap can be negative (specifying a different format for the bitmap) this code is making sure that it is not returning a negative size.

My guess for what it is doing is this:

biWidth * biBitCount : bits per line
+ 7 : add 7 more bits for alignment
/ 8 : number of bytes per line
* abs(biHeight) : times number of lines

So, if you had a 1x1 monochrome bitmap it would look like this:

(1 * 1 + 7) / 8 * abs(1) = (8 / 8) * 1 = 1, or 1 byte of memory used.



I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!