Hi all,

REALbasic 2006r2 Commercial Pro
Mac OS X 10.4.6

This is a follow up of my previous thread about "Swap Colors", but this time, using RGB (or swapping RGB colors - place the red value in the Blue "channel" and place 0 in both other places/channels -).

In that case, I swap the Red, Green or Blue atoms (watch the code below) and so I used RedMap(), GreenMap(), BlueMap(). Of course, it is possible - in this example - to fills the array at Application launch time, but 28 Ticks for the whole process... I do not care!

Also, I can create two window Properties to store the Width and Height (size) of the original image (see the line who create the TargetSource Picture).

HTH,

Emile

BTW: feel free to send your comments on the shared code.

28 Ticks (approx and running in the IDE) for the code below!
[The code is in the BevelButton: BBRGBSwapBlue.Action]
[I have made some benchmarking with the code I used to swap colors using cmy; there is practically no difference in the use of If Then Else or Select Case; there are more difference between two runs / two times the same BevelButton is depressed... BUT, there is a huge difference between an IDE run and a Stand Alone Application...]

 // Dim the swapped color Picture Target
 Dim TargetPict    As Picture // Target Picture
 // Dim the map needed variables
 Dim MapIdx        As Integer // Loop index to fills the three Maps...
 Dim RedMap(255)   As Integer // Array for the Red Colors
 Dim GreenMap(255) As Integer // Array for the Green Colors
 Dim BlueMap(255)  As Integer // Array for the Vlue Colors
 // Dim the Duration report variables
 Dim TickStart     As Integer // Ticks value at the method start
 Dim TickEnd       As Integer // Ticks value at the method end
 Dim TickLen       As Integer // Ticks duration (TicksEnd - TicksStart)

 // a. Get the tick at the start of the method
 TickStart = Ticks

 // Create an Offscreen Picture
 TargetPict = New Picture(wMain.cSource.Width,wMain.cSource.Height,32)

 // Draw wMain.cSource.Backdrop Picture into TargetPict
 TargetPict.Graphics.DrawPicture wMain.cSource.Backdrop,0,0

 // Change the color in the map
 For MapIdx = 0 To 255
   RedMap(MapIdx)   = 0
   GreenMap(MapIdx) = 0
   BlueMap(MapIdx)  = MapIdx
 Next

 // Apply the color map
 TargetPict.RGBSurface.Transform RedMap,GreenMap,BlueMap

 // Apply the modified Image
 wMain.cSource.Backdrop = TargetPict
 wMain.cSource.Refresh

 // b. Get the tick at the end of the method
 TickEnd = Ticks

 // c. Compute the difference
 TickLen = TickEnd - TickStart

 // d. Compute the difference
 MsgBox "[BlueMap & Transform] Duration (in Tick): " + Str(TickLen)

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

Reply via email to