light mapped image by Phaelax29th May 2004 4:51
|
---|
Summary supply a texture map and a light map, function combines the two to create a new image. Texture and light map must be of same dimensions. Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com function create_shadowed_image(texture as integer, light as integer, destination as integer ) make memblock from image 255, texture make memblock from image 256, light make memblock from image 257, light width as dword height as dword width = memblock dword(255, 0) height = memblock dword(255, 4) for x = 1 to width for y = 1 to height location = ((y-1)*width + x - 1)*4 + 12 b = (memblock byte(255,location) * memblock byte(256,location)) / 255 g = (memblock byte(255,location+1) * memblock byte(256,location+1)) / 255 r = (memblock byte(255,location+2) * memblock byte(256,location+2)) / 255 write memblock dword 257, location, rgb(r,g,b) next y next x rem image number, memblock number make image from memblock destination, 257 delete memblock 255 delete memblock 256 delete memblock 257 endfunction |