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: Phil M <phil at mobleybros dot com>
Date: Thu, 29 Dec 2005 16:48:56 -0800
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <20051229211240 dot 1D004F9B1C5 at lists dot realsoftware dot com> <9C81CE50-5DDE-41B1-B98F-F956A66D0F5E at farhner dot com>
On Dec 29, 2005, at 3:58 PM, Ben Farhner wrote:

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,

This example is a perfect use of the Transform() method of RGBSurface. The Language Reference describes this well enough, so I won't. =)

BTW, the ProgressBar code is probably slowing up the transformation more than the actual transformation... for future reference, it would be better to only update the ProgressBar in the outer loop. But since Transform will work much faster, you don't even need a progress bar.

_______________________________________________
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>