borax
02-17-2005, 08:50 AM
Is it possible to have either an array of COLORMAPs or a COLORMAP with an array of oldcolor-newcolor enties? I need to replace serveral colors. This work fine with subsequent calls to the ReplaceColor Function, but is surely not the right way to do it...
Code snip (is a modified function of the "MakeTransparent" funktion in cBitmap from OnErrOr)
Public Function ReplaceColor(ByVal OldColor As Long, ByVal NewColor As Long) As Long
Dim bmp As cBitmap
Dim gfx As cGraphics
Set bmp = New cBitmap
Set gfx = New cGraphics
Dim rc As RECT
Dim lAttrib As Long
Dim ReMapTab As COLORMAP
Dim lTmpHandle As Long
ReMapTab.NewColor = NewColor
ReMapTab.OldColor = OldColor
If bmp.CreateFromScan0(m_lWidth, m_lHeight, 0, PixelFormat32bppARGB, 0) = Ok Then
If gfx.GetGraphicsContext(bmp.Handle) = Ok Then
If gfx.Clear = Ok Then
rc.Right = m_lWidth
rc.Bottom = m_lHeight
If GdipCreateImageAttributes(lAttrib) = Ok Then
If GdipSetImageAttributesRemapTable(lAttrib, ColorAdjustTypeDefault, 1, 2, ReMapTab) = Ok Then
If gfx.DrawImageRectRectIAttr(bitmap, 0, 0, m_lWidth, m_lHeight, 0, 0, m_lWidth, m_lHeight, lAttrib) = Ok Then
...
I have tried with:
Dim ReMapTab(0 to 10) As COLORMAP
but this gives me a type mismatch error?!
Code snip (is a modified function of the "MakeTransparent" funktion in cBitmap from OnErrOr)
Public Function ReplaceColor(ByVal OldColor As Long, ByVal NewColor As Long) As Long
Dim bmp As cBitmap
Dim gfx As cGraphics
Set bmp = New cBitmap
Set gfx = New cGraphics
Dim rc As RECT
Dim lAttrib As Long
Dim ReMapTab As COLORMAP
Dim lTmpHandle As Long
ReMapTab.NewColor = NewColor
ReMapTab.OldColor = OldColor
If bmp.CreateFromScan0(m_lWidth, m_lHeight, 0, PixelFormat32bppARGB, 0) = Ok Then
If gfx.GetGraphicsContext(bmp.Handle) = Ok Then
If gfx.Clear = Ok Then
rc.Right = m_lWidth
rc.Bottom = m_lHeight
If GdipCreateImageAttributes(lAttrib) = Ok Then
If GdipSetImageAttributesRemapTable(lAttrib, ColorAdjustTypeDefault, 1, 2, ReMapTab) = Ok Then
If gfx.DrawImageRectRectIAttr(bitmap, 0, 0, m_lWidth, m_lHeight, 0, 0, m_lWidth, m_lHeight, lAttrib) = Ok Then
...
I have tried with:
Dim ReMapTab(0 to 10) As COLORMAP
but this gives me a type mismatch error?!