Makalele Posted September 28, 2008 Share Posted September 28, 2008 Hi all! I need to know how to FAST edit bmp file with changing some colors. (exactly change all pixel's to white without black and red color ((255,0,0) only).Any Ideas? Link to comment Share on other sites More sharing options...
Makalele Posted September 28, 2008 Author Share Posted September 28, 2008 Hmm i found that code and i changed it a bit: expandcollapse popup#include <Constants.au3> _BMPFilter("D:\Reszta\Moje Dokumenty\AutoIt\Ladder Slasher Bot 2\Render.bmp") Func _BMPFilter($File) $X=0 $Y=0 $imagesize = _ImageGetSize($File) $imgwidth = $imagesize[0] $imgheight = $imagesize[1] $nofpixels = ($imgwidth+1) * ($imgheight+1) Dim $hInst, $hBmp, $hMemDC, $hwnd Opt("WinWaitDelay",1) AutoItWinSetTitle("_GetBMPPixel_Temp_Window") $hwnd = WinGetHandle("_GetBMPPixel_Temp_Window") $hInst = DllCall("user32.dll","int","GetWindowLong","hWnd",$hwnd, "int",$GWL_HINSTANCE) $hInst = $hInst[0] $hBmp = DllCall("user32.dll","hwnd","LoadImage","hwnd",$hInst,"str",$File,"int",$IMAGE_BITMAP, _ "int",0,"int",0,"int",$LR_LOADFROMFILE) $hBmp = $hBmp[0] $hMemDC = DllCall("gdi32.dll", "int", "CreateCompatibleDC", "int", 0) $hMemDC = $hMemDC[0] DllCall("gdi32.dll", "hwnd", "SelectObject", "int", $hMemDC, "hwnd", $hBmp) For $Y=1 to $imgheight For $X=1 to $imgwidth $ret = DLLCall("gdi32.dll","int","GetPixel","int",$hMemDC,"int",$X,"int",$Y) $ret = Hex( $ret[0], 6) $ret = StringRight($ret,2) & StringMid($ret,3,2) & StringLeft($ret,2) $ret=Dec($ret) If ($ret <> 0) And ($ret <> 255) Then DLLCall("gdi32.dll","int","SetPixel","int",$hMemDC,"int",$X,"int",$Y,"int",16777215);changing into white pixel EndIf Next Next ;NOW HOW TO SAVE IMAGE ? DllCall("gdi32.dll", "int", "DeleteDC", "hwnd", $hMemDC) DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $hBmp) ;Return $ret EndFunc Func _ImageGetSize($sFile);SUB Function Local $sHeader = _FileReadAtOffsetHEX($sFile, 1, 24); Get header bytes Local $asIdent = StringSplit("FFD8 424D 89504E470D0A1A 4749463839 4749463837 4949 4D4D", " ") Local $anSize = "" For $i = 1 To $asIdent[0] If StringInStr($sHeader, $asIdent[$i]) = 1 Then Select Case $i = 2; BMP $anSize = _ImageGetSizeSimple($sHeader, 19, 23, 0) ExitLoop EndSelect EndIf Next If Not IsArray($anSize) Then SetError(1) Return ($anSize) EndFunc Func _FileReadAtOffsetHEX($sFile, $nOffset, $nBytes);SUB Function Local $hFile = FileOpen($sFile, 0) Local $sTempStr = "" FileRead($hFile, $nOffset - 1) For $i = $nOffset To $nOffset + $nBytes - 1 $sTempStr = $sTempStr & Hex(Asc(FileRead($hFile, 1)), 2) Next FileClose($hFile) Return ($sTempStr) EndFunc Func _ImageGetSizeSimple($sHeader, $nXoff, $nYoff, $nByteOrder);SUB Function Local $anSize[2] $anSize[0] = _Dec(StringMid($sHeader, $nXoff * 2 - 1, 4), $nByteOrder) $anSize[1] = _Dec(StringMid($sHeader, $nYoff * 2 - 1, 4), $nByteOrder) Return ($anSize) EndFunc Func _Dec($sHexStr, $nByteOrder);SUB Function If $nByteOrder Then Return (Dec($sHexStr)) Local $sTempStr = "" While StringLen($sHexStr) > 0 $sTempStr = $sTempStr & StringRight($sHexStr, 2) $sHexStr = StringTrimRight($sHexStr, 2) WEnd Return (Dec($sTempStr)) EndFunc Especially changed this section: For $Y=1 to $imgheight For $X=1 to $imgwidth $ret = DLLCall("gdi32.dll","int","GetPixel","int",$hMemDC,"int",$X,"int",$Y) $ret = Hex( $ret[0], 6) $ret = StringRight($ret,2) & StringMid($ret,3,2) & StringLeft($ret,2) $ret=Dec($ret) If ($ret <> 0) And ($ret <> 255) Then DLLCall("gdi32.dll","int","SetPixel","int",$hMemDC,"int",$X,"int",$Y,"int",16777215);changing into white pixel EndIf Next Next ;NOW HOW TO SAVE IMAGE ? DllCall("gdi32.dll", "int", "DeleteDC", "hwnd", $hMemDC) DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $hBmp) ;Return $ret And here it's a problem how to save changed in memory image ? Link to comment Share on other sites More sharing options...
martin Posted September 28, 2008 Share Posted September 28, 2008 (edited) Hmm i found that code and i changed it a bit: And here it's a problem how to save changed in memory image ? I think you need to do this (I'm not very confident with GDIPlus) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hMemDC) _GDIPlus_ImageSaveToFile ($hImage,$saveFileFullPath) Edited September 28, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Makalele Posted September 28, 2008 Author Share Posted September 28, 2008 (edited) I think you need to do this (I'm not very confident with GDIPlus) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hMemDC) _GDIPlus_ImageSaveToFile ($hImage,$saveFileFullPath)good idea.. but it doesn't work. I got windows error when i used this. (And Exit code: -1073741819). Any another ideas ? Edited September 28, 2008 by Makalele Link to comment Share on other sites More sharing options...
bluelamp Posted September 28, 2008 Share Posted September 28, 2008 I hope you haven´t use the code as it is ? I think you have forget _GDIPlus_Startup() Link to comment Share on other sites More sharing options...
Makalele Posted September 28, 2008 Author Share Posted September 28, 2008 I hope you haven´t use the code as it is ? I think you have forget _GDIPlus_Startup() I created totally new function: Func PicFilter() $hBMP = _ScreenCapture_Capture ("", $FrameCoords[0], $FrameCoords[1]-8, $FrameCoords[2]-3, $FrameCoords[3]-4, False) $lX=0 $lY=0 _GDIPlus_Startup () $iWidth = _GDIPlus_ImageGetWidth($hBmp) $iHeight = _GDIPlus_ImageGetHeight($hBmp) $hPen = _GDIPlus_PenCreate(16777215,1,2) For $lY=1 to $iHeight For $lX=1 to $iWidth ;Problem Next Next _GDIPlus_ShutDown () EndFunc Problem: i don't know how to detect/change pixel's on bitmap >_< Link to comment Share on other sites More sharing options...
Makalele Posted September 29, 2008 Author Share Posted September 29, 2008 Still need a help. ~ Legal Bump ~ Link to comment Share on other sites More sharing options...
Makalele Posted September 30, 2008 Author Share Posted September 30, 2008 bump Link to comment Share on other sites More sharing options...
Malkey Posted October 1, 2008 Share Posted October 1, 2008 Hi all! I need to know how to FAST edit bmp file with changing some colors. (exactly change all pixel's to white without black and red color ((255,0,0) only). Any Ideas?Try this. When testing this script, Any colour which is not exactly red.(0xFF0000) or exactly black, (0x000000) was changed to white. expandcollapse popup#include <GDIPlus.au3> #include <WinAPI.au3> #include <GuiConstants.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile("E:\Imagebmp\3DeepWizard.bmp") ;<-- Enter Image file here Global $GuiSizeX = _GDIPlus_ImageGetWidth($hImage) Global $GuiSizeY = _GDIPlus_ImageGetHeight($hImage) $hGui = GUICreate("Change Colours", $GuiSizeX, $GuiSizeY) GUISetState() ; Create Double Buffer, so the doesn't need to be repainted on PAINT-Event $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGui) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY, $hGraphicGUI) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) ;End Double Buffer add-in 1 of 3 _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $GuiSizeX, $GuiSizeY) ; Create Double Buffer, so the doesn't need to be repainted on PAINT-Event GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3) GUIRegisterMsg(0x85, "MY_PAINT") ; $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize. _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) ;End Double Buffer add-in 2 of 3 ;Local $hBitmap = ImageColorToTransparent($hBMPBuff, 0, 0, $GuiSizeX, $GuiSizeY) Local $hBitmap = OtherColorsToWhite($hBMPBuff, 0, 0, $GuiSizeX, $GuiSizeY, 0xFF0000, 0x000000) _GDIPlus_ImageSaveToFile($hBitmap, @DesktopDir & "\TestWrite1.bmp") ; Transparency file ShellExecute(@DesktopDir & "\TestWrite1.bmp") ;_GDIPlus_ImageSaveToFile($hBitmap, @DesktopDir & "\TestWrite1.png") ; Transparency file ;ShellExecute(@DesktopDir & "\TestWrite1.png") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ;Func to redraw on PAINT MSG Func MY_PAINT($hWnd, $msg, $wParam, $lParam) ; Check, if the GUI with the Graphic should be repainted ; The sequencial order of these two commands is important. _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) _WinAPI_RedrawWindow($hGui, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ; , $RDW_ALLCHILDREN Return $GUI_RUNDEFMSG EndFunc ;==>MY_PAINT Func close() _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit EndFunc ;==>close Func OtherColorsToWhite($hImage2, $iStartPosX = 0, $iStartPosY = 0, $GuiSizeX = Default, $GuiSizeY = Default, $iColor1 = Default, $iColor2 = Default) Local $hBitmap1, $Reslt, $width, $height, $stride, $format, $Scan0, $v_Buffer, $v_Value, $iIW, $iIH $iIW = _GDIPlus_ImageGetWidth($hImage2) $iIH = _GDIPlus_ImageGetHeight($hImage2) If $GuiSizeX = Default Or $GuiSizeX > $iIW - $iStartPosX Then $GuiSizeX = $iIW - $iStartPosX If $GuiSizeY = Default Or $GuiSizeY > $iIH - $iStartPosY Then $GuiSizeY = $iIH - $iStartPosY $hBitmap1 = _GDIPlus_BitmapCloneArea($hImage2, $iStartPosX, $iStartPosY, $GuiSizeX, $GuiSizeY, $GDIP_PXF32ARGB) ProgressOn("Making a color Transparent", "The image is being processed.", "0 percent", -1, -1, 16) $Reslt = _GDIPlus_BitmapLockBits($hBitmap1, 0, 0, $GuiSizeX, $GuiSizeY, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") For $i = 0 To $GuiSizeX - 1 For $j = 0 To $GuiSizeY - 1 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $v_Value = DllStructGetData($v_Buffer, 1) If (Hex($v_Value, 6) = Hex($iColor1, 6)) Or (Hex($v_Value, 6) = Hex($iColor2, 6)) Then Else DllStructSetData($v_Buffer, 1, 0xFFFFFFFF) ; Sets to white EndIf Next ProgressSet(Int(100 * $i / ($GuiSizeX)), Int(100 * $i / ($GuiSizeX)) & " percent") Next _GDIPlus_BitmapUnlockBits($hBitmap1, $Reslt) ProgressOff() Return $hBitmap1 EndFunc ;==>OtherColorsToWhite Func ImageColorToTransparent($hImage2, $iStartPosX = 0, $iStartPosY = 0, $GuiSizeX = Default, $GuiSizeY = Default, $iColor = Default) Local $hBitmap1, $Reslt, $width, $height, $stride, $format, $Scan0, $v_Buffer, $v_Value, $iIW, $iIH $iIW = _GDIPlus_ImageGetWidth($hImage2) $iIH = _GDIPlus_ImageGetHeight($hImage2) If $GuiSizeX = Default Or $GuiSizeX > $iIW - $iStartPosX Then $GuiSizeX = $iIW - $iStartPosX If $GuiSizeY = Default Or $GuiSizeY > $iIH - $iStartPosY Then $GuiSizeY = $iIH - $iStartPosY $hBitmap1 = _GDIPlus_BitmapCloneArea($hImage2, $iStartPosX, $iStartPosY, $GuiSizeX, $GuiSizeY, $GDIP_PXF32ARGB) If $iColor = Default Then $iColor = GDIPlus_BitmapGetPixel($hBitmap1, 1, 1) ; Transparent color ProgressOn("Making a color Transparent", "The image is being processed.", "0 percent", -1, -1, 16) $Reslt = _GDIPlus_BitmapLockBits($hBitmap1, 0, 0, $GuiSizeX, $GuiSizeY, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") For $i = 0 To $GuiSizeX - 1 For $j = 0 To $GuiSizeY - 1 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $v_Value = DllStructGetData($v_Buffer, 1) If Hex($v_Value, 6) = Hex($iColor, 6) Then DllStructSetData($v_Buffer, 1, Hex($iColor, 6)) ; Sets Transparency here. Alpha Channel = 00, not written to. EndIf Next ProgressSet(Int(100 * $i / ($GuiSizeX)), Int(100 * $i / ($GuiSizeX)) & " percent") Next _GDIPlus_BitmapUnlockBits($hBitmap1, $Reslt) ProgressOff() Return $hBitmap1 EndFunc ;==>ImageColorToTransparent ;The GetPixel method gets the color of a specified pixel in this bitmap. Func GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) Local $tArgb, $pArgb, $aRet $tArgb = DllStructCreate("dword Argb") $pArgb = DllStructGetPtr($tArgb) $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "ptr", $pArgb) Return "0x" & Hex(DllStructGetData($tArgb, "Argb")) EndFunc ;==>GDIPlus_BitmapGetPixel Link to comment Share on other sites More sharing options...
Makalele Posted October 1, 2008 Author Share Posted October 1, 2008 Try this. When testing this script, Any colour which is not exactly red.(0xFF0000) or exactly black, (0x000000) was changed to white. expandcollapse popup#include <GDIPlus.au3> #include <WinAPI.au3> #include <GuiConstants.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile("E:\Imagebmp\3DeepWizard.bmp") ;<-- Enter Image file here Global $GuiSizeX = _GDIPlus_ImageGetWidth($hImage) Global $GuiSizeY = _GDIPlus_ImageGetHeight($hImage) $hGui = GUICreate("Change Colours", $GuiSizeX, $GuiSizeY) GUISetState() ; Create Double Buffer, so the doesn't need to be repainted on PAINT-Event $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGui) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY, $hGraphicGUI) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) ;End Double Buffer add-in 1 of 3 _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $GuiSizeX, $GuiSizeY) ; Create Double Buffer, so the doesn't need to be repainted on PAINT-Event GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3) GUIRegisterMsg(0x85, "MY_PAINT") ; $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize. _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) ;End Double Buffer add-in 2 of 3 ;Local $hBitmap = ImageColorToTransparent($hBMPBuff, 0, 0, $GuiSizeX, $GuiSizeY) Local $hBitmap = OtherColorsToWhite($hBMPBuff, 0, 0, $GuiSizeX, $GuiSizeY, 0xFF0000, 0x000000) _GDIPlus_ImageSaveToFile($hBitmap, @DesktopDir & "\TestWrite1.bmp") ; Transparency file ShellExecute(@DesktopDir & "\TestWrite1.bmp") ;_GDIPlus_ImageSaveToFile($hBitmap, @DesktopDir & "\TestWrite1.png") ; Transparency file ;ShellExecute(@DesktopDir & "\TestWrite1.png") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ;Func to redraw on PAINT MSG Func MY_PAINT($hWnd, $msg, $wParam, $lParam) ; Check, if the GUI with the Graphic should be repainted ; The sequencial order of these two commands is important. _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) _WinAPI_RedrawWindow($hGui, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ; , $RDW_ALLCHILDREN Return $GUI_RUNDEFMSG EndFunc ;==>MY_PAINT Func close() _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit EndFunc ;==>close Func OtherColorsToWhite($hImage2, $iStartPosX = 0, $iStartPosY = 0, $GuiSizeX = Default, $GuiSizeY = Default, $iColor1 = Default, $iColor2 = Default) Local $hBitmap1, $Reslt, $width, $height, $stride, $format, $Scan0, $v_Buffer, $v_Value, $iIW, $iIH $iIW = _GDIPlus_ImageGetWidth($hImage2) $iIH = _GDIPlus_ImageGetHeight($hImage2) If $GuiSizeX = Default Or $GuiSizeX > $iIW - $iStartPosX Then $GuiSizeX = $iIW - $iStartPosX If $GuiSizeY = Default Or $GuiSizeY > $iIH - $iStartPosY Then $GuiSizeY = $iIH - $iStartPosY $hBitmap1 = _GDIPlus_BitmapCloneArea($hImage2, $iStartPosX, $iStartPosY, $GuiSizeX, $GuiSizeY, $GDIP_PXF32ARGB) ProgressOn("Making a color Transparent", "The image is being processed.", "0 percent", -1, -1, 16) $Reslt = _GDIPlus_BitmapLockBits($hBitmap1, 0, 0, $GuiSizeX, $GuiSizeY, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") For $i = 0 To $GuiSizeX - 1 For $j = 0 To $GuiSizeY - 1 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $v_Value = DllStructGetData($v_Buffer, 1) If (Hex($v_Value, 6) = Hex($iColor1, 6)) Or (Hex($v_Value, 6) = Hex($iColor2, 6)) Then Else DllStructSetData($v_Buffer, 1, 0xFFFFFFFF) ; Sets to white EndIf Next ProgressSet(Int(100 * $i / ($GuiSizeX)), Int(100 * $i / ($GuiSizeX)) & " percent") Next _GDIPlus_BitmapUnlockBits($hBitmap1, $Reslt) ProgressOff() Return $hBitmap1 EndFunc ;==>OtherColorsToWhite Func ImageColorToTransparent($hImage2, $iStartPosX = 0, $iStartPosY = 0, $GuiSizeX = Default, $GuiSizeY = Default, $iColor = Default) Local $hBitmap1, $Reslt, $width, $height, $stride, $format, $Scan0, $v_Buffer, $v_Value, $iIW, $iIH $iIW = _GDIPlus_ImageGetWidth($hImage2) $iIH = _GDIPlus_ImageGetHeight($hImage2) If $GuiSizeX = Default Or $GuiSizeX > $iIW - $iStartPosX Then $GuiSizeX = $iIW - $iStartPosX If $GuiSizeY = Default Or $GuiSizeY > $iIH - $iStartPosY Then $GuiSizeY = $iIH - $iStartPosY $hBitmap1 = _GDIPlus_BitmapCloneArea($hImage2, $iStartPosX, $iStartPosY, $GuiSizeX, $GuiSizeY, $GDIP_PXF32ARGB) If $iColor = Default Then $iColor = GDIPlus_BitmapGetPixel($hBitmap1, 1, 1) ; Transparent color ProgressOn("Making a color Transparent", "The image is being processed.", "0 percent", -1, -1, 16) $Reslt = _GDIPlus_BitmapLockBits($hBitmap1, 0, 0, $GuiSizeX, $GuiSizeY, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") For $i = 0 To $GuiSizeX - 1 For $j = 0 To $GuiSizeY - 1 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $v_Value = DllStructGetData($v_Buffer, 1) If Hex($v_Value, 6) = Hex($iColor, 6) Then DllStructSetData($v_Buffer, 1, Hex($iColor, 6)) ; Sets Transparency here. Alpha Channel = 00, not written to. EndIf Next ProgressSet(Int(100 * $i / ($GuiSizeX)), Int(100 * $i / ($GuiSizeX)) & " percent") Next _GDIPlus_BitmapUnlockBits($hBitmap1, $Reslt) ProgressOff() Return $hBitmap1 EndFunc ;==>ImageColorToTransparent ;The GetPixel method gets the color of a specified pixel in this bitmap. Func GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) Local $tArgb, $pArgb, $aRet $tArgb = DllStructCreate("dword Argb") $pArgb = DllStructGetPtr($tArgb) $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "ptr", $pArgb) Return "0x" & Hex(DllStructGetData($tArgb, "Argb")) EndFunc ;==>GDIPlus_BitmapGetPixel Thanks a lot ! After some modifies It's fast and perfectly T/c >_< Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now