`setup sync on : sync rate 0 `Create media (the 2 memblocks that have to be blended box 0,0,256,256,rgb(255,0,0),rgb(0,255,0),rgb(0,0,255),rgb(255,255,255) get image 1,0,0,256,256,1 : make memblock from image 1,1 ink rgb(255,0,0),0 : box 0,0,256,256 get image 2,0,0,256,256,1 : make memblock from image 2,2 BlendImageMemblocks(1, 2, 3, 50.0) make image from memblock 3,3 perc# = 50.0 do cls `Controls if upkey() = 1 inc perc#, 0.5 if perc# > 100.0 then perc# = 100.0 BlendImageMemblocks(1,2,3,perc#) make image from memblock 3,3 endif if downkey() dec perc#, 0.5 if perc# < 0.0 then perc# = 0.0 BlendImageMemblocks(1,2,3,perc#) make image from memblock 3,3 endif `Output paste image 3, 0, 0 ink rgb(255,255,255),0 text 0,400,"press up/down to slowly fade between the images..." text 0,420, left$(str$(perc#+0.05),4) + "%" sync loop `Function function BlendImageMemblocks(Mem1, Mem2, RetMem, percent#) `Get data Width = memblock dword(Mem1, 0) Height = memblock dword(Mem1, 4) `setup teh returned memblock if memblock exist(RetMem)=0 then make memblock RetMem, 12 + (Width*Height*4) write memblock dword RetMem, 0, Width write memblock dword RetMem, 4, Height write memblock dword RetMem, 8, 32 `blend for y = 1 to Height for x = 1 to Width pos = 12 + ((y-1)*Width*4) + ((x-1)*4) difblue# = (memblock byte(Mem2, pos) - memblock byte(Mem1, pos)) difgreen# = (memblock byte(Mem2, pos+1) - memblock byte(Mem1, pos+1)) difred# = (memblock byte(Mem2, pos+2) - memblock byte(Mem1, pos+2)) blue = memblock byte(Mem1, pos) + int(difblue# / 100.0 * percent#) green = memblock byte(Mem1, pos+1) + int(difgreen#/ 100.0 * percent#) red = memblock byte(Mem1, pos+2) + int(difred# / 100.0 * percent#) write memblock byte RetMem, pos, blue write memblock byte RetMem, pos+1, green write memblock byte RetMem, pos+2, red write memblock byte RetMem, pos+3, 255 next x next y endfunction