Mask & Alpha

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jeanvouillon
Posts: 21
Joined: Sat Jan 15, 2011 6:40 pm

Mask & Alpha

Post by jeanvouillon » Tue Jan 18, 2011 12:41 am

Hi guys,
I would like to 'clip' an image imported from the library.
So I'm playing with the alphaData and maskData instructions...

I have tried something simple by copying the alpha channel from an image to the binary data:

put the alphaData of image "mask" into myMask
set the alphaData of image "masked" to myMask

but nothing happen to the image.

Am I missing something?
Thanks.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Mask & Alpha

Post by bn » Tue Jan 18, 2011 1:20 am

Hi Jean,

for something to happen the image has to have alpha information. Otherwise the alphadata is set to transparent. PNG images can have, but must not have alphadata.
Jpeg does not have alphadata.

Very important if you work in imagedata, alphadata or maskdata. Both images have to have the exact same width and height.

I append a stack with an image (an imported png with alphadata) and a image object that I just filled with the bucket tool red.

You can set the alphadata or the maskdata of the red image, you also can remove the alphaData or maskData from the red image via buttons.
Note that the maskdata makes the oval jagged, since the maskdata is only on or off. The alphadata makes a smooth oval, since alphadata is antialiased.

Kind regards

Bernd
Attachments
alphaData.livecode.zip
(41.92 KiB) Downloaded 458 times

jeanvouillon
Posts: 21
Joined: Sat Jan 15, 2011 6:40 pm

Re: Mask & Alpha

Post by jeanvouillon » Tue Jan 18, 2011 2:21 am

Hi Bernd,

Thanks for your (ultra fast!) response and your stack.

So, there is no others ways to clip an image?

Thanks again,

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Mask & Alpha

Post by bn » Tue Jan 18, 2011 9:50 am

Hi Jean,

look at the crop command in the dictionary.

Kind regards

Bernd

jeanvouillon
Posts: 21
Joined: Sat Jan 15, 2011 6:40 pm

Re: Mask & Alpha

Post by jeanvouillon » Tue Jan 18, 2011 4:13 pm

Great!
Thanks Bernd! :D

Post Reply