Advertisement

fill an array with brightness

Started by March 09, 2002 06:15 AM
3 comments, last by the origin 22 years, 11 months ago
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 | * |
                                  \-/
----------------------------------------
Advertisement
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


  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
-------------------------
i need the way over an bmp

because i mast do other things with the source of the heighmap
not only making the heigh

i dont like raw files

and is there a way to do this in the form i expected ?

if yes help me please

thanks

This topic is closed to new replies.

Advertisement