Re: Quick Demo stack for creating Transpanrecy effect.

2005-05-05 Thread Chipp Walters
JB,
Thanks, after modifying it so that I could compare apples to apples, I 
came up with the following function. It tests to between 7-8 times as 
fast as the original, which is substantial. I'm pretty sure the overhead 
is in the binaryEncode function, which you only do 4 times, while I call 
it once for each pixel. Thanks for your help!

For those interested, in the messagebox type:
go URL "http://www.altuit.com/webs/altuit2/RunRev/altMakeTrans.rev";
best,
Chipp
function altMakeTransAlpha pTransColor,pImgData,pAlphaData
  --> pTransColor IS THE COLOR TO MAKE TRANSPARENT
  -->  EX. "255,255,255" IS WHITE
  --> pImgData IS THE IMAGEDATA FROM WHICH THE MASK IS CREATED
  --> pAlphaData IS THE ALPHADATA OF THE ORIGINAL IMAGE
  --> RETURNS THE ALPHADATA TO USE FOR TRANS MASK
  put binaryEncode("C",0) into t0RGB
  put t0RGB into tAlphaTrans
  put binaryEncode("C",item 1 of pTransColor) after t0RGB
  put binaryEncode("C",item 2 of pTransColor) after t0RGB
  put binaryEncode("C",item 3 of pTransColor) after t0RGB
  put 0 into tPos
  repeat forever
put offset(t0RGB,pImgData,tPos) into t
if t=0 then
  exit repeat
else
  add t+3 to tPos
  put tAlphaTrans into char tPos/4 of pAlphaData
end if
  end repeat
  return pAlphaData
end altMakeTransAlpha
___
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution


RE: Quick Demo stack for creating Transpanrecy effect.

2005-05-05 Thread MisterX
Here's a little stack i did way back 2 or 3 years ago to sort out this
transparency format.

I sent it to Chipp bot didn't get an answer (busy guy preparing for
Monterey!) and it does it in different in a different way

But i never managed to work the mickey cursors correctly. Until there's
color in them that is, i'd rather wait than live in a b/w world. But the
cool thing about it is the "text" based editor ;)

After a few crashes and hardly any success making it work, i gave up... 

 go URL "http://monsieurx.com/hyper/stacks/MickeyHandCursor.rev";

The name is because of the cursors i wanted to use in XOS at the time. ;)

