Manipulating imagedata - quickest technique?

David Bovill david at openpartnership.net
Mon Apr 3 06:03:08 EDT 2006


What's the quickest technique? This script is based on some of Chipps 
work... baiscally it loops through the whole imageData 4 chars at a time 
and manipulates each chunk before adding it to the new data.

A few questions:

    1) Is this the fastest way?

    2) Can someone explain the use of binaryEncode - is this faster or 
slower?

    3) Is there a way to cash some intermediary form of data that is 
faster to manipulate?

For the last point - imagine having sliders for HSV values. At the 
moment the script converts rgb in the imageData to hsv and back again - 
by caching the original images HSV data this could speed things up 
nearly 200%? So what sort of format would make the most sense to store 
this data in - some sort of table / array?

> on colour_SetBrightness imageObject, somePercent
>     set the cursor to watch
>     
>     put the imageData of imageObject into someImageData
>     put 0 into tPos
>     put the length of someImageData / 4 into binaryPixelNum
>      
>     repeat for binaryPixelNum times
>         put tPos + 4 into tPos
>         
>         put charToNum(char tPos + 1 of someImageData) into r
>         put charToNum(char tPos + 2 of someImageData) into g
>         put charToNum(char tPos + 3 of someImageData) into b
>         
>         colour_LightenRGB somePercent, r, g, b
>         
>         put binaryEncode("CCCC", 0, r, g, b) after newImageData
>     end repeat
>     -- put newImageData
>     set the imageData of imageObject to newImageData
> end colour_SetBrightness
>




More information about the use-livecode mailing list