Setting Pixels - More answers to suggestions
Monte Goulding
monte at sweattechnologies.com
Wed Jan 29 18:57:01 EST 2003
>
> on mouseUp
> put empty into iData
> put binaryEncode("CCCC",0,0,255,0) into redPixel
> put the imageData of image "bmw.bmp" into iData
> delete char 1 to 1600 of iData
> repeat with i = 1 to 400
> put redPixel before iData
> end repeat
> set the imageData of image "bmw.bmp" to iData
> play beep
> end mouseUp
>
Hi I got 2.405 seconds with your script (Athlon 1600+ with 512MD DDR RAM)
But the following script got 0.161 seconds:
on mouseUp
put the long seconds into tSeconds
put empty into iData
put binaryEncode("CCCC",0,0,255,0) into redPixel
put the imageData of image 1 into tData
delete char 1 to 1600 of tData
repeat for 400
put redPixel after iData
end repeat
set the imageData of image 1 to iData&tData
put the long seconds-tSeconds
end mouseUp
The changes are:
1. I kept the image data in a separate variable until it was needed (tData)
2. I used repeat for (although in this instance id didn't save much time)
3. I put redPixel after rather than before. (Assuming the engine uses array
structures to hold strings then putting the data before will mean that each
array element will need to be pushed back).
Hope this helps
Monte
More information about the use-livecode
mailing list