two functions I already posted, and 2 new ones. desaturate (greayscale) image and colorize image. I came up with the colorize function after kenmo told me his was wrong. I'm sure he'll be posting a new dll soon. But just remember who had it working first!
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
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 255, location, rgb(r,g,b)
next y
next x
rem image number, memblock number
make image from memblock destination, 255
delete memblock 255
delete memblock 256
endfunction
function blend_image(img1 as integer, img2 as integer, dest as integer, percent as integer)
make memblock from image 255, img1
make memblock from image 256, img2
width = memblock dword(255,0)
height = memblock dword(255,4)
K# = percent/100.0
for x = 1 to width
for y = 1 to height
location = ((y-1)*width + x - 1)*4 + 12
b = memblock byte(255, location)
g = memblock byte(255, location+1)
r = memblock byte(255, location+2)
b = b + ((memblock byte(256, location) - b) * K#)
g = g + ((memblock byte(256, location+1) - g) * K#)
r = r + ((memblock byte(256, location+2) - r) * K#)
write memblock dword 255, location, rgb(r,g,b)
next y
next x
make image from memblock dest, 255
delete memblock 255
delete memblock 256
endfunction
function desaturate_image(img1 as integer, dest as integer)
make memblock from image 256, img1
width = memblock dword(256, 0)
height = memblock dword(256, 4)
for x = 1 to width
for y = 1 to height
location = ((y-1)*width + x - 1)*4 + 12
b = memblock byte(256, location) * 0.11
g = memblock byte(256, location+1) * 0.59
r = memblock byte(256, location+2) * 0.3
c = r+g+b
write memblock dword 256, location, rgb(c,c,c)
next y
next x
make image from memblock dest, 256
delete memblock 256
endfunction
function colorize_image(img1 as integer, dest as integer, color as dword)
make memblock from image 256, img1
width = memblock dword(256, 0)
height = memblock dword(256, 4)
for x = 1 to width
for y = 1 to height
location = ((y-1)*width + x - 1)*4 + 12
b = memblock byte(256, location) * 0.11
g = memblock byte(256, location+1) * 0.59
r = memblock byte(256, location+2) * 0.3
c = r+g+b
r = (rgbr(color) * c) / 255
g = (rgbg(color) * c) / 255
b = (rgbb(color) * c) / 255
write memblock dword 256, location, rgb(r,g,b)
next y
next x
make image from memblock dest, 256
delete memblock 256
endfunction
"eureka" - Archimedes