Image Masks - Completely lost

Jim Ault JimAultWins at yahoo.com
Tue Dec 27 17:50:48 CST 2005


On 12/27/05 2:24 PM, "Bob Warren" <robertum at brturbo.com> wrote:
>The RR HELP hasn't helped me very much so far, I'm afraid. My experiments with
"imagedata" and  "alphadata" have so far failed.

Bob, maybe the following will help you get a handle on this image stuff.

a 10x10 image has 100 alphaData bytes
a 10x10 image has 300 imageData bytes
obviously imageData (RGB) cannot possibly fit into the alphaData
a 10x10 image has 100 maskData bytes

alphaData, if all were 00, then it would be transparent
alphaData, if all were FF, then it would be opaque
imageData, if all were 00, then it would be black (no lights are on)
imageData, if all were FF, then it would be white (RGB full on
maskData, if all were 00, then it would be unmasked and show thru
maskData, if all were anything but 00, then it would be masked and nothing
would show thru

alphaData for one pixel could be C0
imageData for that same pixel could be 80 3F FF
maskData for that same pixel should be 00 to see it

alphaData for one pixel could be C0  [75% opaque, 25% transparent]
imageData for that same pixel could be 80 3F FF  [.5R .25G 1.0B]

thus a 10x10 image has 100 alphaData bytes.  If all were value  0, this
would be like "00 00 00 00 00 00 00 00 00 00 00  etc 100 times"
and  a 10x10 image has 300 imageData bytes.  If all bytes were 0, this would
be like "00,00,00   00,00,00   00,00,00  etc to make 100 groups of 3"
which would be a black square as R & G & B are 00 for each pixel.
thus a 10x10 image has 100 maskData bytes.  If all were value  0, this would
be like "00 00 00 00 00 00 00 00 00 00 00  etc 100 times"


remember that a value of
0 = 00      in hexadecimal, which is what a byte contains.
255 = FF  in hexadecimal
127 = 80  (pronounced 8 zero, not eighty) in hexadecimal, which is 50% of
maximum of 255

Bright red square would be 300 bytes,
like "FF,00,00   FF,00,00   FF,00,00   FF,00,00  etc 100 groups of 3"
where every pixel has 0 green and 0 blue, 255 Red

Dark maroon square would be 300 bytes
like "80,00,00   80,00,00   80,00,00   80,00,00   etc 100 groups of 3"
where every pixel has 0 green and 0 blue, 50% red.

Thus imageData storage = 300 bytes, alphaData = 100 bytes
One text char = 1 byte.  The letter 'b' = 62, 'B' = 42
thus 'Bob' = 42 6F 62 = 3 bytes.

If the alphaData alternated 00 FF 00 FF 00 ... then this would be like a
checkerboard of transparent pixels and opaque pixels, 100% transparent or
100% opaque.

If this were the alphaData 80 80 80 80 80... each pixel would be 50%
transparent (or 50% opaque)

Very confusing to use so many different concepts for values in one exercise,
but that is the wonderful world of color.  Hopefully some of these
paragraphs will help you make sense of it all.

Jim Ault
Las Vegas

On 12/27/05 2:24 PM, "Bob Warren" <robertum at brturbo.com> wrote:

> I am trying to apply a mask to an image without any success whatsoever
> in getting it to work correctly. Would someone be kind enough to give me
> an example of how it might be done? My experiments with "imagedata" and
> "alphadata" have so far failed.
> 
> Let's outline a simple spec:
> 
> 1. I have a normal full coloured image on the left of my window, loaded
> from an RGB PNG file. The image box is called "fullcolour".
> 
> 2. I have another image in the middle of my window which is exactly the
> same size as the one on the left. The image it contains consists of a
> big, black circle on a white background. The image was also loaded from
> an RGB PNG file. The image box is called "themask".
> 
> 3. There is an empty image box on the right called "result".
> 
> 4. If I click on button "showblack", the black ball mask in the middle
> image is applied to the image on the left to show the ball portion only
> of the coloured picture in the "result" image on the right. It has a
> surround of the original grey colour.
> 
> 5. Alternatively, if I click on button "showwhite", the ball-surround
> portion of the mask is applied to the "fullcolour" image on the left,
> producing the original coloured image with a grey round hole in the
> middle in "result".
> 
> Any hints regarding file types that can be used (e.g. PNG, JPG, BMP,
> etc.), the richness of bits (e.g. 2-bit, 8-bit, 16-bit, 32-bit, etc.)
> and so on, for the original coloured picture and the mask picture, would
> be greatly appreciated.
> 
> Also, can anyone recommend useful webpages elucidating this kind of
> thing? The RR HELP hasn't helped me very much so far, I'm afraid.
> Thanks.
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list