Blends two images together using good ol' linear interpolation.
Parameters are the 2 source images, destination image for the result, and percent to blend. source image sizes must be the same.
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
make memblock from image 257, 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 257, location, rgb(r,g,b)
next y
next x
make image from memblock dest, 257
delete memblock 255
delete memblock 256
delete memblock 257
endfunction
"eureka" - Archimedes