Accesing individual Bitmap values

Started by
4 comments, last by Seaman 23 years, 11 months ago
How can I access individual values from A bitmap, I mean if I have a 256 greyscale bitmap say 40*40 how could I fill an array[40][40] with the values. I want to use a bitmap for heightmap data. I''m having trouble explaining I think, but I think u can vaguely get what I''m trying to do. Any help would be greatly appreciated. Thanks Seaman =/
Advertisement
Do you want to read from the file directly?
All you have to do is know the format structure of a bitmap. First you have to read in the file header and then the info header. Since it''s greyscale it should a palette after that. Then you get to the actual values. I''m not at home so I don''t have the documentation, but here is a little hash of what you would do.

BITMAPFILEHEADER bfh;
BITMAPINFOHEADER bih;
// Not sure what palette is, look in help files
// I usually use 16bit or greater

// Open file for read
// Read in bfh
// Read in bih
// Read in palette
// Read in values

If you need any more help on this, you can take a look at the help files or www.wotsit.org

Or feel free to write me or post and I''ll try to get back to you with some code.
Working on: DoP
Go to WOTSIT, there you''ll find information about the file format!

Visit our homepage: www.rarebyte.de.st

GA
Visit our homepage: www.rarebyte.de.stGA
Thanks =)
Yay! I submited two file formats to WOTSIT.org in 7/30/99 and they added them to their site . Do a search for "m8" and "wal". m8 files are images files for Heretic II, they''re really easy to read because there is no compression. wal files are used in Quake2, easier to read.

This topic is closed to new replies.

Advertisement