jvds
Active Members-
Posts
131 -
Joined
-
Last visited
jvds's Achievements
Adventurer (3/7)
10
Reputation
-
Rurorita reacted to a post in a topic: Making a control invisible?
-
jvds reacted to a post in a topic: _ChangeWallpaper() Func
-
i had a problem with this also with a .bat script (that was run as admin), i think it was Win7, and i didn't look deep into it, i just did it like this, reset to dhcp then set ip and i worked. netsh interface ipv4 set address "Local Area Connection" dhcp netsh interface ipv4 add address "Local Area Connection" 192.168.1.44 255.255.255.0 192.168.1.1 pause also look in the advanced options in the internet protocol version4 tcpip properties, there you can add several IP addresses to the same network card, look if the IP addresses you are trying to add aren't already in the list, in my case they where not strangely, also it seems according to the console writes you posted that they are already added to the interface, so let know what you see there.
-
I want to take some images and bring their bits down from 32 bits to 8bits(256 colors) and 4 bits (16 colors) searching around for color data, it was easy to get the 4 bits color data and to add it to an array and use the color table $aColorTable= stringsplit('0-8388608-16711680-16711935-32896-32768-65280-65535-128-8388736-255-12632256-8421504-8421376-16776960-16777215','-',3) ; Create color table from an array of colors Local $tColorTable = _WinAPI_CreateDIBColorTable($aColorTable) ; Create 8 bits-per-pixel device-independent bitmap (DIB) and retrieve a pointer to the location of its bit values $hBitmap = _WinAPI_CreateDIB($iWidth, $iHeight, 4, $tColorTable, 16) the result is the same as if i take mspaint load any image and save as 16 colors(4bits) however with the 256 color or 8 bit the data i found are not the same, there are multiple color tables i tested, the colors are off, i even found some scripts in the forum that generate 8 bit color tables but the colors are also off, they are not the same as if i take mspaint and save an image as 256 colors, if done with mspaint the colors are very acculturate, i thought well maybe get the color table from an 8 bit image i have that was done with mspaint, but im not sure how to do that, below i tried something but not sure if it gets the table and i don't know how to get the table to an array #include <WinAPIGdi.au3> #include <WinAPIRes.au3> Global $hBitmap = _WinAPI_LoadImage(0, 'D:\spectrum256.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE+$LR_CREATEDIBSECTION ) Local $tSIZE = _WinAPI_GetBitmapDimension($hBitmap) Local $iWidth = DllStructGetData($tSIZE, 'X') Local $iHeight = DllStructGetData($tSIZE, 'Y') ConsoleWrite('size= '&$iWidth&' '&$iHeight&@CRLF) $table = _WinAPI_GetDIBColorTable ( $hBitmap) ConsoleWrite(' Error '&@error & @CRLF) ConsoleWrite(' Extended '&@extended & @CRLF) ;_WinAPI_GetDIBits?
- 1 reply
-
- _winapi_createdibcolortable
- _winapi_createdib
- (and 1 more)
-
Thanks!
-
jvds reacted to a post in a topic: context menu freeze loop
-
I want to create a context menu that does not freeze the script while the menu is open, is that possible?, here is a modified sample script, when the menu is open the loop is stuck #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI Context Menu", 300, 200) Local $idContextmenu = GUICtrlCreateContextMenu() Local $idNewsubmenu = GUICtrlCreateMenu("new", $idContextmenu) Local $idNewsubmenuText = GUICtrlCreateMenuItem("text", $idNewsubmenu) Local $idButton = GUICtrlCreateButton("OK", 100, 100, 70, 20) Local $idButtoncontext = GUICtrlCreateContextMenu($idButton) Local $idMenuAbout = GUICtrlCreateMenuItem("About button", $idButtoncontext) Local $idMenuOpen = GUICtrlCreateMenuItem("Open", $idContextmenu) Local $idMenuSave = GUICtrlCreateMenuItem("Save", $idContextmenu) GUICtrlCreateMenuItem("", $idContextmenu) ; separator Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $idContextmenu) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton MsgBox($MB_SYSTEMMODAL, "Button Clicked", 'OK') Case $idMenuAbout MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'About') Case $idMenuOpen MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Open') Case $idMenuSave MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Save') Case $idMenuInfo MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Info') Case $idNewsubmenuText MsgBox($MB_SYSTEMMODAL, "SubMenu Selected", 'Text') EndSwitch sleep(1000) ConsoleWrite('test loop'&@CRLF) WEnd GUIDelete() EndFunc ;==>Example
-
try koda if you have scite installed, press alt+m there you can create buttons, labels etc. and lock them to the top left or where ever you want, or even resize with the gui, then you can run the form with f10, test , close adjust, F10 and test again, until you have the flags that work for you, then copy the flags to your button, label or any other control
-
WINAPI DRAWSTATE with HBITMAP and DSS_DISABLED
jvds replied to kurtykurtyboy's topic in AutoIt GUI Help and Support
i don't think it will work, was looking in to that my self a time ago, it grays the whole image out all details are gone i ended up creating a bitmap gray scale for my disabled item and a color one for enabled item, then switch displaying between the 2, there may be smarter ways but didn't dive to deep in to it, here is your example modified to display autoit example folders images #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIEx.au3> #include <GDIPlus.au3> Global Const $DST_ICON = 0x03 Global Const $DST_BITMAP = 0x04 Global Const $DSS_NORMAL = 0x00 Global Const $DSS_UNION = 0x10 Global Const $DSS_DISABLED = 0x20 Global Const $DSS_MONO = 0x80 Example() Func Example() _GDIPlus_Startup() ;initialize GDI+ ;~ $hBitmap = _GDIPlus_BitmapCreateFromFile ( @ProgramFilesDir &'\AutoIt3\Examples\GUI\Advanced\Images\blue.bmp' ) ;~ $hBitmap = _GDIPlus_BitmapCreateFromFile ( @ProgramFilesDir &'\AutoIt3\Examples\GUI\logo4.gif' ) $hBitmap = _GDIPlus_BitmapCreateFromFile(@ProgramFilesDir & '\AutoIt3\Examples\GUI\torus.png') $hClone = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, 80, 80, $GDIP_PXF04INDEXED ) ;unfortinately $GDIP_PXF16GRAYSCALE does not work, set the correct size of image or get it with _GDIPlus_ImageGetHeight/width $hHBitmaphClone = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClone) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;Create HBitmap from Bitmap _GDIPlus_BitmapDispose($hBitmap) ;dispose the bitmap ;create GUI Local $hGUI = GUICreate("DrawState Bitmap Test", 350, 250) GUISetState(@SW_SHOW, $hGUI) $hDC = _WinAPI_GetDC($hGUI) ;*** draws bitmap OK but with black border GUICtrlCreateLabel("Bitmap DrawState Normal", 5, 10) _WinAPI_DrawState($hDC, 0, $hHBitmap, 5, 30, 80, 80, BitOR($DST_BITMAP, $DSS_NORMAL)) ;set size correcly not 80 80 ;*** draws bitmap as a gray box GUICtrlCreateLabel("Bitmap DrawState Disabled", 150, 10) _WinAPI_DrawState($hDC, 0, $hHBitmap, 150, 30, 80, 80, BitOR($DST_BITMAP, $DSS_DISABLED)) ;*** draws bitmap OK but with black border GUICtrlCreateLabel("Bitmap DrawState Normal", 5, 130) _WinAPI_DrawState($hDC, 0, $hHBitmaphClone, 5, 150, 80, 80, BitOR($DST_BITMAP, $DSS_NORMAL)) ;set intended size of images not 80 80 ;*** draws bitmap as a gray box GUICtrlCreateLabel("Bitmap DrawState Disabled", 150, 130) _WinAPI_DrawState($hDC, 0, $hHBitmaphClone, 150, 150, 80, 80, BitOR($DST_BITMAP, $DSS_DISABLED)) ;Sorry didnt I dit not clean up! _GDIPlus_Shutdown() Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example ;From funkey Func _WinAPI_DrawState($hDC, $hBrush, $lData, $x, $y, $w, $h, $iFlags) Local $aRet = DllCall("User32.dll", "BOOL", "DrawState", "handle", $hDC, "handle", $hBrush, "ptr", 0, "long", $lData, "long", 0, _ "int", $x, "int", $y, "int", $w, "int", $h, "UINT", $iFlags) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc ;==>_WinAPI_DrawState -
WJAMET reacted to a post in a topic: [Solved] My autoit script not work in some computer
-
[Solved] My autoit script not work in some computer
jvds replied to WJAMET's topic in AutoIt General Help and Support
$Form = GUICreate("Rpi-Utility", 437, 315, 2415, 365) isnt your window outside the field of view on the other computer? maybe you can try $Form = GUICreate("Rpi-Utility", 437, 315, -1,-1) -
you could connect to its port to see if it is open ConsoleWrite(@CR) ConsoleWrite(IpPortTest(@IPAddress1,21)&@CR) ConsoleWrite(IpPortTest(@IPAddress1,139)&@CR) ConsoleWrite(IpPortTest('192.168.100.300',21)&@CR) ConsoleWrite(IpPortTest(@IPAddress1,'tAsd')&@CR&@CR) func IpPortTest($ip,$port) TCPStartup() $socket = TCPConnect($ip,$port) $error = @error if $error then if $error = 10060 then Return 'Error : Connection timed out on ip:'&$ip&', port:'&$port if $error = 1 then Return '!Error : IPAddr: '&$ip&' is incorrect.' if $error = 2 then Return '!Error : port: '&$port&' is incorrect.' if $error = -2 then Return 'not connected.'; not sure when this one will trigger, no network conection? Else TCPCloseSocket($socket) Return '+Port:'&$port&' is open on IPAddr: '&$ip&' socket:'&$socket EndIf TCPShutdown() EndFunc
-
Create different labels within a For Loop
jvds replied to Silas's topic in AutoIt General Help and Support
how about _arraypush?, just _arraypush the new values in to the array and rewrite the labels from the array in the help file is an example of _arraypush -
Palmmodify reacted to a post in a topic: Xor and image, problem rebuilding image
-
#include <Memory.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> AutoItSetOption("GUIOnEventMode", 1) ;~ $BitCount = 4 $BitCount = 8 ;~ $BitCount = 16 $Width = 500 $Height = 500 Local $ptrbmp, $DibHandle, $DibPre_Obj $BitmapBB1 = _CreateNewDIB_Bitmap($Width, $Height, $BitCount, $ptrbmp, $DibHandle, $DibPre_Obj) Local $ptrbmp2, $DibHandle2, $DibPre_Obj2 $BitmapBB2 = _CreateNewDIB_Bitmap($Width, $Height, $BitCount, $ptrbmp2, $DibHandle2, $DibPre_Obj2) Local $ptrbmp3, $DibHandle3, $DibPre_Obj3 $BitmapBB3 = _CreateNewDIB_Bitmap($Width, $Height, $BitCount, $ptrbmp3, $DibHandle3, $DibPre_Obj3) $Form = GUICreate("GUI", $Width, $Height, -1, -1) $Pic = GUICtrlCreatePic("", 5, 5, $Width, $Height) GUICtrlSetResizing($Pic, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") Local $hWnd = _WinAPI_GetDesktopWindow() Local $hDDC = _WinAPI_GetDC($hWnd) $hCtrl = GUICtrlGetHandle($Pic) $hGUI_DC = _WinAPI_GetDC($hCtrl) _GDIPlus_Startup() While 1 _WinAPI_BitBlt($BitmapBB2, 0, 0, $Width, $Height, $BitmapBB1, 0, 0, $SRCCOPY) ;buffer of olf image to xor from _WinAPI_BitBlt($BitmapBB1, 0, 0, $Width, $Height, $hDDC, 0, 0, $SRCCOPY) ;get the mew image _WinAPI_BitBlt($BitmapBB2, 0, 0, $Width, $Height, $BitmapBB1, 0, 0, $SRCINVERT);Xor Old and New image ;save image to stream or file as png format $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($DibHandle2) If @error Then ConsoleWrite('_GDIPlus_BitmapCreateFromHBITMAP Failed') $BitmapStream = _GDIPlus_StreamImage2BinaryString($hBitmap, "PNG",100) If @error Then ConsoleWrite('_GDIPlus_StreamImage2BinaryString Failed') _GDIPlus_BitmapDispose($hBitmap) ;######################################################################################### ;Load image from stream or file Local $hHBITMAP $hHBITMAP = _GDIPlus_BitmapCreateFromMemory($BitmapStream, True) If @error Then ConsoleWrite('_GDIPlus_BitmapCreateFromMemory Failed') Local $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hGUI_DC) Local $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBITMAP) _WinAPI_BitBlt($BitmapBB3, 0, 0, $Width, $Height, $hDC_backbuffer, 0, 0, $SRCINVERT) ;xor image existing image _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBITMAP) sleep(100) ;~ _WinAPI_BitBlt($hGUI_DC, 0, 0, $Width, $Height, $BitmapBB2, 0, 0, $SRCCOPY) ;see Xored img before saved to file or stream ;~ _WinAPI_BitBlt($hGUI_DC, 0, 0, $Width, $Height, $BitmapBB1, 0, 0, $SRCCOPY) ;see New image before it is xored and saved _WinAPI_BitBlt($hGUI_DC, 0, 0, $Width, $Height, $BitmapBB3, 0, 0, $SRCCOPY) ;image xor chain? WEnd Func _Exit() _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit Func _GDIPlus_StreamImage2BinaryString($hBitmap, $sFormat = "JPG", $iQuality = 80, $bSave = False, $sFilename = @ScriptDir & "\Converted.jpg") ;coded by UEZ 2013 build 2014-01-25; based on the code by Andreik $lastfunc = '_GDIPlus_StreamImage2BinaryString' Local $sImgCLSID, $tGUID, $tParams, $tData Switch $sFormat Case "JPG" $sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat) $tGUID = _WinAPI_GUIDFromString($sImgCLSID) $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $iQuality) ;quality 0-100 Local $pData = DllStructGetPtr($tData) $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) Case "PNG", "BMP", "GIF", "TIF" $sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat) $tGUID = _WinAPI_GUIDFromString($sImgCLSID) Case Else Return SetError(1, 0, 0) EndSwitch Local $hStream = _WinAPI_CreateStreamOnHGlobal() ;http://msdn.microsoft.com/en-us/library/ms864401.aspx If @error Then Return SetError(2, 0, 0) _GDIPlus_ImageSaveToStream($hBitmap, $hStream, DllStructGetPtr($tGUID), DllStructGetPtr($tParams)) If @error Then Return SetError(3, 0, 0) Local $hMemory = _WinAPI_GetHGlobalFromStream($hStream) ;http://msdn.microsoft.com/en-us/library/aa911736.aspx If @error Then Return SetError(4, 0, 0) Local $iMemSize = _MemGlobalSize($hMemory) If Not $iMemSize Then Return SetError(5, 0, 0) Local $pMem = _MemGlobalLock($hMemory) $tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem) Local $bData = DllStructGetData($tData, 1) _WinAPI_ReleaseStream($hStream) ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221473(v=vs.85).aspx _MemGlobalFree($hMemory) If $bSave Then Local $hFile = FileOpen($sFilename, 18) If @error Then Return SetError(6, 0, $bData) FileWrite($hFile, $bData) FileClose($hFile) EndIf Return $bData EndFunc ;==>_GDIPlus_StreamImage2BinaryString Func _CreateNewDIB_Bitmap($Width, $Height, $BitCount, ByRef $ptrbmp, ByRef $DibHandle, ByRef $DibPre_Obj) Local $tBITMAPINFO = DllStructCreate("dword Size; long Width; long Height; word Planes; word BitCount; dword Compression; dword SizeImage; long XPelsPerMeter; long YPelsPerMeter; dword ClrUsed; dword ClrImportant; dword RGBQuad[256];") DllStructSetData($tBITMAPINFO, 'Size', 40) DllStructSetData($tBITMAPINFO, 'Width', $Width) DllStructSetData($tBITMAPINFO, 'Height', -$Height) DllStructSetData($tBITMAPINFO, 'Planes', 1) DllStructSetData($tBITMAPINFO, 'BitCount', $BitCount) Local $iColorCnt = BitShift(1, -$BitCount) DllStructSetData($tBITMAPINFO, 'ClrUsed', $iColorCnt) DllStructSetData($tBITMAPINFO, 'ClrImportant', $iColorCnt) ;https://www.autoitscript.com/forum/topic/139174-gdi-cc-code-to-autoit-conversion/ Switch $BitCount Case 1 DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift(0xFF, -16), BitShift(0xFF, -8), 0xFF), 1) ;~ Case 4 ;~ Local $aCol[16] = [8, 24, 38, 56, 72, 88, 104, 120, 136, 152, 168, 184, 210, 216, 232, 248] ;~ For $i = 0 To 15 ;~ DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift($aCol[$i], -16), BitShift($aCol[$i], -8), $aCol[$i]), $i + 1) ;~ Next Case 4 Local $aCol[16] = [16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 216, 232, 248] For $i = 0 To 15 DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift($aCol[$i], -16), BitShift($aCol[$i], -8), $aCol[$i]), $i + 1) Next ;~ Case 8 ;~ ; Windows reserves first color for white, ;~ DllStructSetData($tBITMAPINFO, 'RGBQuad', 255, 1) ;~ ; and last color as black! ;~ DllStructSetData($tBITMAPINFO, 'RGBQuad', 0, 255) ;~ Local $iColor = 10 ;~ For $i = 20 To $iColorCnt - 22 ;first 20 and last 20 are reserved! ;~ DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift($i, -16), BitShift($i, -8), $i * $iColor), $i + 1) ;~ Next Case 8 ;~ ; Windows reserves first color for white, ;~ $tBITMAPINFO.RGBQuad((0)) = 0xFFFFFF ;~ ; and last color as black! ;~ $tBITMAPINFO.RGBQuad((0xFF)) = 0x000000 Local $iColor = 20, $iRed, $iGreen, $iBlue For $iRed = 0 To 255 Step 51 For $iGreen = 0 To 255 Step 51 For $iBlue = 0 To 255 Step 51 $tBITMAPINFO.RGBQuad(($iColor)) = BitShift($iRed, -16) + BitShift($iGreen, -8) + $iBlue $iColor += 1 Next Next Next EndSwitch Local $hDC = _WinAPI_CreateCompatibleDC(0) $DibHandle = _WinAPI_CreateDIBSection(0, $tBITMAPINFO, $DIB_RGB_COLORS, $ptrbmp) $DibPre_Obj = _WinAPI_SelectObject($hDC, $DibHandle) Return $hDC EndFunc ;==>_CreateNewDIB_Bitmap oh great, I edited my post and messed it up. lost all i wrote before. basically my problem is when i Xor and image with $SRCINVERT and _WinAPI_BitBlt, and save the image in stream or file, after i load or rebuild the image, i get color problems, this only happens with 8 bits, other bits work just fine. i'm not sure if the color structure i'm using is the problem, or if i need to save or rebuild the 8 bits image differently. im stuck
-
8 bit png stored as binary string in script
jvds replied to jvds's topic in AutoIt General Help and Support
Thanks UEZ!, i was doing it all wrong!! -
Cant get this to work, i want to HBITMAP_To_Bytes an 8bit png image and store it as binary string in the script, then xor or invert it with another image later on but i cant get it to even show up on gui, i also tried an example image but no luck, not even an example gif image i got from the forum #include <GDIPlus.au3> #include <ScreenCapture.au3> #include <Memory.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> AutoItSetOption("GUIOnEventMode", 1) $Width = @DesktopWidth / 2 $Height = @DesktopHeight / 2 $Form = GUICreate("GUI", $Width, $Height, -1, -1, $WS_MINIMIZEBOX+ $WS_CAPTION+ $WS_POPUP+ $WS_SYSMENU+$WS_SIZEBOX) $Pic = GUICtrlCreatePic("", 0, 0, 255, 255) GUICtrlSetResizing($Pic, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM) GUISetState(@SW_SHOW) $hCtrl = GUICtrlGetHandle($Pic) ;get the $Pic ctrl handle $hGUI_DC = _WinAPI_GetDC($hCtrl) Local $hWnd = _WinAPI_GetDesktopWindow() Local $hDDC = _WinAPI_GetDC($hWnd) Local $Bmp_DibHandle Local $Bmp_DibHandleObj Local $Bmp_ptr Local $Bmp_Buffer = _CreateNewDIB_Bitmap(100, 100,8,$Bmp_ptr,$Bmp_DibHandle,$Bmp_DibHandleObj) _WinAPI_SetStretchBltMode($Bmp_Buffer, $COLORONCOLOR) Local $sBinGIFImage = '0x47494638396144004700F70000FFFFFF1831711C357D182D6D1C3982182D691C35791C3986CACACA1831751C3D9614246118316D14286914357D1835791C398A183575204192142D65C2C2C2BE9296142459203D92AEAAAEC69A9AB2B2B6BAB6B6CACACEBEAA41142D7520398A395D9618358614317DA29E9E1028751C3D8A0C2455797979A27D7918316941699ECEA2A23D4955101C4955595961656100041C86828214358E182861B6A23DEBEBEBBEBEBE142D71E7B2B220419EB28E8E10246D2D3959DFA6AA10245D8E8A8EA29641696969CAB241202D49082065C6C6CA0C1C516165556979927D61616186B2183179AAAAAAC6C6C2969296DBDBDF243D718A71712031591C3582DFAEAE8E7D86A2A6A6314579866969AA828214285D20316910246592928E1031860410353D5D92F3F3F328499A14399A14203D3539497D754986868E0C2059A28282E3E3E3081024AE9A3D967171454545355992494D61AE8A8E7175797D869ED7A2A26555554D4D51B69296DBD7D7394969928A4D555D65D7A6AA8A7D39142855CAA6AA203982EBCACE5D6569AE9A359E9E9E715959183161B6C2DF5186C22D4169928A55414965BABABE615971AE9E9E0C18394559755979AAEBE3DF31498A5179A22439694159A6313128A6964D9EAABEDFBABE314982514924081849495565A696396969610C287D4535352035719682867171557171694571A64D5D861C3D92D2BE41514141DBCACAEFB6BA49393D24459A315586394561082471C6B649614D55B6AA5D1C2D59BE969A3D49717D7959614949CAB2AE514139244186E3C6CAF3EFEB756935797965867D55595D4561758AFBBEC23D659A1C357161551CBAAA49413D456D798A7D8282617DA2141C35000C2820283D24418A79753DE3DFDB24395D9692695D6986283965B2B2B23559968A8279FBFBEF8692AEEFD74D516D96C6B6559A8E45353541A69E5D82615D967D79454531D2BE4D92864561869E14244D554D456D6555393D555D61613159A6B286867592B29E8A351C316DF7FBFBFFC6C665757D1C397D555D7DCECACA1C3979182D71BEC2CE4539206D611C866561FFFFFF21F904010000FF002C00000000440047000008FF00FF091C48B0A0C18308132A5CC8B0A1C38710233E74674CA2C58B08C5E4B8900F16C68F1651697C152011C8930E977DD3A6F100CA970BC5C9C92166D92431307316540149C2AB1CDE64EA1CFA2FDA87483968CE01878E684E246A7E591A9369DBBE664E5F669254E357264BD3BAE2819715243C0A3FAA90DA45CF519518562894FDA8A451851E3DA8E0C0DBA34D3D25733156A0A32990AFC281FED02115F862333AACE6593A24F550183EB71A5BAC42C7579843785A1D7A52435306249A1F12BB1567452B568134E10864184706478C5333248645C70A3E545A151BDE8A' $sBinGIFImage &= '0F9F0C59C645D2BD70CE381D192A00C7419DCA0AE851A200669E905B1B1D59A264FFD171A7C29D3869B0544893663BF7834AD2E878A7AE1096FB5892D4D185FCC77B8555E8E0883AAEF0B2CA81AE8812C31F59CCF15F4255E013060241ACE2CA856E7451430DBBA0F6E0418CFC5243183570D0055C4F90D855261F1AC44D586AE0F1C4346AA8F1C41378C818A3832D0E840D1E1C144101214EFC10430C4E60C0880D08E063458F0229C10436D830614A21B75041051F59D47186154C6060857B1FCE51A413419CB0CB1F155470CB1F8EB473C20F3F10D2548F679C70423B31E0C301051B6CC008051CD810449A319C01A529EDB8C00C0708441A24A44D3212840B413003252EE198B2411191861AAA9056B4C303253D9E3204343130C108A8A246FF4A81065604F185212DBA13CB258F04E1043636C03A2A234CFCA0CC1A5FE4F3E03DB598334B1F6EC44008B0C2526003064E9832C4140494100D18DCF522432DDD74534D19A074C1C4061414E1AE0DD88C10831B054860EF0507BC919A0AD1C880CA37D598730509653033EDA0D6128BE6B6537C7081BD074CD258360294708135937821483B32D8F282BA1BD8400123D8101283324B8883CB14164B700104F69C52960A0F5C60732A1008E0413E071C50C60907DBB001B62E4C708F399E784080C33643207156BD9470EF070404208F008094F0801D203342EB093CC8608A397AA4B0440810A4F28A045364E3943153D82B412A5E3CD04002F6007240098604FF31ED06D83861C703105C318B10476CB1C726D5D4A3C0058038958FD46B07014A0A2CE0220001807C00010F3160808D152FC853C20121E4A20A382C60924C300AACDDF650F55CA1B602F5D4D2411FEB94620FE77B2F01C70818FCC043CF3D8B20CCEE8360E2F0BDBDE8D40C2EA9DC1B0D208B00B345289BEBBD770A273001C7143D0302880022E4314C1F1D4002814F1240103D4C9BBC7F2F014B7051C60D09189037F221488420187000F3018200F610C0120AE086580822040FB3D71440F01228340010AF78C5053E20007DF8410AFA08C0037EE73DADF9E0000448E10113688014A4C30709C89A4F2E20002D80EB24D780C11A5A6080541CC00033184201FF18C0800808200421F0DE01A7600F6EA590850C68413A182000089460028F58C31A6E884318E8900706F0C0AA0650800124E00182B84212CD470001B8F1776D34C00306E087474CE0015080C61A74C8459424E20BCEE045387CD0023F04A000050880084C910C35AED08D6E4CA1000C60802D68E11146B0052F44B10632F4112588384521508002657CA100FA2840031409095528220492A42424DD28823DB8800B8F20C328DB0087ACB4860A7480430306708D44DC2014B998C52C1E294B01E4037DA1D0830B88900E72E0E0388A220A12B290811564200EF220A6191251' $sBinGIFImage &= '8A0ECC2219BF73A32C45100C458002141D580711E0E0CD1554801CA81A0A12DE91FF810CD4E116A318C004A4C1860E744008C110813A2949497B2842151DA0011086D18834446105B7408153908002D69021035018400358400321084118906428431F600045449406D2684414D8B18238A0603943B1863FB2F38524E0A2003358C0223CE10903A4F4014865E812842104894A610FEC18421AFC5108A750A20E3B8506341800542D34C0032260E94A2380D40788E00542D0831ED8C0834E7CA10EE4488237B2428946D022099C40A416B45080049075AC11202B4BDBF182048C420F7048072D0AA18BB9CEC50EC0E0C43576E003BE06E0AF728C4002361BD80878C00309F040256231047570E21E8808CC30E2818C3E9881053E48A45FCBBAD900FF6CF6B6B5D5470386800C7E78642E8860413FFAF00970B821B60CB02D529790800038D7B9B7752E5787C08974FC762E9740C627CEB10534F035B99BBD022E3C10007DDCE0B9CF256201A4A08E4E5C372B60E0871DCC30081E547688B6F5401E30510912546211E7452F03C8A88572E432302A4807170A60063BA0C102654CAE7E69908B2300C11301962E570B5060673C2230C630C1041A90026A5800C22918803E46E10920B08106A5B80111931B00F572D80816480788455C8009CCC0027C2D803C4A01840EB0E1C87990F18C67ACD774580057733184052640E519F821C80CA8C41ECC70641A80A312FA604098990CD47418410B08DEEB0C66A0852B237269C0B258041BCE710433B840C9649E409BAFA002CDC0020A50D0420BA6FCE61BC0810D89D8C10EE4B1641B4FC0022A482D734E01060BC416913758443B1AA0CA05AC79060D6840507D9082147C48056F28B53C183D80141862132088B5AC63FD069941E9D6B84E484000003B' Binary($sBinGIFImage) ;TEst x Local $Bmp_Buffer2 = _WinAPI_CreateCompatibleDC(0) $hHBITMAP = Load_BMP_From_Mem($sBinGIFImage, True) _WinAPI_SelectObject($Bmp_Buffer2, $hHBITMAP) ;Test y Local $hBitmap = _GDIPlus_BitmapCreateFromMemory($sBinGIFImage) ;load binary saved GIF image and convert it to GDI+ bitmap format ;ok now what, how do i get it to be gdi bitmap so i can _WinAPI_BitBlt it? _WinAPI_BitBlt($Bmp_Buffer, 0, 0, $Width, $Height, $Bmp_Buffer2, 0, 0,$NOTSRCCOPY ) ;Invert color _WinAPI_BitBlt($Bmp_Buffer, 0, 0, $Width, $Height, $Bmp_Buffer, 0, 0,$SRCINVERT) ;Invert color _WinAPI_BitBlt($hGUI_DC, 0, 0, $Width, $Height, $Bmp_Buffer, 0, 0,$SRCCOPY ) ;Invert color sleep(2000) _GDIPlus_ImageSaveToFile($Bmp_Buffer, "InvertedAndXored.png") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") While 1 WEnd func _Exit() Exit EndFunc ;====================================================================================== ; Function Name: Load_BMP_From_Mem ; Description: Loads a image which is saved as a binary string and converts it to a bitmap or hbitmap ; ; Parameters: $mem_image: the binary string which contains any valid image which is supported by GDI+ ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created ; ; Remark: hbitmap format is used generally for GUI internal images ; ; Requirement(s): GDIPlus.au3, Memory.au3 ; Return Value(s): Success: handle to bitmap or hbitmap, Error: 0 ; Error codes: 1: $mem_image is not a binary string ; ; Author(s): UEZ ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines ; Version: v0.95 Build 2011-06-11 Beta ;======================================================================================= Func Load_BMP_From_Mem($mem_image, $hHBITMAP = False) If Not IsBinary($mem_image) Then Return SetError(1, 0, 0) Local $declared = True If Not $__g_hGDIPDll Then _GDIPlus_Startup() $declared = False EndIf Local Const $memBitmap = Binary($mem_image) ;load image saved in variable (memory) and convert it to binary Local Const $len = BinaryLen($memBitmap) ;get length of image Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002) Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE Local $hStream = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) $hStream = $hStream[3] Local $hBitmap = DllCall($__g_hGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface $hBitmap = $hBitmap[2] Local Const $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr") DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _ "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak $tMem = 0 If $hHBITMAP Then Local Const $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) If Not $declared Then _GDIPlus_Shutdown() Return $hHBmp EndIf If Not $declared Then _GDIPlus_Shutdown() Return $hBitmap EndFunc ;==>Load_BMP_From_Mem Func _CreateNewDIB_Bitmap($Width, $Height,$BitCount, ByRef $ptrbmp, ByRef $DibHandle, ByRef $DibHandle_Obj) Local $tBITMAPINFO = DllStructCreate("dword Size; long Width; long Height; word Planes; word BitCount; dword Compression; dword SizeImage; long XPelsPerMeter; long YPelsPerMeter; dword ClrUsed; dword ClrImportant; dword RGBQuad[256];") DllStructSetData($tBITMAPINFO, 'Size', 40) DllStructSetData($tBITMAPINFO, 'Width', $Width) DllStructSetData($tBITMAPINFO, 'Height', -$Height) DllStructSetData($tBITMAPINFO, 'Planes', 1) DllStructSetData($tBITMAPINFO, 'BitCount', $BitCount) Local $iColorCnt = BitShift(1, -$BitCount) DllStructSetData($tBITMAPINFO, 'ClrUsed', $iColorCnt) DllStructSetData($tBITMAPINFO, 'ClrImportant', $iColorCnt) Switch $BitCount Case 1 DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift(0xFF, -16), BitShift(0xFF, -8), 0xFF), 2) Case 4 Local $aCol[16] = [8, 24, 38, 56, 72, 88, 104, 120, 136, 152, 168, 184, 210, 216, 232, 248] For $i = 0 To 15 DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift($aCol[$i], -16), BitShift($aCol[$i], -8), $aCol[$i]), $i + 1) Next Case 8 ; Windows reserves first color for white, $tBITMAPINFO.RGBQuad((0)) = 0xFFFFFF ; and last color as black! $tBITMAPINFO.RGBQuad((0xFF)) = 0x000000 Local $iColor = 20, $iRed, $iGreen, $iBlue For $iRed = 0 To 255 Step 51 For $iGreen = 0 To 255 Step 51 For $iBlue = 0 To 255 Step 51 $tBITMAPINFO.RGBQuad(($iColor)) = BitShift($iRed, -16) + BitShift($iGreen, -8) + $iBlue $iColor += 1 Next Next Next EndSwitch Local $hDCbuffer = _WinAPI_CreateCompatibleDC(0) $DibHandle = _WinAPI_CreateDIBSection(0, $tBITMAPINFO, $DIB_RGB_COLORS, $ptrbmp) ;~ $DibHandle = _WinAPI_CreateDIBSection(0, $tBMI, $DIB_RGB_COLORS, $ptrbmp) $DibHandle_Obj=_WinAPI_SelectObject($hDCbuffer, $DibHandle) Return $hDCbuffer EndFunc ;==>_CreateNewDIB_Bitmap Func HBITMAP_To_Bytes($HBITMAP) _GDIPlus_Startup() Local $BITMAP = _GDIPlus_BitmapCreateFromHBITMAP($HBITMAP) Local $JPG_ENCODER = _GDIPlus_EncodersGetCLSID("png") Local $TAG_ENCODER = _WinAPI_GUIDFromString($JPG_ENCODER) Local $PTR_ENCODER = DllStructGetPtr($TAG_ENCODER) Local $STREAM = DllCall("ole32.dll","uint","CreateStreamOnHGlobal","ptr",0,"bool",1,"ptr*",0) DllCall($__g_hGDIPDll,"uint","GdipSaveImageToStream","ptr",$BITMAP,"ptr",$STREAM[3],"ptr",$PTR_ENCODER,"ptr",0) _GDIPlus_BitmapDispose($BITMAP) Local $MEMORY = DllCall("ole32.dll","uint","GetHGlobalFromStream","ptr",$STREAM[3],"ptr*",0) Local $MEM_SIZE = _MemGlobalSize($MEMORY[2]) Local $MEM_PTR = _MemGlobalLock($MEMORY[2]) Local $DATA_STRUCT = DllStructCreate("byte[" & $MEM_SIZE & "]", $MEM_PTR) Local $DATA = DllStructGetData($DATA_STRUCT,1) _MemGlobalFree($MEMORY[2]) _GDIPlus_Shutdown() Return $DATA EndFunc
-
It works really well now, it does exacly what i want, only problem is my mask. i create a black and white bitmap (line 58 $Bmp6_Buffer = _CreateNewDIB_Bitmap) copy the buffer that hold the image that was $SRCINVERT in to the new black and white image and i have the mask it possible to tell the structure in _CreateNewDIB_Bitmap to thread all pixels as white and only true black pixels as black here? Switch $BitCount Case 1 DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift(0xFF, -16), BitShift(0xFF, -8), 0xFF), 2) Or maybe with this operators? how do i set the hDest brush or the hdcDest? ;~ $PATCOPY - Copies the brush selected in hdcDest, into the destination bitmap ;~ $MERGECOPY - Merges the color of the source rectangle with the brush currently selected in hDest, by using the AND operator. ;~ $PATINVERT - Combines the colors of the brush currently selected in hDest, with the colors of the destination rectangle by using the XOR operator. ;~ $PATPAINT - Combines the colors of the brush currently selected in hDest, with the colors of the inverted source rectangle by using the OR operator. The result of this operation is combined with the color of the destination rectangle by using the OR operator. delaying the script between captures 400ms it clearly does what i intend here is the sript, #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> AutoItSetOption("GUIOnEventMode", 1) $ColorDepth = 32 $secondaryBitmap = 32 $Width = @DesktopWidth / 2 $Height = @DesktopHeight / 2 $Form = GUICreate("GUI", $Width, $Height, -1, -1, $WS_MINIMIZEBOX+ $WS_CAPTION+ $WS_POPUP+ $WS_SYSMENU+$WS_SIZEBOX) $Pic = GUICtrlCreatePic("", 0, 0, 255, 255) GUICtrlSetResizing($Pic, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM) GUISetState(@SW_SHOW) Local $hWnd = _WinAPI_GetDesktopWindow() Local $hDDC = _WinAPI_GetDC($hWnd) Local $Bmp1_DibHandle Local $Bmp1_DibHandleObj Local $Bmp1_ptr Local $Bmp1_Buffer = _CreateNewDIB_Bitmap(@DesktopWidth, @DesktopHeight,$ColorDepth,$Bmp1_ptr,$Bmp1_DibHandle,$Bmp1_DibHandleObj) _WinAPI_SetStretchBltMode($Bmp1_Buffer, $COLORONCOLOR) Local $Bmp2_DibHandle Local $Bmp2_DibHandleObj Local $Bmp2_ptr Local $Bmp2_Buffer = _CreateNewDIB_Bitmap($Width, $Height,$secondaryBitmap,$Bmp2_ptr,$Bmp2_DibHandle,$Bmp2_DibHandleObj) ;~ Local $Bmp2_Buffer = _CreateNewDIB_Bitmap($Width, $Height,32,$Bmp2_ptr,$Bmp2_DibHandle,$Bmp2_DibHandleObj) ;~ _WinAPI_SetStretchBltMode($Bmp2_Buffer, $BLACKONWHITE) ;~ _WinAPI_SetStretchBltMode($Bmp2_Buffer, $COLORONCOLOR) _WinAPI_SetStretchBltMode($Bmp2_Buffer, $HALFTONE) ;~ _WinAPI_SetStretchBltMode($Bmp2_Buffer, $WHITEONBLACK) Local $Bmp3_DibHandle Local $Bmp3_DibHandleObj Local $Bmp3_ptr Local $Bmp3_Buffer = _CreateNewDIB_Bitmap($Width, $Height,$secondaryBitmap,$Bmp3_ptr,$Bmp3_DibHandle,$Bmp3_DibHandleObj) Local $Bmp4_DibHandle Local $Bmp4_DibHandleObj Local $Bmp4_ptr Local $Bmp4_Buffer = _CreateNewDIB_Bitmap($Width, $Height,$secondaryBitmap,$Bmp4_ptr,$Bmp4_DibHandle,$Bmp4_DibHandleObj) Local $Bmp5_DibHandle Local $Bmp5_DibHandleObj Local $Bmp5_ptr Local $Bmp5_Buffer = _CreateNewDIB_Bitmap($Width, $Height,$secondaryBitmap,$Bmp5_ptr,$Bmp5_DibHandle,$Bmp5_DibHandleObj) Local $Bmp6_DibHandle Local $Bmp6_DibHandleObj Local $Bmp6_ptr Local $Bmp6_Buffer = _CreateNewDIB_Bitmap($Width, $Height,1,$Bmp6_ptr,$Bmp6_DibHandle,$Bmp6_DibHandleObj) Local $Bmp7_DibHandle Local $Bmp7_DibHandleObj Local $Bmp7_ptr Local $Bmp7_Buffer = _CreateNewDIB_Bitmap($Width, $Height,1,$Bmp7_ptr,$Bmp7_DibHandle,$Bmp7_DibHandleObj) Local $BmpOld_ptr Local $BmpOld_DibHandle Local $BmpOld_DibHandleObj Local $BmpOld_Buffer = _CreateNewDIB_Bitmap($Width, $Height,$secondaryBitmap,$BmpOld_ptr,$BmpOld_DibHandle,$BmpOld_DibHandleObj) Local $BmpNew_ptr Local $BmpNew_DibHandle Local $BmpNew_DibHandleObj Local $BmpNew_Buffer = _CreateNewDIB_Bitmap($Width, $Height,$secondaryBitmap,$BmpNew_ptr,$BmpNew_DibHandle,$BmpNew_DibHandleObj) $Switch=true GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $hCtrl = GUICtrlGetHandle($Pic) $hGUI_DC = _WinAPI_GetDC($hCtrl) $test=0 ;~ Specifies a raster operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color: ;~ $BLACKNESS - Fills the destination rectangle using the color associated with palette index 0 ;~ $CAPTUREBLT - Includes any window that are layered on top of your window in the resulting image ;~ $DSTINVERT - Inverts the destination rectangle ;~ $MERGECOPY - Merges the color of the source rectangle with the brush currently selected in hDest, by using the AND operator. ;~ $MERGEPAINT - Merges the color of the inverted source rectangle with the colors of the destination rectangle by using the OR operator. ;~ $NOMIRRORBITMAP - Prevents the bitmap from being mirrored ;~ $NOTSRCCOPY - Copies the inverted source rectangle to the destination ;~ $NOTSRCERASE - Combines the colors of the source and destination rectangles by using the OR operator and then inverts the resultant color. ;~ $PATCOPY - Copies the brush selected in hdcDest, into the destination bitmap ;~ $PATINVERT - Combines the colors of the brush currently selected in hDest, with the colors of the destination rectangle by using the XOR operator. ;~ $PATPAINT - Combines the colors of the brush currently selected in hDest, with the colors of the inverted source rectangle by using the OR operator. The result of this operation is combined with the color of the destination rectangle by using the OR operator. ;~ $SRCAND - Combines the colors of the source and destination rectangles by using the AND operator ;~ $SRCCOPY - Copies the source rectangle directly to the destination rectangle ;~ $SRCERASE - Combines the inverted color of the destination rectangle with the colors of the source rectangle by using the AND operator. ;~ $SRCINVERT - Combines the colors of the source and destination rectangles by using the XOR operator ;~ $SRCPAINT - Combines the colors of the source and destination rectangles by using the OR operator ;~ $WHITENESS - Fills the destination rectangle using the color associated with index 1 in the physical palette. While 1 $Timer = TimerInit() _WinAPI_BitBlt($Bmp3_Buffer, 0, 0, $Width, $Height, $Bmp2_Buffer, 0, 0, $SRCCOPY) ;~ _WinAPI_BitBlt($hGUI_DC, 0, 0, $Width, $Height, $Bmp3_Buffer, 0, 0,$SRCCOPY ) ;~ sleep(2000) ;~ _WinAPI_BitBlt($Bmp1_Buffer, 0, 0, @DesktopWidth, @DesktopHeight, $hDDC, @DesktopWidth, 0, $SRCCOPY) ;get the mew image _WinAPI_BitBlt($Bmp1_Buffer, 0, 0, @DesktopWidth, @DesktopHeight, $hDDC, 0, 0, $SRCCOPY) _WinAPI_StretchBlt($Bmp2_Buffer, 0, 0, $Width, $Height, $Bmp1_Buffer, 0, 0, @DesktopWidth, @DesktopHeight, $SRCCOPY);resize new image _WinAPI_BitBlt($Bmp3_Buffer, 0, 0, $Width, $Height, $Bmp2_Buffer, 0, 0, $SRCINVERT) ;$SRCINVERT the new and old image so the changed pixels are any other color exept black, ;~ _WinAPI_BitBlt($hGUI_DC, 0, 0, $Width, $Height, $Bmp3_Buffer, 0, 0,$SRCCOPY ) ;~ sleep(2000) ;~ GET $BmpX_Buffer white black pixels on the image ;~ _WinAPI_BitBlt($Bmp3_Buffer, 0, 0, $Width, $Height, $BmpX_Buffer, 0, 0, $MERGEPAINT) ;Merge the two images to get the mask, blackmask covers pixels that did not change(will give problems with real black pixels probably) ;~ _WinAPI_BitBlt($hGUI_DC, 0, 0, $Width, $Height, $Bmp3_Buffer, 0, 0,$SRCCOPY ) ;~ sleep(2000) ;creating the mask Mode 2, not working good _WinAPI_BitBlt($Bmp6_Buffer, 0, 0, $Width, $Height, $Bmp3_Buffer, 0, 0, $SRCCOPY) ;Draw the mask using the older image in to a Black white pixel bitmap, not a perfect mask but to test out if it will work ;~ _WinAPI_BitBlt($hGUI_DC, 0, 0, $Width, $Height, $Bmp6_Buffer, 0, 0,$SRCCOPY ) ;~ sleep(2000) _WinAPI_BitBlt($Bmp5_Buffer, 0, 0, $Width, $Height, $Bmp6_Buffer, 0, 0, $SRCCOPY) ;copy mask to a color bitmap, ;~ _WinAPI_BitBlt($hGUI_DC, 0, 0, $Width, $Height, $Bmp5_Buffer, 0, 0,$SRCCOPY ) ;~ sleep(2000) _WinAPI_BitBlt($Bmp5_Buffer, 0, 0, $Width, $Height, $Bmp2_Buffer, 0, 0, $SRCAND) ;$SRCAND the new image with the mask, changed pixels will be in color, unchanged pixels will be black _WinAPI_BitBlt($hGUI_DC, 0, 0, $Width, $Height, $Bmp5_Buffer, 0, 0,$SRCCOPY ) ;~ sleep(8000) sleep(100) ;~ $test+=1 ;~ if $test=50 Then ;~ $filename = @ScriptDir & "\Complete Image.Png" ;~ _ScreenCapture_SaveImage($filename, $Bmp2_DibHandle) ;~ $filename = @ScriptDir & "\black with changed pixels Image.Png" ;~ _ScreenCapture_SaveImage($filename, $Bmp5_DibHandle) ;~ Exit ;~ EndIf ;~ ;up to here seems to be good, true black pixels will give a problem, fix later ;~ Exit WEnd Func _CreateNewDIB_Bitmap($Width, $Height,$BitCount, ByRef $ptrbmp, ByRef $DibHandle, ByRef $DibHandle_Obj) Local $tBITMAPINFO = DllStructCreate("dword Size; long Width; long Height; word Planes; word BitCount; dword Compression; dword SizeImage; long XPelsPerMeter; long YPelsPerMeter; dword ClrUsed; dword ClrImportant; dword RGBQuad[256];") DllStructSetData($tBITMAPINFO, 'Size', 40) DllStructSetData($tBITMAPINFO, 'Width', $Width) DllStructSetData($tBITMAPINFO, 'Height', -$Height) DllStructSetData($tBITMAPINFO, 'Planes', 1) DllStructSetData($tBITMAPINFO, 'BitCount', $BitCount) Local $iColorCnt = BitShift(1, -$BitCount) DllStructSetData($tBITMAPINFO, 'ClrUsed', $iColorCnt) DllStructSetData($tBITMAPINFO, 'ClrImportant', $iColorCnt) Switch $BitCount Case 1 DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift(0xFF, -16), BitShift(0xFF, -8), 0xFF), 2) Case 4 Local $aCol[16] = [8, 24, 38, 56, 72, 88, 104, 120, 136, 152, 168, 184, 210, 216, 232, 248] For $i = 0 To 15 DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift($aCol[$i], -16), BitShift($aCol[$i], -8), $aCol[$i]), $i + 1) Next ;~ Case 4 ;~ Local $aCol[16] = [16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 216, 232, 248] ;~ For $i = 0 To 15 ;~ DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift($aCol[$i], -16), BitShift($aCol[$i], -8), $aCol[$i]), $i + 1) ;~ Next ;~ Case 8 ;~ ; Windows reserves first color for white, ;~ DllStructSetData($tBITMAPINFO, 'RGBQuad', 255, 1) ;~ ; and last color as black! ;~ DllStructSetData($tBITMAPINFO, 'RGBQuad', 0, 255) ;~ Local $iColor = 10 ;~ For $i = 20 To $iColorCnt - 22 ;first 20 and last 20 are reserved! ;~ DllStructSetData($tBITMAPINFO, 'RGBQuad', BitOR(BitShift($i, -16), BitShift($i, -8), $i*$iColor), $i + 1) ;~ Next Case 8 ; Windows reserves first color for white, $tBITMAPINFO.RGBQuad((0)) = 0xFFFFFF ; and last color as black! $tBITMAPINFO.RGBQuad((0xFF)) = 0x000000 Local $iColor = 20, $iRed, $iGreen, $iBlue For $iRed = 0 To 255 Step 51 For $iGreen = 0 To 255 Step 51 For $iBlue = 0 To 255 Step 51 $tBITMAPINFO.RGBQuad(($iColor)) = BitShift($iRed, -16) + BitShift($iGreen, -8) + $iBlue $iColor += 1 Next Next Next EndSwitch Local $hDCbuffer = _WinAPI_CreateCompatibleDC(0) $DibHandle = _WinAPI_CreateDIBSection(0, $tBITMAPINFO, $DIB_RGB_COLORS, $ptrbmp) ;~ $DibHandle = _WinAPI_CreateDIBSection(0, $tBMI, $DIB_RGB_COLORS, $ptrbmp) $DibHandle_Obj=_WinAPI_SelectObject($hDCbuffer, $DibHandle) Return $hDCbuffer EndFunc ;==>_CreateNewDIB_Bitmap Func _Exit() _WinAPI_ReleaseDC($hWnd, $hDDC) GUIDelete() Exit EndFunc ;==>_Exit ;~ Func _DeleteBitmap32($DC, $ptr, $hbmp) ;~ $ptr = 0 ;~ EndFunc
-
ok so playing arround with one of the scripts found on the forum i figured out what i need to do, first $SRCINVERT my old and new images so I get image a.bmp open a.bmp in paint, repace black with white and save it as b.bmp $MERGEPAINT a.bmp and b.bmp, i get Resul which is the black mask then $SRCAND the newer newer image with the black mask, and i get the changed pixels in full color only problems is how do i fill in replacing black with white with _WinAPI_BitBlt or another fast functions?? the step with a.bmp and b.bmp was done manualy
-
if i use that script i get the same result, a double image, now after i was away from computer a while i was thinking about what can be done, what this script and the example one of uez does is inverting the newer image on to the older one with $SRCINVERT, the result is all unchanged pixels are black, (good so far),the problem is all pixels changed from black to color are their true color, and all pixels that there on other colors and changed colors are inverted color, so the image have a mix of inverted and not inverted colors + the old image blent in to the new (old colors vs new ones)making it apear a double image what can probably work is take an image(First Image), taking another image,fiew secs later (Second Image), invert the images on each other to get the black pixels + mixed color pixels,(third image), take all colors on third image exept black, and blank them out, make it tansparent?,then overlay the image with only black pixels over the second image and there i have all the changed pixels black, that will work i suppose, but now that i think about it, that will give me problems with black later on, when i stream the image to a client and try to draw the image on the previously recieved one. will try it anyway to do that not sure how to make all colors but black transparent, any tips? dont know it its the right path either moded desk to stream script achieves exaxly what i need to achieve with _WinAPI_BitBlt