more bitmap stuff
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
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...
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement