Problem with mask

James Hurley jhurley0305 at sbcglobal.net
Sat Oct 18 21:40:03 EDT 2008


>
> Message: 2
> Date: Thu, 16 Oct 2008 10:53:25 -0700
> From: Scott Rossi <scott at tactilemedia.com>
> Subject: Re: Problem with mask
> To: Revolution Mail List <use-revolution at lists.runrev.com>
> Message-ID: <C51CCDA5.3D05D%scott at tactilemedia.com>
> Content-Type: text/plain;	charset="US-ASCII"
>
> Recently, James Hurley wrote:
>
>> In the past I have always used Freehand to deal with masking of  
>> images.
>>
>> But I thought I would see if I couldn't roll one of my own in RR.
>>
>> It worked after a fashion but is rough around the edges. In
>> particular when masking to an ellipse, the results is flat on the
>> right edge and the bottom edge. I do this by running over the image
>> and masking all pixels that are not within the ellipse--using the
>> "within" function. That should work.
>>
>> But it doesn't quite. There must be something  about images I don't
>> understand. I would appreciate any thoughts.
>
> I think what you're running into is antialiasing -- the smoothing  
> of the
> edge of the mask graphic.  If you look closely at the edge of the  
> oval,
> you'll see it is composed of translucent pixels which are  
> equivalent to
> shades of grey.  This effect is easier to see with a black graphic:  
> the
> interior of the oval is black, but around the edge of the oval are  
> pixels of
> various translucent values that give the oval a smoother appearance  
> and
> allow the edge to blend with whatever is behind the oval.
>
> Your script appears to work only in values of black and white  
> (block and
> clear).  If you want to achieve and antialiased edge you need to  
> include
> in-between (grey) values as well.

Scott,

(I hope this isn't a multiple post. It keeps bouncing back to me.)

Thanks for your thoughtful reply. I have a lot to learn about images.

I'm afraid I still don't understand why I got those flat edges.
It appears that if one were to mask all the pixels of an image  
outside an oval graphic, that the iamge ought bto be an oval, albeit  
with some piilation around the edges. But what happens is a  
flattening on the right edge and at the bottom of the masked image.

>
> Here are a couple of ways you can get the effect:
>
> If you really want to mask an image directly, I think the fastest  
> way to do
> this is to group the oval in a 0 margins group, import a snapshot  
> image of
> the group, and store the alphaData of the snapshot in a variable to  
> use as a
> mask on the target image.  Why a group?  Because the resulting  
> image will
> contain the mask information you need.
>
>   import snapshot from rect (rect of grp 1) of grp 1
>   put the alphaData of last img into myMaskData
>
> You can crop the target image to the oval's rect as you suggest in  
> your
> script and then set the alphaData of the cropped target image to the
> alphaData you collected from the snapshot.

I think I see what you mean here but I'm missing something. I tried  
the following script and got gibberish.

On mouseUp
   group grc 1
   import snapshot from rect (rect of grp 1) of grp 1
   put the alphaData of last img into myMaskData
   set the alphaData of img 1 to myMaskData
end MouseUP

Graphic 1 if an oval and image 1 if a large black square.

I think I need to see this in a script if I am to understand the  
process.


>
>
> If you only want the "effect" of a masked image, a simpler (and  
> arguably
> more flexible) way to mask an image is using groups and ink  
> effects.  I
> posted a sample stack that shows the result.  In your message box:
>
>   go url "http://www.tactilemedia.com/site_files/downloads/ 
> masked_abe.rev"
>
> This is the same effect illustrated in the spotlight demo stack  
> posted here:
>
>   go url "http://www.tactilemedia.com/site_files/downloads/ 
> spotlight.rev"

These are clearly superior to what I was getting, but I'm trying to  
understand where I went wrong.

Jim  Hurley


>
> Hope this helps.
>
> Regards,
>
> Scott Rossi
> Creative Director
> Tactile Media, Multimedia & Design
>
>




More information about the use-livecode mailing list