Slowdown when putting symbols into image data

J. Landman Gay jacque at hyperactivesw.com
Tue Sep 9 15:09:51 EDT 2014


On 9/9/2014, 12:51 PM, William Prothero wrote:
> Seems I’ve found the offending line in my draw script. Its:
>
>> >  put byte 1 to tLength of tbrushBinaryData into byte tNewStart * 4 - 3 to tNewStart*4 - 3  + tLength -1 of imgdata  -- insert brushimageData into image
> If I comment out this line, the symbols are drawn in 2.85 seconds, more than a factor of 10 speedup.

This would be similar to using a "repeat with x = 1 to 1000" structure. 
Every time through the loop the engine has to count from byte 1 to 
tNewStart. An image has lots of bytes, so all that counting makes it slow.

I had a very similar requirement in my current project, I had to create 
hundreds of small images on top of a map. I never bothered to try 
drawing into the map image, I knew it would take forever. Instead I used 
a polygon graphic and set its points to the locations I needed, and set 
its markers to the symbol I wanted to display. I needed one graphic per 
symbol type, but that still cut down the number from hundreds to five.

You may remember my thread about setting markers so they would resize 
correctly. It was very helpful and I was able to do what I needed. 
Setting the points of a graphic is instantaneous, there was no delay at 
all. If your goal is similar to mine, you might want to drop the 
painting method and just go with the graphics approach.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com





More information about the use-livecode mailing list