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 18:57:55 -0800
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>
On Dec 29, 2005, at 6:22 PM, 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?

I didn't realize that Transform was not introduced until 5.5.

With that in mind, here is how I would optimize the loop:

  Dim xMax As Integer
  Dim yMax As Integer

  xMax = p.Width - 1
  yMax = p.Height - 1

  For j = 0 To yMax
    For i = 0 To xMax
      c = r1.pixel(i,j)
      r2.pixel(i,j) = RGB(255-c.red, 255-c.green, 255-c.blue)
    Next
    progress.prog.value=progress.prog.value+1
  Next

Set the Progress.Maximum to equal the number of rows (height) instead of the number of pixels like you had before. Notice that I switched the rows and columns... it is only a theory, but it should be faster to access memory sequentially instead of jumping around in memory like you were by processing the columns with the outer loop.

I would be interested to know how much of an improvement this would provide.

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