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: Nick Lockwood <nick at charcoaldesign dot co dot uk>
Date: Fri, 30 Dec 2005 02:17:36 +0000
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> <00BA1D52-1439-4C1C-A96D-514B13394973 at mac dot com>
I believe the operation he is trying to perform is an inversion of the colours - making the picture a negative of itself, as opposed to flipping it horizontally or vertically.

I believe the procedure being used is the fastest available within RB 5.2 for this purpose. Newer versions of RB have substantially improved speed for RGBsurface operations, but that's not good if you can't afford the upgrade.

The RGBsurface.transform method would be ideal, but I don't think it was introduced until RB 5.5 or later.

You might want to look at something like the Monkeybread plugin, which can do operations like this much faster, and is cheaper than an RB upgrade. Alternatively write your own plugin, or use system declares to access Quickdraw or Quartz.

Nick

On 30 Dec 2005, at 00:49, John Kubie wrote:

This more a question than a suggestion.

If you use drawpicture, you can scale one picture as it's drawn onto another.

Perhaps, if you inverted the source range (x1>x1 or y1>y2) you would get an inverted image?

Drawpicture shoould be much faster than going thru pixel-by-pixel.

Does this work?

John Kubie


On Dec 29, 2005, at 6:58 PM, Ben Farhner wrote:

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>

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



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