realbasic-nug
[Top] [All Lists]

Re: Reversing an image

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Reversing an image
From: "Theodore H. Smith" <delete at elfdata dot com>
Date: Fri, 30 Dec 2005 12:20:58 +0000
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <20051230021806 dot 04F83F9BE45 at lists dot realsoftware dot com> <A81911A6-B133-4D27-B396-9B95E328F284 at farhner dot com>
Your code does just about everything wrong that you could possibly do wrong.

Imagine this, you want to walk down a street.

You take one step down the street.

You then stop walking, to open your mobile phone to your sweetheart and say "hey, I've moved one step down the road, I'll be there soon!" Then you end the phone call and put your phone away.

You take another step down the street.

Then you make ANOTHER phone call to her, "hey I've moved one step down the street!"

Ridiculous.

But that's exactly what your code is doing.

Also, you shouldn't put anthing but an integer constant on the end of a for loop. for i = 0 to iEnd (Where iEnd is a local integer) would be better.

You aren't using any pragmas. Put the disablebackgroundtasks pragma in there. That'll give you a 2 or 3x speed up.

The best way to do progress updating, is first DON'T do it, and see if it's slow enough that it needs it. If it DOES need it, then don't even think about updating on every loop. Update on every 50th loop or something like that. And after every 50th loop, STILL don't update, but instead check the Ticks() function to see if a second has passed since your last update.

On 30 Dec 2005, at 02:22, Ben Farhner wrote:

Well I got it all sorted out by removing the progress bar and replacing it with chasingarrows. I wish I could use the RGBSurface.Transform(), but its not available in 5.2.4. Is it still possible to get 5.5?

Ben Farhner
CEO / Head Developer
farhnware
http://macware.byethost5.com


Hi,

Okay, I have a thread that reverses an image. Heres the code:

   for i=0 to p.width-1
     for j=0 to p.height-1
       c=r1.pixel(i,j)
       r2.pixel(i,j)=rgb(255-c.red,255-c.green,255-c.blue)
       progress.prog.value=progress.prog.value+1
     next
     progress.prog.value=progress.prog.value+1
   next

The problem is, that takes over 8 seconds. Other programs, such as
Seashore, do it instantly. I'm using RGBSurfaces, which is supposed
to be faster, but is there a faster way? I'm on RB 5.2.4, Mac OS X
10.4.3. Thanks,


Ben Farhner
CEO / Head Developer
farhnware
http://macware.byethost5.com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>




--
http://elfdata.com/plugin/

What does our work achieve, if it's not making the world a happier place?
http://www.whatnextjournal.co.uk/Pages/Next/Happiness.html
When's the last time you thought deeply about how to improve our lives?


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>