At 13:55 Uhr +0200 14.07.2004, Christoffer Enedahl wrote:
I am using this code similar to this :

repeat with xx = 1 to 450
        repeat with yy = 1 to 400
                rgbval = member("firstImg").image.getPixel(xx, yy)
                -- some calculations here and then
                member("secondImg").image.setPixel(xx,yy, newrgbval)
        end repeat
end repeat

This is all working fine, except how slow it is.


It helps to cache slow stuff. like getting a member is slow.
And getPixel and setPixel is slow aswell.

for normal image copy stuff, check copyPixels in the manual, and some inks can be useful.
if you need to work down at pixellevel I would recode the loop something like this:


vImg1 = member("firstImg").image
vImg2 = member("secondImg").image
repeat with xx = 1 to 450
        repeat with yy = 1 to 400
                rgbval = vImg1.getPixel(xx,yy)
                -- some calculations here and then
                vImg2.setPixel(xx,yy, rgbval)
        end repeat
end repeat


although this will speed up the handler a little bit, it doesn't do the great benefit you're expecting, since image objects from a member get passed by reference rather than by value.
so storing member("firstImg").image in the variable vImg1 will only work as kind of 'shortcut', but anyway it needs to dereference the image data and act (and actualize) the image data in the members image.
this is SLOW.
as a rule of thumb, every time you do more than one operation on an imageobject always make sure you work on a copy of the imageobject in RAM and NOT on a reference to a members image.


modifying the above code to:

vImg1 = member("firstImg").image.duplicate()
vImg2 = member("secondImg").image.duplicate()
repeat with xx = 1 to 450
        repeat with yy = 1 to 400
                rgbval = vImg1.getPixel(xx,yy)
                -- some calculations here and then
                vImg2.setPixel(xx,yy, rgbval)
        end repeat
end repeat
member("secondImg").image = vImg2

these *little but very important* changes should speed up the thing noticeably.

nonetheless acting on an image object on a per pixel basis will always remain slow.
depending on what you're after, there may be other techniques (using inkmodes with copyPixels for example), wjhich are WAY FASTER !


--

  |||
a�ex
 --

[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]

Reply via email to