combining images

Blitz3D Forums/Blitz3D Beginners Area/combining images

Mental Image(Posted 2004) [#1]
Is it possible to use one image as a mask to determine what bits to show of another image?

i.e. ImageC = ImageA AND ImageB

Ta


ford escort(Posted 2004) [#2]
it's possible with a smart use of the maskimage command but if you have a lot of these image style to draw simultaneously that may slowdown things.

'pict' is the image to draw
'mask' is the image used as a mask (2 color picture better use nonused colors in pict) for exemple we can use pink and green (255,0,255 and 0,255,0) colors to make this picture
'temp' is a temporary buffer the part in pink is the part to show, the part in green is the part to hide

here's a function to do the 'thing'

function maskdraw(x,y,pict,mask)
   buffer=graphicsbuffer();save the active buffer
   temp=createimage(imagewidth(pict),imageheight(pict)) 
   maskimage temp,0,255,0 
   maskimage mask,255,0,255
   setbuffer imagebuffer(temp)
   drawblock pict,0,0 ; draw the picture
   drawimage mask,0,0 ;draw the mask on top
   setbuffer buffer
   drawimage temp,x,y
   freeimage temp
end function


not tested as i'm not @home and i don't have blitz here but should work:)


Mental Image(Posted 2004) [#3]
Wow. Ta very much, that is EXACTLY what I was looking for.

I LOVE this place :-)

Thanks again.