#### Archived

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

## Recommended Posts

i made my own bitmap loader to load in a height map. im not using any API calls im doing it from scratch with fread()''s when i load in the bitmap, it looks as though fread is adding 0''s to the bitmap in weird places. my test bitmap is has only one color on it (r=150, g=150, b=150). when i output all of the data to a file, it should look like this: (assume that each line is a new pixel, the first column is for red, the next green and the next blue): 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 but it doesn''t it looks like this: 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 0 0 150 i have no idea where these 0''s are coming from. I am using fread to load the data straight out of the bmp file and the outputting it on the next line and these zeros that always seem to be traveling in pairs of two are coming out of no where. Again my test bitmap has only one color on it, so these are not supposed to be there. The bitmaps color format is R8B8G8. here is the code:

int			x, y;
V3DCOLOR	Color;
FILE		*File = fopen(filename, "rb");

BitmapData = new V3DCOLOR[BitmapWidth * BitmapHeight];

if (!BitmapData)
return false;

for (x = 0; x < BitmapWidth; x++) {
for (y = 0; y < BitmapHeight; y++) {

BitmapData[y + x * BitmapWidth].r = Color.r;
BitmapData[y + x * BitmapWidth].g = Color.g;
BitmapData[y + x * BitmapWidth].b = Color.b;
}
}

fclose(File);





i added a line that would output what came from it and it was the 150''s polluted with 0''s anybody know ?

##### Share on other sites
Haha... silly coder (j/k). If the width isn''t evenly divisible by 4.. it pads it with 0''s.

Billy

BillyB@mrsnj.com -> Email me, and I can give you my bitmap loader (source code).

hehehe
nice worked

##### Share on other sites
i''d appreciate it. i''m trying to do mine through
GDI calls and i swear i can''t get the bitmap data
at all... 2 days of work on a pathetically simple
problem.

you can mail me at chisholm@cs.utk.edu

thanks
dan

• ### Forum Statistics

• Total Topics
628349
• Total Posts
2982210

• 10
• 9
• 24
• 11
• 9