RemapHue example for Visual Basic
' This example changes all green hues(and hues near green) to the hue of crNewColor
Private Function Increment(x As Integer) As Integer
Increment = (x + 1) Mod 256
End Function
Private Function Decrement(x As Integer) As Integer
Decrement = (x + 255) Mod 256
End Function
Private Function Add(x As Integer, y As Integer) As Integer
Add = (x + y) Mod 256
End Function
Private Sub Command83_Click()
Dim i As Integer
Dim nHueGreen As Integer
Dim nHueNewColor As Integer
Dim nHueChange As Integer
Dim crNewColor As OLE_COLOR
Dim iCount As Integer
Dim RasterProc As New LEADRasterProcess
If (LEADRasterView1.Raster.BitmapBits = 16 And LEADRasterView1.Raster.IsGrayscale()) _
Or LEADRasterView1.Raster.BitmapBits = 64 Or LEADRasterView1.Raster.BitmapBits = 48 Then
RasterProc.RemapHueTablesSize = 65536
ElseIf LEADRasterView1.Raster.BitmapBits = 12 Then
RasterProc.RemapTablesSize = 4096
Else
RasterProc.RemapTablesSize = 256
End If
For i = 0 To RasterProc.RemapTablesSize-1
RasterProc.MaskTable (i) = 0
RasterProc.HTable (i) = I
Next I
'Get the hue for green
nHueGreen = RasterProc.HSV_HfromRGB (RGB(0, 255, 0))
'Obtain new hue (crNewColor can be any color)
crNewColor = RGB(255, 255, 0)
nHueNewColor = RasterProc.HSV_HfromRGB(crNewColor)
nHueChange = nHueNewColor - nHueGreen
If (nHueChange < 0) Then
nHueChange = nHueChange + 256
End If
'Set values in uHueTable, uMaskTable
RasterProc.HTable(nHueGreen) = Add(RasterProc.HTable(nHueGreen), nHueChange)
RasterProc.MaskTable(nHueGreen) = 1
'set the hues near green (+/- 10)
iCount = 0
i = Increment(nHueGreen)
While iCount < 10
RasterProc.HTable(i) = Add(RasterProc.HTable(i), nHueChange)
RasterProc.MaskTable(i) = 1
i = Increment(i)
iCount = iCount + 1
Wend
iCount = 0
i = Decrement(nHueGreen)
While iCount < 10
RasterProc.HTable(i) = Add(RasterProc.HTable(i), nHueChange)
RasterProc.MaskTable(i) = 1
i = Decrement(i)
iCount = iCount + 1
Wend
RasterProc.RemapHue LEADRasterView1.raster, True, True, False, False
End Sub