Skip to main content
GameDev.net gamedev.net
🔒 Locked

more bitmap stuff

Started by Jason2Jason Jun 2, 2002 at 6:31 PM 2 replies 350+ views
Original Post
Jason2Jason
Jason2Jason
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
jakl007
jakl007
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...
What was it when I was in is now no longer that so I am out...
Colin Jeanne
Colin Jeanne
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.