Exporting transparent PNGs (again)

Chris Carroll-Davis asgg35 at dsl.pipex.com
Tue Jul 4 17:33:47 EDT 2006


Dave -

Thanks so much!  Yes, your routine is much faster than mine... though  
I'm not sure why!!

Here is my code:

on mouseUp
   put alphadata of image "black" into temp
   put the milliseconds into tStart ## for speed calc
   repeat with n = 1 to number of chars in imagedata of image "A1"/4
     put char n*4 of imagedata of image "A1" into char n of temp
   end repeat
   put the milliseconds - tStart && length(tMaskData) ##speed score
   set alphadata of image "black" to temp
end mouseUp

For some reason, even though my loop is only a quarter of the length  
of yours with just one line of code in it (and no decisions)  it is  
much slower.  It was slower still because I was (for daft reasons I  
wont go into!) originally doing the loop backwards.

I'll try to tweak to improve speed further, but even as it stands I  
think it should be fine.

Also, thanks Ken for the links.  They helped me understand what is  
going on now!

Regards,

Happy Chris


On 4 Jul 2006, at 18:10, Dave Cragg wrote:

>
> I'm not sure what calculations you are doing in the loop, but it  
> sounds too slow. The following routine creates alphaData from a 300  
> x 300 grayscale image in less than a second on my not so fast  
> machine. (You'll probably need to substitute the calculation inside  
> the loop with your own.)
>
> I'm sure others will step up with faster alternatives. :-)
>
>
> on mouseUp
>
>   put the imageData of image 1 into tImageData
>   put the milliseconds into tStart ## for speed calc
>   put 0 into tCount
>   repeat for each char tChar in tImageData
>     add 1 to tCount
>     if tCount = 4 then
>       put numToChar(255 - charToNum(tChar)) after tMaskData
>       put 0 into tCount
>     end if
>   end repeat
>   put the milliseconds - tStart && length(tMaskData) ##speed score
>   set the alphaData of image 1 to tMaskData
> end mouseUp
>
> Cheers
> Dave
> _______________________________________________
> 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