Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Masking, Keying and Image Composition ideas.

From: james:mustard at: 24-May-2003 20:10

Hi All, Have added a reference demo for REBOL/View of image masking / keying / compositing to: This includes 4 functions that will work in View or Core to do a variety of masking / overlay / type effects. For those who have some time for detective work / enlightening me - I am using REBOL/View 3-Aug-2002 (for linux) and am getting a weird bug/error/feature?? where save/png sometimes does not always save the alpha channel information - so far I have only noticed this occurring on images where black (0.0.0) or white (255.255.255) are being masked. (This wont be apparent in the demo link above as i cheated and specified transparency to be in the boxen style line.) ;----- masking functions ---------------------------------- create-mask: func [mask c /local img [image!] v [integer!]][ img: copy mask for v 1 (img/size/x * img/size/y) 1 [if not (pick mask v) = c [poke img v]] return img ] create-not-mask: func [mask c /local img [image!] v [integer!]][ img: copy mask for v 1 (img/size/x * img/size/y) 1 [if (pick mask v) = c [poke img v]] return img ] ;--------load in test image-------------------------------- msk: load ; ;-------Scenario 1: Mask by Color ------------------------- ; Images 1 - 3 save with alpha channel,Image 4 does not. ; save/png %image1.png create-mask msk 255.0.0 save/png %image2.png create-mask msk 0.255.0 save/png %image3.png create-mask msk 0.0.255 save/png %image4.png create-mask msk 255.255.255 ; ;-------Scenario 2: Mask by Color ------------------------- ;Images 5 - 7 do not save alpha channel, Image 8 does.. ; save/png image5.png create-not-mask msk 255.0.0 save/png image6.png create-not-mask msk 0.255.0 save/png image7.png create-not-mask msk 0.0.255 save/png image8.png create-not-mask msk 255.255.255 ;-------------------------------------------------------- PS: Yes I am aware there are other ways rather than using FOR statements (like repeat) but repeat was having issues with moving past the end of image markers..?? (repeat n mask []) so what is there now works :P James.