Chris Carroll-Davis 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.

Two obvious possible reasons .... and probably more that I didn't immediately see.

1. I suspect taking the imagedata of the image may take some time, so instead of

 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

I would have done
  put the imagedata of image "A1" into tImageData
 repeat with n = 1 to number of chars in imagedata of image "A1"/4
   put char n*4 of tImageData into char n of temp


2. Putting a value into "into char N of tVar" happens quickly - but slower that putting "after tVar"
so I'd actually make that central line be
   put char n*4 of tImageData after temp

This might still be slower than the other method, because "repeat for each char ..." is very fast - possibly fast enough that going around the loop 4 times as often beats the cost of accessing "char N*4"



--
Alex Tweedly       http://www.tweedly.net



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.8/380 - Release Date: 30/06/2006

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to