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

Masking, Keying and Image Composition ideas.

 [1/4] 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: http://www.mustard.co.nz/rebol/compositing.r 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 1.2.8.4.2 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 0.0.0.255 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 0.0.0.255]] 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 0.0.0.255]] return img ] ;--------load in test image-------------------------------- msk: load http://www.mustard.co.nz/rebol/vsml-insignia-mask.png ; ;-------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.

 [2/4] from: antonr:iinet:au at: 24-May-2003 21:03


I noticed a bug when making pixel-boy.r where the alpha channel wouldn't appear until the top-left pixel of the image had its alpha channel value set. You set the top-left pixel, and magically the alpha channel appears. I've already sent a bug report for that. Maybe that will help you. Here's code which demonstrates the bug: img: make image! 2x1 poke img 1 255.255.255.192 poke img 2 255.255.255.0 ?? img img2: make image! 2x1 poke img2 1 255.255.255.0 poke img2 2 255.255.255.192 ?? img2 view center-face layout [ image 64 * img/size img ; as expected image 64 * img2/size img2 ; where's the alpha ? ] I don't understand what the problem is with 'repeat in your comment at the bottom. I am sure if you replace: for v 1 (img/size/x * img/size/y) 1 [...] with: repeat v (img/size/x * img/size/y) [...] that it will work identically, faster, and you won't have to declare 'v as local to the function, either. Also, for a bit extra speed, use: equal? c pick mask v rather than: (pick mask v) = c The parens and the '= cause the interpreter to do more work. not-equal? c pick mask v is also faster than: not (pick mask v) = c Anton Rolls.

 [3/4] from: rotenca:telvia:it at: 24-May-2003 16:02


Hi Anton
> equal? c pick mask v > > rather than: > > (pick mask v) = c > The parens and the '= cause the interpreter to do more work.
c = pick mask v In my system (W98) op! are always faster than functions. Do you have different test results in your system? --- Ciao Romano

 [4/4] from: antonr::iinet::net::au at: 26-May-2003 0:41


Sorry, no, that was a mistake. op! perform faster on my system too. Anton.