fill an array with brightness
hi can somebody send me the code to read in an 256x256 bmp file
with the brigtness value
the pixel 1,9 should fill the array world[1][9] with an float value between 1(for white) and 0(for black) (his brightness value)
the array is float world[256][256]
(i use nehes loadin code of the normal tuts )
thanks
t as long; // holds Temporary pixel values
v as float; // holds reinterpreted cast of t
t = bmparray[x][y].redcomponent; // load red into t
t += bmparray[x][y].greencomponent; // add green to t
t += bmparray[x][y].bluecomponent; // add blue to t
t /= 3; // average t
t /= 256; // clamps t to value between 1 and 0
v = (float)t; // cast t to float
-------- E y e .Scream Software --------
----------------------------------------
/-\
http://www.eyescream.cjb.net | * |
\-/
----------------------------------------
v as float; // holds reinterpreted cast of t
t = bmparray[x][y].redcomponent; // load red into t
t += bmparray[x][y].greencomponent; // add green to t
t += bmparray[x][y].bluecomponent; // add blue to t
t /= 3; // average t
t /= 256; // clamps t to value between 1 and 0
v = (float)t; // cast t to float
-------- E y e .Scream Software --------
----------------------------------------
/-\
http://www.eyescream.cjb.net | * |
\-/
----------------------------------------
i dont understand this post how can i get pixelvalues and what sens has t
is it not needed to count pixels up in an 2 dimensional loop ??
i would expect the form
and now i searsch what must i write between the {} thanks
Edited by - the origin on March 12, 2002 2:52:00 PM
is it not needed to count pixels up in an 2 dimensional loop ??
i would expect the form
for (a= 1;a<257;a++)for (b= 1;b<257;b++){world [a][b] = read brightness of pixel a,b }
and now i searsch what must i write between the {} thanks
Edited by - the origin on March 12, 2002 2:52:00 PM
Why do you want the brightness value ? For a heightmap ? If so use .raw file format. Its for black and white images and it records the brightness from 0-255.
-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------
-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement