#include <GDIPlus.au3>
Example()
Func Example()
Local $hImage1, $hGraphics
Local Const $iWidth = 100, $iHeight = 100
; Initialize GDI+ library
_GDIPlus_Startup()
$hImage1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\p0.bmp")
; Draw one image in another
$hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1)
Local $aRemapTable[4][2]
$aRemapTable[0][0] = 3
$aRemapTable[1][0] = 0xFF2D1200 ;Old Color1
$aRemapTable[1][1] = 0xFF000000 ;New Color1
$aRemapTable[2][0] = 0xFF491D00 ;Old Color2
$aRemapTable[2][1] = 0xFF000000 ;New Color2
$aRemapTable[3][0] = 0xFF381600 ;Old Color3
$aRemapTable[3][1] = 0xFF000000 ;New Color3
Local $hIA = _GDIPlus_ImageAttributesCreate()
_GDIPlus_ImageAttributesSetRemapTable($hIA, $aRemapTable)
_GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage1, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA)
; Save resultant image
_GDIPlus_ImageSaveToFile($hImage1, @ScriptDir & "\p1.bmp")
; Clean up resources
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_ImageDispose($hImage1)
; Shut down GDI+ library
_GDIPlus_Shutdown()
EndFunc ;==>Example
https://i.postimg.cc/ZYXCH5MQ/p0.png
https://i.postimg.cc/0jS5F7BB/p1.png
Hello,
Is there a quick way to use "gdi" to convert the image "p0.bmp" to "p1.bmp"?
With "_GDIPlus_ImageAttributesSetRemapTable" I could convert the relevant pixels to the desired color. Now I just need a quick function to replace the remaining non-relevant pixels with white "0xFFFFFFFF".
thanks in advance
p1.bmp p0.bmp