Mutltiple Masking
Blitz3D Forums/Blitz3D Programming/Mutltiple Masking
| ||
is it possible to mask image more than one color? because I've tried to do maskimage than another maskimage but only the second maskimage worked. thanks in advance |
| ||
That's not possibe as far as I know, but you could use a little trick to achieve the same: use Setbuffer, Lockbuffer and ReadPixelFast and WritePixelFast to paint all to-be-masked pixels with one definite maskcolor that will be used with MaskImage later. EG: setbuffer imagebuffer (img) lockbuffer() w=imagewidth(img) h=imageheight(img) for j=0 to h-1 for i=0 to w-1 rgb=readpixelfast(i,j) and $FFFFFF if (rgb=mask1) or (rgb=mask2) or (rgb=mask3) writepixelfast i,j,mask1 endif next next unlockbuffer() setbuffer backbuffer() maskimage img,mask1 Or you may store this inside a function, so it becomes more useful: my_maskimage(img,$000000,$FF00FF,$00FF00) ... function my_maskimage(img,col1=0,col2=0,col3=0,col4=0,col5=0) setbuffer imagebuffer (img) lockbuffer() w=imagewidth(img) h=imageheight(img) for j=0 to h-1 for i=0 to w-1 rgb=readpixelfast(i,j) and $FFFFFF if (rgb=col1) or (rgb=col2) or (rgb=col3) or (rgb=col4) or (rgb=col5) writepixelfast i,j,col1 endif next next unlockbuffer() setbuffer backbuffer() maskimage img,mask1 return img end function So this allows to use a max of 5 maskcolors. You may of course increase the number of optional colors. Tho, if you omit any maskcolor parameter in the function call, then black ($000000) is taken as default, so maybe you need to alter this. |