cheers
Xav

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of jbv
> Sent: Thursday, May 05, 2005 13:05
> To: How to use Revolution
> Subject: Re: Quick Demo stack for creating Transpanrecy effect.
> 
> 
> Chipp,
> 
> I was wrong : you can't set transparent pixels using the "replace"
> function (actually I thought that the 1st byte of each pixel 
> was used for the alpha channel, but it's just zero).
> 
> But you can try the following script which uses the offset function.
> With the image in your example, it's roughly 28 times faster :
> 
> on mouseUp
>   set cursor to watch
>   lock screen
>   put binaryEncode("C",0) into a
>   put a into b
>   repeat 3 times
> put binaryEncode("C",255) after a
>   end repeat
> 
>   put imagedata of img 2 into IMD
>   put alphadata of img 2 into AD
>   put 0 into sk
>   repeat forever
> put offset(a,IMD,sk) into c
> if c=0 then
>   exit repeat
> else
>   add c+3 to sk
>   put b into char sk/4 of AD
> end if
>   end repeat
>   set alphadata of img 2 to AD
> end mouseUp
> 
> JB
> 
> > Chipp,
> >
> > one more question : have you tried to use the replace function for 
> > groups of 4 bytes in the imagedata to speed up things, instead of 
> > checking binary values in the imagedata and then setting 
> each byte of 
> > the alphadata ?
> >
> > best,
> > JB
> >
> > > Helping out a friend, I did this. It could be good for a 
> number of 
> > > things including:
> > >
> > > Creating cursors
> > > Creating transparent GIFs
> > > etc..
> > >
> > > in the messagebox:
> > >
> > > go URL 
> "http://www.altuit.com/webs/altuit2/RunRev/altMakeTrans.rev";
> > >
> > > altMakeTransparent
> > > This is a small demo stack which has a neat function 
> which can make 
> > > a specific color transparent in an image.
> > >
> > > The demo makes all white pixels transparent. The function 
> is in the 
> > > script of the button, "Make White Transparent"
> > >
> > > -Chipp
> > >
> > > ___
> > > use-revolution mailing list
> > > use-revolution@lists.runrev.com
> > > http://lists.runrev.com/mailman/listinfo/use-revolution
> >
> > ___
> > use-revolution mailing list
> > use-revolution@lists.runrev.com
> > http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 

___
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Quick Demo stack for creating Transpanrecy effect.

2005-05-05 Thread jbv

Chipp,

I was wrong : you can't set transparent pixels using the "replace"
function (actually I thought that the 1st byte of each pixel was used
for the alpha channel, but it's just zero).

But you can try the following script which uses the offset function.
With the image in your example, it's roughly 28 times faster :

on mouseUp
  set cursor to watch
  lock screen
  put binaryEncode("C",0) into a
  put a into b
  repeat 3 times
put binaryEncode("C",255) after a
  end repeat

  put imagedata of img 2 into IMD
  put alphadata of img 2 into AD
  put 0 into sk
  repeat forever
put offset(a,IMD,sk) into c
if c=0 then
  exit repeat
else
  add c+3 to sk
  put b into char sk/4 of AD
end if
  end repeat
  set alphadata of img 2 to AD
end mouseUp

JB

> Chipp,
>
> one more question : have you tried to use the replace function for
> groups
> of 4 bytes in the imagedata to speed up things, instead of checking
> binary values
> in the imagedata and then setting each byte of the alphadata ?
>
> best,
> JB
>
> > Helping out a friend, I did this. It could be good for a number of
> > things including:
> >
> > Creating cursors
> > Creating transparent GIFs
> > etc..
> >
> > in the messagebox:
> >
> > go URL "http://www.altuit.com/webs/altuit2/RunRev/altMakeTrans.rev";
> >
> > altMakeTransparent
> > This is a small demo stack which has a neat function which can make a
> > specific color transparent in an image.
> >
> > The demo makes all white pixels transparent. The function is in the
> > script of the button, "Make White Transparent"
> >
> > -Chipp
> >
> > ___
> > use-revolution mailing list
> > use-revolution@lists.runrev.com
> > http://lists.runrev.com/mailman/listinfo/use-revolution
>
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution

___
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Quick Demo stack for creating Transpanrecy effect.

2005-05-04 Thread Ken Ray
On 5/4/05 3:09 PM, "jbv" <[EMAIL PROTECTED]> wrote:

> I've done that before : setting transparent pixels, replacing
> colors in an image, etc.

Have you managed to create transparent pixels in an image, but *not* ones of
the same color that are in an enclosed region (i.e. leave those opaque)?

For example, if you have a circle that is white on the inside and white in
the surrounding area of the bounds of the image rectangle, setting only
those white pixels *outside* the circle as transparent...


Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: [EMAIL PROTECTED]


___
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Quick Demo stack for creating Transpanrecy effect.

2005-05-04 Thread jbv


Chipp,

one more question : have you tried to use the replace function for
groups
of 4 bytes in the imagedata to speed up things, instead of checking
binary values
in the imagedata and then setting each byte of the alphadata ?

best,
JB

> Helping out a friend, I did this. It could be good for a number of
> things including:
>
> Creating cursors
> Creating transparent GIFs
> etc..
>
> in the messagebox:
>
> go URL "http://www.altuit.com/webs/altuit2/RunRev/altMakeTrans.rev";
>
> altMakeTransparent
> This is a small demo stack which has a neat function which can make a
> specific color transparent in an image.
>
> The demo makes all white pixels transparent. The function is in the
> script of the button, "Make White Transparent"
>
> -Chipp
>
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution

___
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Quick Demo stack for creating Transpanrecy effect.

2005-05-04 Thread jbv

I've done that before : setting transparent pixels, replacing
colors in an image, etc.
the problem with using the imagedata property is that it's
terribly slow... it works for small images (like in your example),
but for large images, better write an external...
JB

> Helping out a friend, I did this. It could be good for a number of
> things including:
>
> Creating cursors
> Creating transparent GIFs
> etc..
>
> in the messagebox:
>
> go URL "http://www.altuit.com/webs/altuit2/RunRev/altMakeTrans.rev";
>
> altMakeTransparent
> This is a small demo stack which has a neat function which can make a
> specific color transparent in an image.
>
> The demo makes all white pixels transparent. The function is in the
> script of the button, "Make White Transparent"
>
> -Chipp
>
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution

___
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution