Exporting transparent PNGs (again)

Chris Carroll-Davis asgg35 at dsl.pipex.com
Wed Jul 5 05:53:30 EDT 2006


Jim -

I'm sure you are correct here.  I tried testing my loop against  
Dave's.  On a small image my loop was 75 times slower than his.  On a  
larger image that took about a third of a second with his routine, I  
expected mine to take about 20 seconds... After 5 minutes I gave up!!!

Chipp - your compositing stack is great - wish I'd seen it a few days  
ago!

With everyone's help I now have a first draft of handler that  
correctly exports a transparent PNG of a field containing Japanese  
text - just what I needed!  (And I've also learned a couple of  
scripting lessons to boot - I had never used the "repeat for each  
+var" syntax before!  Doh!  I am a SC dinosaur and I don't think SC  
has this variant). Thanks so much.

All I need now is a bigger brain.

  - Chris



On 5 Jul 2006, at 07:27, Jim Ault wrote:

> The key maybe the
>          repeat for each
> which is a sequential access rather than
>  'evaluate the access position each loop'
>
> I also think that the larger the data source, the slower 'repeat  
> with x ='
> becomes.
>
> Try these runs and see if the results are linear or exponential.
>
> get ( number of chars in imagedata of image "A1"/4)
> repeat with n = 1 to it/10
> repeat with n = 1 to it/5
> repeat with n = 1 to it/4
> repeat with n = 1 to it/2
> repeat with n = 1 to it/1
>
>
> Jim Ault
> Las Vegas
>
> On 7/4/06 2:33 PM, "Chris Carroll-Davis" <asgg35 at dsl.pipex.com> wrote:
>
>> 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
>>
>> _______________________________________________
>> 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
>
>
> _______________________________________________
> 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