Miliardsto Posted December 19, 2018 Share Posted December 19, 2018 hello Im wondering if it is possible to process image in autoit like this 1. firstly there is colorfull wallpaper 2. Fill all colors (exception rose color) - with white 3. Fill rose color with black color I see Gdi functions have things to manipulate images https://imgur.com/a/lFdY26g Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2018 Moderators Share Posted December 19, 2018 Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states: Quote Share your cool AutoIt scripts, UDFs and applications with others. Do not post general support questions here, instead use the AutoIt Help and Support forums. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Nine Posted December 19, 2018 Share Posted December 19, 2018 Look at _GDIPlus_BitmapGetPixel in the autoit help file. It is pretty much all you need in there. You will need to adjust the, lets call it, filter. And you will need to read a file instead of a screencapture. This one easy way to do it, among other solutions. Good scripting ! “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
InnI Posted December 19, 2018 Share Posted December 19, 2018 expandcollapse popup#include <GDIPlus.au3> ; base color 0xFF0080 (255,0,128) Global $iBaseR = 255, $iBaseG = 0, $iBaseB = 128 ; shade-variation (0-255) Global $iVary = 107 ; color to change base color Global $iChangeBaseColor = 0x000000 ; color to change other colors Global $iChangeOtherColor = 0xFFFFFF Global $sSourceFile = "1.jpg" Global $sDestFile = "2.jpg" SplashTextOn("", "Processing...", 300, 100, Default, Default, 33) _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sSourceFile) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $tBits = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD)) $iScan0 = DllStructGetData($tBits, "Scan0") $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0) For $iY = 0 To $iH - 1 $iOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 $iColor = DllStructGetData($tPixel, 1, $iOffset + $iX) $iR = BitAND(BitShift($iColor, 16), 0xFF) $iG = BitAND(BitShift($iColor, 8), 0xFF) $iB = BitAND($iColor, 0xFF) If $iR > $iBaseR - $iVary And $iR < $iBaseR + $iVary _ And $iG > $iBaseG - $iVary And $iG < $iBaseG + $iVary _ And $iB > $iBaseB - $iVary And $iB < $iBaseB + $iVary Then DllStructSetData($tPixel, 1, $iChangeBaseColor, $iOffset + $iX) Else DllStructSetData($tPixel, 1, $iChangeOtherColor, $iOffset + $iX) EndIf Next Next _GDIPlus_BitmapUnlockBits($hImage, $tBits) _GDIPlus_ImageSaveToFile($hImage, $sDestFile) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() SplashOff() ShellExecute($sDestFile) Link to comment Share on other sites More sharing options...
Nine Posted December 19, 2018 Share Posted December 19, 2018 Or you can wait for someone to write it for you “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
qwert Posted December 19, 2018 Share Posted December 19, 2018 @Innl: that's a nifty script. But while it's fresh on your mind, can you add just a few comments. For example, the statements for Lock and Unlock Bits are not familiar to most of us. Thanks for the script. Link to comment Share on other sites More sharing options...
UEZ Posted December 19, 2018 Share Posted December 19, 2018 Check this out (example is from help file but modified appropriately): expandcollapse popup;coded by UEZ #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sFile = "C:\Temp\Ballons_364x227.png" If Not FileExists($sFile) Then MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30) Return False EndIf _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) ;create an image object based on a file If @error Then _GDIPlus_Shutdown() MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "An error has occured - unable to load image!", 30) Return False EndIf Local $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) ;get width and height of the image Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iW, $iH) Local $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iW, $iH, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;locks a portion of a bitmap for reading and writing. More infor at http://msdn.microsoft.com/en-us/library/windows/desktop/ms536298(v=vs.85).aspx Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") ;get scan0 (pixel data) from locked bitmap Local $tPixel = DllStructCreate("int argb[" & $iW * $iH & "];", $iScan0) Local $iRGBA, $iRowOffset, $aHSL For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 ;get each pixel in each line and row $iRGBA = DllStructGetData($tPixel, 1, $iRowOffset + $iX) $aHSL = RGB2HSL($iRGBA) ;convert color to HSL color space ;check if HSL color is in the red / purple range -> see http://hslpicker.com for details If ($aHSL[0] < 30 And InRange(Round(100 * $aHSL[1]), 100) And InRange(Round(100 * $aHSL[2]), 50)) Or _ ($aHSL[0] > 300 And InRange(Round(100 * $aHSL[1]), 100) And InRange(Round(100 * $aHSL[2]), 50)) Then DllStructSetData($tPixel, 1, 0xFFFFFFFF, $iRowOffset + $iX) ;if yes then set white pixel Else DllStructSetData($tPixel, 1, 0xFF000000, $iRowOffset + $iX) ;else black pixel EndIf Next Next _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) ;unlocks a portion of a bitmap that was locked by _GDIPlus_BitmapLockBits ;display manipulated image Local $hGUI = GUICreate("_GDIPlus_BitmapLockBits Demo", $iW, $iH) GUISetState(@SW_SHOW) Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a Graphics object from a window handle _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH) ;copy manipulated image to graphics handle Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ;cleanup resources _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example Func InRange($iNumber, $iRange, $iPlus = 25, $iMinus = 25) If $iNumber > ($iRange - $iMinus) And $iNumber < ($iRange + $iPlus) Then Return 1 Return 0 EndFunc Func RGB2HSL($iColor) Local $r = BitAND(BitShift($iColor, 16), 255) / 255, $g = BitAND(BitShift($iColor, 8), 255) / 255, $b = BitAND($iColor, 255) / 255 Local $Cmax = Max(Max($r, $g), $b), $Cmin = Min(Min($r, $g), $b), $deltaChroma = $Cmax - $Cmin Local $L = ($Cmin + $Cmax) / 2, $H, $S If $deltaChroma = 0 Then $H = 0 $S = 0 Else $S = $deltaChroma / (1 - Abs(2 * $L - 1)) If $r = $Cmax Then ;r is max $H = Mod(($g - $b) / $deltaChroma, 6) ElseIf $g = $Cmax Then ;g is max $H = ($b - $r) / $deltaChroma + 2 Else ;else b is max $H = ($r - $g) / $deltaChroma + 4 EndIf $H *= 60 If $H < 0 Then $H += 360 EndIf Local $aHSL[3] = [$H, $S, $L] Return $aHSL EndFunc Func Min($a, $b) Return ($a < $b) ? $a : $b EndFunc Func Max($a, $b) Return ($a > $b) ? $a : $b EndFunc Replace $sFile with proper path to the image before you run the script! Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
qwert Posted December 20, 2018 Share Posted December 20, 2018 @UEZ: thanks for that annotated variation. I now have plenty to look at for a few days. I'm still determined to have a tunable script than can render a monochome result. This looks promising. Link to comment Share on other sites More sharing options...
UEZ Posted December 20, 2018 Share Posted December 20, 2018 8 hours ago, qwert said: @UEZ: thanks for that annotated variation. I now have plenty to look at for a few days. I'm still determined to have a tunable script than can render a monochome result. This looks promising. Have a look to There is a function called _GDIPlus_BlackAndWhite() which can convert an image to b/w aka monochrom. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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