Jump to content

Search the Community

Showing results for tags 'PNG'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 17 results

  1. Hi guys, I would like to make a gui borderless viewing a png image with transparent background. pretty much has to be visible only the png image with no background..you have any simple example? Thank's GUICtrlCreatePic still it provides the image with the background...
  2. The following script, thanks largely to @UEZ, displays the attached PNG image on the Windows Desktop. It perfectly renders the sticky note's shadow over whatever's in the background. But here's the catch: I would like to add a line of text, fetched from a variable and using a font of my choice, atop the sticky note. It needs to be part of the same GUI because the sticky note can be dragged and placed anywhere on the screen. Will someone here show me how to add just the additional code needed to accomplish my goal? I have tried sporadically for two years to merge in code from scripts that use GDI+ calls to display text over alpha channels but the challenge has proven beyond me. #include <ButtonConstants.au3> #include <MsgBoxConstants.au3> #include <StructureConstants.au3> #include <WinAPIConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> _GDIPlus_Startup() Global Const $SC_DRAGMOVE = 0xF012 Global $iW, $iH, $hImage, $hBitmap, $hGUI $hImage = _GDIPlus_BitmapCreateFromFile("Using-Note.png") $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST)) GUISetState() _WinAPI_BitmapDisplayTransparentInGUI($hBitmap, $hGUI) GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBitmap) _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() GUIDelete() Func _WinAPI_BitmapDisplayTransparentInGUI(ByRef $hHBitmap, ByRef $hGUI, $iOpacity = 0xFF, $bReleaseGDI = True) If Not BitAND(GUIGetStyle($hGUI)[1], $WS_EX_LAYERED) = $WS_EX_LAYERED Then Return SetError(1, 0, 0) Local $tDim = DllStructCreate($tagBITMAP) If Not _WinAPI_GetObject($hHBitmap, DllStructGetSize($tDim), DllStructGetPtr($tDim)) Then Return SetError(2, 0, 0) Local $tSize = DllStructCreate($tagSIZE), $tSource = DllStructCreate($tagPOINT), $tBlend = DllStructCreate($tagBLENDFUNCTION) Local Const $hScrDC = _WinAPI_GetDC(0), $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC), $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) $tSize.X = $tDim.bmWidth $tSize.Y = $tDim.bmHeight $tBlend.Alpha = $iOpacity $tBlend.Format = 1 _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, DllStructGetPtr($tSize), $hMemDC, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlend), $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) If $bReleaseGDI Then _WinAPI_DeleteObject($hHBitmap) Return True EndFunc Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN
  3. Hi, is it possible to export only the area "$idOutput" with the TEXT as a PNG? Thanks #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Example() Func Example() Local $hGUI = GUICreate("Test", 700, 700, -1, -1) Local $input1 = GUICtrlCreateInput("", 10, 10, 150, 20) Local $idButtonStart = GUICtrlCreateButton("Start", 200, 10, 50, 30) Local $idButtonClear = GUICtrlCreateButton("Clear", 260, 10, 50, 30) Local $idButtonExport = GUICtrlCreateButton("Export", 320, 10, 50, 30) Local $idOutput = GUICtrlCreateLabel("TEXT", 10, 50, 500, 500, BitOR($BS_PUSHLIKE, $SS_CENTER)) GUICtrlSetFont($idOutput, 45, 800, "", "Impact") GUISetState(@SW_SHOW, $hGUI) ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButtonStart $ContentInput1 = GUICtrlRead($input1) GUICtrlSetData($idOutput, $ContentInput1) Case $idButtonClear GUICtrlSetData($input1, "") GUICtrlSetData($idOutput, "") Case $idButtonExport EndSwitch WEnd GUIDelete($hGUI) Exit EndFunc ;==>Example
  4. After UEZ helped me with the Countdown Timer his techniques seemed perfect for displaying individual images with transparency. One thing led to another and here's the resulting script. Download the attached zip file and place the 5 PNG files in the same folder as this script. I did not embed the images in the script, to make the script easier to read and so you can see the actual images used. In my opinion the ultimate next step would be to add the ability to play animated GIFs, still with transparency if that's possible. Enjoy! (with much gratitude to UEZ for his help) ; Functions coded by UEZ 2013-10-29 ; Updated to address issues 2013-10-31 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #NoTrayIcon _GDIPlus_Startup() ;initiate GDI+ #region ; timmy2's simple demonstration of UEZ's code ; ; display blank chalkboard (there will be no fade-in so use default $iAlpha value of 255) $aRes1 = DisplayImage( "Wood-framed-chalkboard.png", -1, -1 ) Sleep (500) ; add first two steps $aRes2 = DisplayImage("step-1.png", -1, -1 ) Sleep(2000) $aRes3 = DisplayImage("step-2.png", -1, -1 ) ; fade in handdrawn circle (therefore start with $iAlpha = 0) $aPos = WinGetPos($aRes1[0]) ;required because the chalkboard is displayed at screen center, which varies based on resolution (doh!) $aRes4 = DisplayImage("circle.png", $aPos[0] + 290, $aPos[1] + 75, 0) sleep (500) _Fader($aRes4) sleep(1000) _Fader($aRes4, False) ReleaseResources($aRes4) sleep(500) ; add third step $aRes5 = DisplayImage("step-3.png", -1, -1 ) Sleep(2000) ; fade the three steps out in reverse order (faster than defaults) _Fader($aRes5, False, 255, 5, 5) ReleaseResources($aRes5) _Fader($aRes3, False, 255, 5, 5) ReleaseResources($aRes3) _Fader($aRes2, False, 255, 5, 5) ReleaseResources($aRes2) Sleep(500) ; fade out chockboard _Fader($aRes1, False, 255, 10, 5) ReleaseResources($aRes1) #endregion _GDIPlus_Shutdown() Exit ; Display the image at center unless otherwise specified. If Fader will not be used then $iAlpha's default of 0xFF is good. ; If Fader will be used then start with $iAlpha equal to zero. Option to make this image "Always on top" is also available. Func DisplayImage($sFile, $iPosX = -1, $iPosY = -1, $iAlpha = 0xFF, $bTopmost = True) Local Const $hBmp_Background = _GDIPlus_BitmapCreateFromFile($sFile) ;load the image If @error Then Return SetError(1, 0, 0) ;image cannot be loaded Local Const $iW = _GDIPlus_ImageGetWidth($hBmp_Background), $iH = _GDIPlus_ImageGetHeight($hBmp_Background) ;get the dimension of the background image Local Const $hGUI = GUICreate("", $iW, $iH, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST * $bTopmost, $WS_EX_TOOLWINDOW)) ;create GUI with appropriate styles and extented style (borderless transparent GUI) GUICtrlCreateLabel("", 0, 0, $iW, $iH, Default, $GUI_WS_EX_PARENTDRAG) ;create a hidden label for GUI dragging GUISetState(@SW_SHOW, $hGUI) ;show GUI Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) ;define an empty bitmap where all the gfx stuff will copied to Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the context to the bitmap to be able to copy / draw to the bitmap _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp_Background, 0, 0, $iW, $iH) ;draw background image to the empty bitmap ;display GDI+ with transparency on desktop Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert GDI+ image to GDI to display it on the screen using GDI functions Local Const $hScrDC = _WinAPI_GetDC($hGUI) ;get the device context (dc) handle of the GUI Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) ;create a compatible dc handle Local Const $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) ;selects the GDI bitmap object into the specified device context Local Const $tSize = DllStructCreate($tagSIZE) ;create a $tagSIZE struct (x = width, y = height) DllStructSetData($tSize, "X", $iW) ;set data for width DllStructSetData($tSize, "Y", $iH) ;set data for height Local $tSource = DllStructCreate($tagPOINT) ;create a $tagPOINT struct (x = x position, y = y position) Local $tBlend = DllStructCreate($tagBLENDFUNCTION) ;create $tagBLENDFUNCTION struct -> see help file for more info DllStructSetData($tBlend, "Alpha", $iAlpha) ;set the alpha channel of the GUI -> 255 = opaque, 0 = transparent DllStructSetData($tBlend, "Format", 1) ;set the format to 1 -> bitmap has alpha channels DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $hGUI, "handle", $hScrDC, "ptr", 0, "struct*", $tSize, "handle", $hMemDC, "struct*", $tSource, "dword", 0, "struct*", $tBlend, "dword", $ULW_ALPHA) ;display bitmap on screen ;release resources otherwise memory will filled up (memory leak) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBitmap) Local $aResource[7] = [$hGUI, $hScrDC, $hHBitmap, $hMemDC, $tBlend, $tSize, $tSource] ;return the handle to release it later Return $aResource EndFunc ;==>DisplayImage ; This function releases the resources of a specific image and closes it Func ReleaseResources(ByRef $aResource) If Not IsArray($aResource) Then Return SetError(1, 0, 0) If UBound($aResource) <> 7 Then Return SetError(2, 0, 0) _WinAPI_ReleaseDC($aResource[0], $aResource[1]) _WinAPI_DeleteDC($aResource[3]) _WinAPI_DeleteObject($aResource[2]) GUIDelete($aResource[0]) EndFunc ;==>ReleaseResources ; To fade in an image leave $bIn at default (True); to fade out specify False. ; There are also options to set the ending transparency level (0 transparent, 255 opaque), speed and delay. ; If you change the speed or delay be sure to specify $bIn and $iTrans, otherwise you'll wonder why the fade-in or out isn't what you hoped for. ; The default values are specified in the function below. Func _Fader($res1, $bIn = True, $iTrans = 255, $speed = 3, $delay = 10 ) If Not IsArray($res1) Then Return SetError(1, 0, 0) If UBound($res1) <> 7 Then Return SetError(2, 0, 0) Switch $bIn Case True For $a = 0 To $iTrans Step $speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next Case Else For $a = $iTrans To 0 Step -$speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next EndSwitch EndFunc ;==>_FadeIn #region GDI and GDI+ functions Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iPixelFormat = $GDIP_PXF32ARGB, $iStride = 0, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 #endregion GDI and GDI+ functions images.zip
  5. wakillon

    Svg2Png

    Version 1.0.0

    361 downloads

    Convert SVG file to PNG using Cairo and rsvg libraries
  6. Convert SVG file to PNG using Cairo and rsvg libraries (and their imports) #Region ;************ Includes ************ #include <File.au3> #EndRegion ;************ Includes ************ ; typedef enum _cairo_status Global Const $CAIRO_STATUS_SUCCESS = 0 Global Const $CAIRO_STATUS_NO_MEMORY = 1 Global Const $CAIRO_STATUS_INVALID_RESTORE = 2 Global Const $CAIRO_STATUS_INVALID_POP_GROUP = 3 Global Const $CAIRO_STATUS_NO_CURRENT_POINT = 4 Global Const $CAIRO_STATUS_INVALID_MATRIX = 5 Global Const $CAIRO_STATUS_INVALID_STATUS = 6 Global Const $CAIRO_STATUS_NULL_POINTER = 7 Global Const $CAIRO_STATUS_INVALID_STRING = 8 Global Const $CAIRO_STATUS_INVALID_PATH_DATA = 9 Global Const $CAIRO_STATUS_READ_ERROR = 10 Global Const $CAIRO_STATUS_WRITE_ERROR = 11 Global Const $CAIRO_STATUS_SURFACE_FINISHED = 12 Global Const $CAIRO_STATUS_SURFACE_TYPE_MISMATCH = 13 Global Const $CAIRO_STATUS_PATTERN_TYPE_MISMATCH = 14 Global Const $CAIRO_STATUS_INVALID_CONTENT = 15 Global Const $CAIRO_STATUS_INVALID_FORMAT = 16 Global Const $CAIRO_STATUS_INVALID_VISUAL = 17 Global Const $CAIRO_STATUS_FILE_NOT_FOUND = 18 Global Const $CAIRO_STATUS_INVALID_DASH = 19 Global Const $CAIRO_STATUS_INVALID_DSC_COMMENT = 20 Global Const $CAIRO_STATUS_INVALID_INDEX = 21 Global Const $CAIRO_STATUS_CLIP_NOT_REPRESENTABLE = 22 Global Const $CAIRO_STATUS_TEMP_FILE_ERROR = 23 Global Const $CAIRO_STATUS_INVALID_STRIDE = 24 Global Const $CAIRO_STATUS_FONT_TYPE_MISMATCH = 25 Global Const $CAIRO_STATUS_USER_FONT_IMMUTABLE = 26 Global Const $CAIRO_STATUS_USER_FONT_ERROR = 27 Global Const $CAIRO_STATUS_NEGATIVE_COUNT = 28 Global Const $CAIRO_STATUS_INVALID_CLUSTERS = 29 Global Const $CAIRO_STATUS_INVALID_SLANT = 30 Global Const $CAIRO_STATUS_INVALID_WEIGHT = 31 Global Const $CAIRO_STATUS_INVALID_SIZE = 32 Global Const $CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED = 33 Global Const $CAIRO_STATUS_DEVICE_TYPE_MISMATCH = 34 Global Const $CAIRO_STATUS_DEVICE_ERROR = 35 Global Const $CAIRO_STATUS_INVALID_MESH_CONSTRUCTION = 36 Global Const $CAIRO_STATUS_DEVICE_FINISHED = 37 Global Const $CAIRO_STATUS_LAST_STATUS = 38 ; typedef enum _cairo_format Global Const $CAIRO_FORMAT_INVALID = -1 Global Const $CAIRO_FORMAT_ARGB32 = 0 Global Const $CAIRO_FORMAT_RGB24 = 1 Global Const $CAIRO_FORMAT_A8 = 2 Global Const $CAIRO_FORMAT_A1 = 3 Global Const $CAIRO_FORMAT_RGB16_565 = 4 Global Const $CAIRO_FORMAT_RGB30 = 5 ; Check libraries. $aList = _FileListToArray ( @ScriptDir, '*.dll', 1, 0 ) For $i = 1 To UBound ( $aList ) -1 If _GetBinaryType ( @ScriptDir & '\' & $aList[$i] ) <> 'i386' Then Exit MsgBox ( 262144+16, 'Error', $aList[$i] & ' is not 32bit !', 5 ) ;~ ConsoleWrite ( $aList[$i] & @TAB & 'Version ' & FileGetVersion ( $aList[$i] ) & @Crlf ) Next #Region ------ Global Variables ------------------------------ FileChangeDir ( @ScriptDir & '\Libraries' ) Global $h_RsvgDll = DllOpen ( @ScriptDir & '\Libraries\librsvg-2-2.dll' ) Global $h_CairoDll = DllOpen ( @ScriptDir & '\Libraries\libcairo-2.dll' ) Global $sPngFilePath = @DesktopDir & '\' & @HOUR & @MIN & @SEC & @MSEC & '.png' Global $sSvgFilePath, $hRsvg, $pCairoSurface, $pCr #EndRegion --- Global Variables ------------------------------ FileChangeDir ( @ScriptDir & '\SVG files' ) $sSvgFilePath = FileOpenDialog ( 'Select a Shape', @WorkingDir, 'Vector Graphic (*.svg)', 1+2, '' ) If @error Then Exit ; Open the SVG image file $hRsvg = _Rsvg_handle_new_from_file ( $sSvgFilePath ) ConsoleWrite ( '!->-- [' & StringFormat ( '%03i', @ScriptLineNumber ) & '] $hRsvg : ' & $hRsvg & @Crlf ) ; Get dimensions $aSize = _Rsvg_handle_get_dimensions ( $hRsvg ) If Not @error Then ConsoleWrite ( '> Width : ' & $aSize[0] & ', Height : ' & $aSize[1] & @Crlf ) ; Create a Surface into which we render the SVG drawing $pCairoSurface = _Cairo_image_surface_create ( $CAIRO_FORMAT_ARGB32, $aSize[0], $aSize[1] ) ConsoleWrite ( '!->-- [' & StringFormat ( '%03i', @ScriptLineNumber ) & '] $pCairoSurface : ' & $pCairoSurface & @Crlf ) ; Create a new Cairo renderer $pCr = _Cairo_create ( $pCairoSurface ) ConsoleWrite ( '!->-- [' & StringFormat ( '%03i', @ScriptLineNumber ) & '] $pCr : ' & $pCr & @Crlf ) ConsoleWrite ( 'Cairo status after _Cairo_create : ' & _Cairo_status ( $pCr ) & @Crlf ) ; Render the SVG into the Cairo buffer _Rsvg_handle_render_cairo ( $hRsvg, $pCr ) ConsoleWrite ( 'Cairo status after _Rsvg_handle_render_cairo : ' & _Cairo_status ( $pCr ) & @Crlf ) ; Save to png _Cairo_surface_write_to_png ( $pCairoSurface, $sPngFilePath ) ConsoleWrite ( 'Cairo status after _Cairo_surface_write_to_png : ' & _Cairo_status ( $pCr ) & @Crlf ) _Cairo_surface_finish ( $pCairoSurface ) ConsoleWrite ( 'Cairo status after _Cairo_surface_finish : ' & _Cairo_status ( $pCr ) & @Crlf ) _Rsvg_handle_close ( $hRsvg ) ConsoleWrite ( 'Cairo status after _Rsvg_handle_close : ' & _Cairo_status ( $pCr ) & @Crlf ) ; Display _BitmapDisplayInWindowsViewer ( $sPngFilePath ) ; Cleanup _Cairo_destroy ( $pCr ) _Cairo_surface_destroy ( $pCairoSurface ) DllClose ( $h_RsvgDll ) DllClose ( $h_CairoDll ) Exit Func _BitmapDisplayInWindowsViewer ( $sFilePath ) If Not FileExists ( $sFilePath ) Then Return SetError ( -1 ) Run ( 'rundll32 shimgvw.dll,ImageView_Fullscreen ' & $sFilePath ) EndFunc ;==> _BitmapDisplayInWindowsViewer() Func _Cairo_create ( $pCairoSurface ) Local $aRet = DllCall ( $h_CairoDll, 'ptr:cdecl', 'cairo_create', 'ptr', $pCairoSurface ) If @error Then Return SetError ( @error, 0, 0 ) Return $aRet[0] EndFunc ;==> _Cairo_create() Func _Cairo_destroy ( $pCr ) Local $aRet = DllCall ( $h_CairoDll, 'int:cdecl', 'cairo_destroy', 'ptr', $pCr ) If @error Then Return SetError ( @error, 0, 0 ) Return $aRet[0] EndFunc ;==> _Cairo_destroy() Func _Cairo_image_surface_create ( $iFormat, $iWidth, $iHeight ) Local $aRet = DllCall ( $h_CairoDll, 'ptr:cdecl', 'cairo_image_surface_create', 'int', $iFormat, 'int', $iWidth, 'int', $iHeight ) If @error Then Return SetError ( @error, 0, 0 ) Return $aRet[0] EndFunc ;==> _Cairo_image_surface_create() Func _Cairo_image_surface_create_for_data ( $iFormat, $iWidth, $iHeight, $iStride ) Local $tStruct = DllStructCreate ( 'byte[' & $iStride*$iHeight & ']' ) Local $aRet = DllCall ( $h_CairoDll, 'ptr:cdecl', 'cairo_image_surface_create_for_data', 'ptr', DllStructGetPtr ( $tStruct ), 'int', $iFormat, 'int', $iWidth, 'int', $iHeight, 'int', $iStride ) If @error Then Return SetError ( @error, 0, 0 ) $tStruct = 0 Return $aRet[0] EndFunc ;==> _Cairo_image_surface_create_for_data() Func _Cairo_status ( $pCr ) Local $aRet = DllCall ( $h_CairoDll, 'int:cdecl', 'cairo_status', 'ptr', $pCr ) If @error Then Return SetError ( @error, 0, 0 ) Switch $aRet[0] Case $CAIRO_STATUS_SUCCESS Return 'SUCCESS' Case $CAIRO_STATUS_NO_MEMORY Return 'NO MEMORY' Case $CAIRO_STATUS_INVALID_RESTORE Return 'INVALID RESTORE' Case $CAIRO_STATUS_INVALID_POP_GROUP Return 'INVALID POP GROUP' Case $CAIRO_STATUS_NO_CURRENT_POINT Return 'NO CURRENT POINT' Case $CAIRO_STATUS_INVALID_MATRIX Return 'INVALID MATRIX' Case $CAIRO_STATUS_INVALID_STATUS Return 'INVALID STATUS' Case $CAIRO_STATUS_NULL_POINTER Return 'NULL POINTER' Case $CAIRO_STATUS_INVALID_STRING Return 'INVALID STRING' Case $CAIRO_STATUS_INVALID_PATH_DATA Return 'INVALID PATH DATA' Case $CAIRO_STATUS_READ_ERROR Return 'READ ERROR' Case $CAIRO_STATUS_WRITE_ERROR Return 'WRITE ERROR' Case $CAIRO_STATUS_SURFACE_FINISHED Return 'SURFACE FINISHED' Case $CAIRO_STATUS_SURFACE_TYPE_MISMATCH Return 'SURFACE TYPE MISMATCH' Case $CAIRO_STATUS_PATTERN_TYPE_MISMATCH Return 'PATTERN TYPE MISMATCH' Case $CAIRO_STATUS_INVALID_CONTENT Return 'INVALID CONTENT' Case $CAIRO_STATUS_INVALID_FORMAT Return 'INVALID FORMAT' Case $CAIRO_STATUS_INVALID_VISUAL Return 'INVALID VISUAL' Case $CAIRO_STATUS_FILE_NOT_FOUND Return 'FILE NOT FOUND' Case $CAIRO_STATUS_INVALID_DASH Return 'INVALID DASH' Case $CAIRO_STATUS_INVALID_DSC_COMMENT Return 'INVALID DSC COMMENT' Case $CAIRO_STATUS_INVALID_INDEX Return 'INVALID INDEX' Case $CAIRO_STATUS_CLIP_NOT_REPRESENTABLE Return 'CLIP NOT REPRESENTABLE' Case $CAIRO_STATUS_TEMP_FILE_ERROR Return 'TEMP FILE ERROR' Case $CAIRO_STATUS_INVALID_STRIDE Return 'INVALID STRIDE' Case $CAIRO_STATUS_FONT_TYPE_MISMATCH Return 'FONT TYPE MISMATCH' Case $CAIRO_STATUS_USER_FONT_IMMUTABLE Return 'USER FONT IMMUTABLE' Case $CAIRO_STATUS_USER_FONT_ERROR Return 'USER FONT ERROR' Case $CAIRO_STATUS_NEGATIVE_COUNT Return 'NEGATIVE COUNT' Case $CAIRO_STATUS_INVALID_CLUSTERS Return 'INVALID CLUSTERS' Case $CAIRO_STATUS_INVALID_SLANT Return 'INVALID SLANT' Case $CAIRO_STATUS_INVALID_WEIGHT Return 'INVALID WEIGHT' Case $CAIRO_STATUS_INVALID_SIZE Return 'INVALID SIZE' Case $CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED Return 'USER FONT NOT IMPLEMENTED' Case $CAIRO_STATUS_DEVICE_TYPE_MISMATCH Return 'DEVICE TYPE MISMATCH' Case $CAIRO_STATUS_DEVICE_ERROR Return 'DEVICE ERROR' Case $CAIRO_STATUS_INVALID_MESH_CONSTRUCTION Return 'INVALID MESH CONSTRUCTION' Case $CAIRO_STATUS_DEVICE_FINISHED Return 'DEVICE FINISHED' Case $CAIRO_STATUS_LAST_STATUS Return 'LAST STATUS' Case Else Return 'UNKNOW ERROR' EndSwitch EndFunc ;==> _Cairo_status() Func _Cairo_status_to_string() Local $aRet = DllCall ( $h_CairoDll, 'str:cdecl', 'cairo_status_to_string' ) If @error Then Return SetError ( @error, 0, 0 ) ;~ If $aRet[0] = '<unknown error status>' Then Return '' Return $aRet[0] EndFunc ;==> _Cairo_status_to_string() Func _Cairo_surface_destroy ( $pCairoSurface ) Local $aRet = DllCall ( $h_CairoDll, 'int:cdecl', 'cairo_surface_destroy', 'ptr', $pCairoSurface ) If @error Then Return SetError ( @error, 0, 0 ) Return $aRet[0] EndFunc ;==> _Cairo_surface_destroy() Func _Cairo_surface_finish ( $pCairoSurface ) Local $aRet = DllCall ( $h_CairoDll, 'int:cdecl', 'cairo_surface_finish', 'ptr', $pCairoSurface ) If @error Then Return SetError ( @error, 0, 0 ) Return $aRet[0] EndFunc ;==> _Cairo_surface_finish() Func _Cairo_surface_write_to_png ( $pCairoSurface, $sFilePath ) Local $aRet = DllCall ( $h_CairoDll, 'int:cdecl', 'cairo_surface_write_to_png', 'ptr', $pCairoSurface, 'str', $sFilePath ) If @error Then Return SetError ( @error, 0, 0 ) Return $aRet[0] EndFunc ;==> _Cairo_surface_write_to_png() Func _GetBinaryType ( $sFilePath ) ; by Dougiefresh Local $hFile = FileOpen ( $sFilePath, 16 ) If $hFile = -1 Then Return SetError ( -1, 0, 'Invalid' ) If BinaryToString ( FileRead ( $hFile, 2 ) ) = 'MZ' Then FileSetPos ( $hFile, 60, 0 ) FileSetPos ( $hFile, Int ( FileRead ( $hFile, 4 ) ) +4, 0 ) Local $sFileRead = FileRead ( $hFile, 2 ) FileClose ( $hFile ) If $sFileRead = '0x6486' Then Return 'AMD64' If $sFileRead = '0x4c01' Then Return 'i386' If $sFileRead = '0x0002' Then Return 'IA64' EndIf FileClose ( $hFile ) Return 'Unknown' EndFunc ;==> _GetBinaryType() Func _Rsvg_handle_close ( $hRsvg ) Local $iError = 0 Local $aRet = DllCall ( $h_RsvgDll, 'ptr:cdecl', 'rsvg_handle_close', 'ptr', $hRsvg, 'int', $iError ) If @error Then Return SetError ( @error, 0, 0 ) If $iError Then Return SetError ( $iError, 0, 0 ) Return $aRet[0] EndFunc ;==> _Rsvg_handle_close() Func _Rsvg_handle_get_dimensions ( $hRsvg ) Local $aSize[4], $tRsvgDimensionData = DllStructCreate ( 'int width;int height;double em;double ex' ) Local $aRet = DllCall ( $h_RsvgDll, 'int:cdecl', 'rsvg_handle_get_dimensions', 'ptr', $hRsvg, 'ptr', DllStructGetPtr ( $tRsvgDimensionData ) ) If @error Then Return SetError ( @error, 0, 0 ) $aSize[0] = $tRsvgDimensionData.width $aSize[1] = $tRsvgDimensionData.height $aSize[2] = $tRsvgDimensionData.em $aSize[3] = $tRsvgDimensionData.ex $tRsvgDimensionData = 0 Return $aSize EndFunc ;==> _Rsvg_handle_get_dimensions() Func _Rsvg_handle_new_from_file ( $sSvgFile ) If Not FileExists ( $sSvgFile ) Then Return SetError ( -1, 0, 0 ) Local $iError = 0 Local $aRet = DllCall ( $h_RsvgDll, 'ptr:cdecl', 'rsvg_handle_new_from_file', 'str', FileGetShortName ( $sSvgFile ), 'int', $iError ) If @error Then Return SetError ( @error, 0, 0 ) If $iError Then Return SetError ( $iError, 0, 0 ) Return $aRet[0] EndFunc ;==> _Rsvg_handle_new_from_file() Func _Rsvg_handle_render_cairo ( $hRsvg, $pCr ) Local $aRet = DllCall ( $h_RsvgDll, 'bool:cdecl', 'rsvg_handle_render_cairo', 'ptr', $hRsvg, 'ptr', $pCr ) If @error Then Return SetError ( @error, 0, 0 ) Return $aRet[0] ; Returns TRUE if drawing succeeded. EndFunc ;==> _Rsvg_handle_render_cairo() Func _Rsvg_init() ; deprecated since version 2.36 and should not be used in newly-written code. Local $aRet = DllCall ( $h_RsvgDll, 'int:cdecl', 'rsvg_init' ) If @error Then Return SetError ( @error, 0, 0 ) Return $aRet[0] EndFunc ;==> _Rsvg_init() Script and files are available in the downloads Section
  7. It's been long enough since I started looking for a solution, so I post this with a clear conscious. I am developing an application that would render keystrokes and click on the screen, much like KeyCastr on Mac OS. I did this once in the past. Back then I faced with the same problem - making a nice semitransparent window. I solved it by using Adobe AIR for the interface and Visual Basic for the data. VB was the server capturing the keystrokes and mouse events and passing them via TCP over localhost to Adobe AIR (compiled to exe). This solution worked quite ok. I even tried reviving it few hours before posting it with no success. Important note - this is NOT a keylogger, though it shares some core functionality with such application. I do not ask for tips on capturing keyboards events (though if someone could post something useful I'd be grateful). These are some posts that I've found on the forum: https://www.autoitscript.com/forum/topic/137618-two-questions-about-layered-gui/#comment-963975 https://www.autoitscript.com/forum/topic/102961-multiple-png-images-as-gui-elements/ https://www.autoitscript.com/forum/topic/47651-png-as-gui-drop-shadows-curved-edges-you-name-it/ https://www.autoitscript.com/forum/topic/102920-advanced-gui-udf-design/ https://www.autoitscript.com/forum/topic/157841-gui-fun/#comment-1144334 https://www.autoitscript.com/forum/topic/140053-just-the-text/#comment-983400 and even more... The reason for not using an existing application is that there aren't many for windows, they look ugly, and they do not behave the way I need them too. I've tried these approaches, but I'm either to stupid to understand them fully or I'm simply missing something. The main problem that I'm having is having the window transparent and displaying a label with text on top of it. As you know regular controls will not be transparent. I figured out that making a child window (transparent) on top of the parent transparent window might be the solution (I figured it out myself before finding some posts about it so I'm pretty proud of myself :)). Still... even if I do so the text is not anti-aliased and simply looks ugly. I could really use an example code that creates a window that has a PNG as a background with a nice label on top that has drop shadow (two labels? one black for the shadow and one white for the text). The window should also be dragable with a mouse. Here's a video with my old app running (start watching from 0:50): https://www.youtube.com/watch?v=C7fSpZntpfA Here's a similar application called KeyPose: http://jungsbluth.de/magnus/blog/keypose/keypose.html At some point I thought I'd just create a flash object on my window and make it transparent (I've seen this done even back in Windows 98). The difficulty here is that it's not a binary transparency, but a 32bpc one - real, smooth alpha channel like in a PNG, which is what most of the code I've seen is doing. Unfortunately I wasn't able to check that code, because I fail to create the Shockwave.Shockwave.11 object. I've installed the Flash player and the Shockwave player manually, registered the OCX, but no success. TL;DR Honestly - the solution to all my problems and problems other users are having would be replicating the behavior of such apps, that take an SWF and make a windowless EXE out of them. Just take a look at the attached file. Please note that the BG is semi-transparent, the labels are anti-aliased with a drop shadow. This is my old solution using Adobe AIR (Flash). I'd like to replicate that as closely as possible. I really hope some good soul will help me with this. Thank you.
  8. First off, I still learning Autoit, and so hopefully this hasn't been answered before on the forum and I just overlooked it... I've been testing/tinkering/researching and can't seem to code what I want. So I'm hoping that someone here can lend me a hand. I'm trying to come up with a 3-stage, flicker-free, .PNG-based button. I'm also looking for this method to let me tab between one of these buttons and other input fields on the same GUI. Essentially I'm wanting to have a button that shows the typical states (normal, hover, pressed) without flickering. And of course, so I can have multiple buttons on the same GUI too. Has anyone gotten this type of thing to work consistently and care to share some code? I should mention that I did get something to work, but it seems kind of overkill and clunky (it uses child GUIs as buttons). So I'm hoping one of you Autoit gurus have a better, sleeker, solution I can take advantage of. Thanks!
  9. Thanks to the help of a couple forum members I got a web png loaded onto a button. I also want to do this with an image list. *Jump to the last code snippet (Slim Version) if you want to just see what I have so far. Here is a basic example image list that works from locally stored bmp files. I would like to replace the bitmaps with jpegs or png's from the internet: #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Example() Func Example() Local $idListview, $hImage Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images" GUICreate("ImageList AddBitmap", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create(16, 32) _GUIImageList_AddBitmap($hImage, $sPath & "\Red.bmp") _GUICtrlListView_SetImageList($idListview, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($idListview, "Items", 120) ; Add items _GUICtrlListView_AddItem($idListview, "Item 1", 0) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example I tried integrating code from the working button example below that grabs a png file #include <GDIplus.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> _GDIPlus_Startup() Global $myImage = "http://icons.iconarchive.com/icons/hopstarter/soft-scraps/64/User-Administrator-Blue-icon.png" Global $GDIbmpLarge = _GDIPlus_BitmapCreateFromMemory(InetRead($myImage), 1) ;this is a GDI bitmap Global $GDIplusLarge = _GDIPlus_BitmapCreateFromHBITMAP($GDIbmpLarge) ;convert GDI to GDIPlus bitmap Global $hGUI = GUICreate("Bitmap from inet", 540, 396, -1, -1) GUISetBkColor(0xFFFFFF) Global $iBtnL = GUICtrlCreateButton("", 65, 89, 72, 72, $BS_BITMAP) , $hBtnL = GUICtrlGetHandle($iBtnL) _WinAPI_DeleteObject(_SendMessage($hBtnL, $BM_SETIMAGE, $IMAGE_BITMAP, $GDIbmpLarge)) ;this needs a GDI bitmap!!! GUISetState() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GDIPlus_BitmapDispose($GDIplusLarge) _WinAPI_DeleteObject($GDIbmpLarge) _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtnL MsgBox(0, "Info", "Large Image Downloaded from web and used directly without saving to disk first!") EndSwitch Until False Here is what I tried but it doesn't work: #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GDIplus.au3> ; Needed for GDI functions Example() Func Example() Local $idListview, $hImage Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images" GUICreate("ImageList AddBitmap", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create(16, 32) $webImage = "http://icons.iconarchive.com/icons/hopstarter/soft-scraps/64/User-Administrator-Blue-icon.png" ; This line works-> _GUIImageList_AddBitmap($hImage, $sPath & "\Red.bmp") Global $GDIbmpLarge = _GDIPlus_BitmapCreateFromMemory(InetRead($webImage), 1) ;this is a GDI bitmap Global $GDIplusLarge = _GDIPlus_BitmapCreateFromHBITMAP($GDIbmpLarge) ;convert GDI to GDIPlus bitmap ; This doesn't work -> _GUIImageList_AddBitmap($hImage, _GDIPlus_BitmapCreateFromHBITMAP($GDIbmpLarge)) ; This doesn't work -> _GUIImageList_AddBitmap($hImage, _GDIPlus_BitmapCreateFromHBITMAP($GDIplusLarge)) _GUICtrlListView_SetImageList($idListview, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($idListview, "Items", 120) ; Add items _GUICtrlListView_AddItem($idListview, "Item 1", 0) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example *Slim version (No comments) #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GDIplus.au3> Example() Func Example() Local $idListview, $hImage GUICreate("ImageList AddBitmap", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create(16, 32) $webImage = "http://icons.iconarchive.com/icons/hopstarter/soft-scraps/64/User-Administrator-Blue-icon.png" Global $GDIbmpLarge = _GDIPlus_BitmapCreateFromMemory(InetRead($webImage), 1) ;this is a GDI bitmap Global $GDIplusLarge = _GDIPlus_BitmapCreateFromHBITMAP($GDIbmpLarge) ;convert GDI to GDIPlus bitmap ; This doesn't work -> _GUIImageList_AddBitmap($hImage, _GDIPlus_BitmapCreateFromHBITMAP($GDIplusLarge)) _GUICtrlListView_SetImageList($idListview, $hImage, 1) _GUICtrlListView_AddColumn($idListview, "Items", 120) _GUICtrlListView_AddItem($idListview, "Item 1", 0) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc
  10. I'm trying to use '?do=embed' frameborder='0' data-embedContent>> but none of the examples work. Mostly, I'm just not seeing any pictures, just nothing, a window with some text but no picture. What am I doing wrong? Do these examples work for anybody else?
  11. I'd like to load a BMP file then change chosen color (0xFF00FF) to transparent and save it as PNG file. I'm using a code from other thread. I've modified it a little, but it still doesn't work. My program displays image with transparent color correctly, however saves a black image file. #include <Constants.au3> #include <WinAPIEx.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> Global Const $STM_SETIMAGE = 0x0172 Global Const $STM_GETIMAGE = 0x0173 $hForm = GUICreate('MyGUI', 400, 400) $Pic = GUICtrlCreatePic('', 50, 50, 144, 87) $hPic = GUICtrlGetHandle(-1) _GDIPlus_Startup() $hDstDC = _WinAPI_CreateCompatibleDC(0) $hBitmap = _WinAPI_CreateSolidBitmap(0, _WinAPI_GetSysColor($COLOR_3DFACE), 144, 87, 0) $hDstSv = _WinAPI_SelectObject($hDstDC, $hBitmap) $hSrcDC = _WinAPI_CreateCompatibleDC(0) $hImg = _WinAPI_LoadImage(0, @ScriptDir & '\piclvq.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE) $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hImg) _WinAPI_TransparentBlt($hDstDC, 0, 0, 144, 87, $hSrcDC, 0, 0, 144, 87, 0xFF00FF) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hForm) $hImage = _GDIPlus_BitmapCreateFromGraphics(144, 87, $hGraphic) ; Save resultant image _GDIPlus_ImageSaveToFile($hImage, "My_transparent_image.png") _WinAPI_SelectObject($hDstDC, $hDstSv) _WinAPI_DeleteDC($hDstDC) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteObject($hImg) _WinAPI_DeleteObject(_SendMessage($hPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)) $hPic = _SendMessage($hPic, $STM_GETIMAGE) If $hPic <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf GUISetState() Do Until GUIGetMsg() = -3 piclvq.bmp
  12. So, at first, I just wanted a transparent png splash screen and the idea came to me to simulate their movements just for fun and it gives this : 3 examples #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> Dim $_GuiDelete $sPngUrl = 'http://s21.postimg.org/4hofttn9z/20141102175221.png' $sPngPath = @TempDir & '\temp1.png' If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 ) _GDIPlus_Startup () $hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath ) $iWidth = _GDIPlus_ImageGetWidth ( $hImage ) $iHeight = _GDIPlus_ImageGetHeight ( $hImage ) $fRatio = $iWidth / $iHeight ; example 1 For $iWidth = 200 To @DesktopWidth/2 Step 10 $_Gui = GUICreate ( 'gui', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) ) $hImage = _ImageResize ( $sPngPath, $iWidth, $iWidth / $fRatio ) _SetBitMap ( $_Gui, $hImage, 255, $iWidth, $iWidth / $fRatio ) GUISetState ( @SW_SHOW ) Next Sleep ( 2000 ) _GDIPlus_GraphicsDispose ( $hImage ) _GDIPlus_Shutdown () While Not $_GuiDelete $_GuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) ) WEnd Sleep ( 3000 ) ; example 2 $sPngUrl = 'http://s17.postimg.org/v95y9tnvj/20141102180621.png' $sPngPath = @TempDir & '\temp2.png' If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 ) _GDIPlus_Startup () $hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath ) $iWidth = _GDIPlus_ImageGetWidth ( $hImage ) $iHeight = _GDIPlus_ImageGetHeight ( $hImage ) $fRatio = $iWidth / $iHeight For $iWidth = 50 To @DesktopWidth/3 Step 10 $_Gui = GUICreate ( 'gui', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) ) $hImage = _ImageResize ( $sPngPath, $iWidth, $iHeight ) _SetBitMap ( $_Gui, $hImage, 255, $iWidth, $iHeight ) GUISetState ( @SW_SHOW ) Next Sleep ( 3000 ) _GDIPlus_GraphicsDispose ( $hImage ) _GDIPlus_Shutdown () $_GuiDelete= Not $_GuiDelete While Not $_GuiDelete $_GuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) ) WEnd Sleep ( 2000 ) ; example 3 $sPngUrl = 'http://s11.postimg.org/5xco0uw77/20141102174904.png' $sPngPath = @TempDir & '\temp3.png' If Not FileExists ( $sPngPath ) Then InetGet ( $sPngUrl, $sPngPath, 1 ) _GDIPlus_Startup () $hImage = _GDIPlus_ImageLoadFromFile ( $sPngPath ) $iWidth = _GDIPlus_ImageGetWidth ( $hImage ) $iHeight = _GDIPlus_ImageGetHeight ( $hImage ) $fRatio = $iWidth / $iHeight For $iWidth = 300 To @DesktopWidth/2 Step 10 $_Gui = GUICreate ( '', $iWidth , $iWidth / $fRatio, -1, -1, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) ) $hImage = _ImageResize ( $sPngPath, $iWidth, $iHeight ) _SetBitMap ( $_Gui, $hImage, 255, $iWidth, $iWidth / $fRatio ) GUISetState ( @SW_SHOW ) Next Sleep ( 3000 ) _GDIPlus_GraphicsDispose ( $hImage ) _GDIPlus_Shutdown () $_GuiDelete= Not $_GuiDelete While Not $_GuiDelete $_GuiDelete= Not GUIDelete ( WinGetHandle ( 'gui' ) ) WEnd Exit Func _SetBitmap ( $hGUI, $hImage, $iOpacity, $n_width, $n_height ) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC ( 0 ) $hMemDC = _WinAPI_CreateCompatibleDC ( $hScrDC ) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap ( $hImage ) $hOld = _WinAPI_SelectObject ( $hMemDC, $hBitmap ) $tSize = DllStructCreate ( $tagSIZE ) $pSize = DllStructGetPtr ( $tSize ) DllStructSetData ( $tSize, 'X', $n_width ) DllStructSetData ( $tSize, 'Y', $n_height ) $tSource = DllStructCreate ( $tagPOINT ) $pSource = DllStructGetPtr ( $tSource ) $tBlend = DllStructCreate ( $tagBLENDFUNCTION ) $pBlend = DllStructGetPtr ( $tBlend ) DllStructSetData ( $tBlend, 'Alpha', $iOpacity ) DllStructSetData ( $tBlend, 'Format', 1 ) _WinAPI_UpdateLayeredWindow ( $hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA ) _WinAPI_ReleaseDC ( 0, $hScrDC ) _WinAPI_SelectObject ( $hMemDC, $hOld ) _WinAPI_DeleteObject ( $hBitmap ) _WinAPI_DeleteDC ( $hMemDC ) EndFunc ;==> _SetBitmap () Func _ImageResize ( $sInImage, $newW, $newH, $sOutImage = '' ) Local $oldImage, $GC, $newBmp, $newGC If $sOutImage = '' Then _GDIPlus_Startup () $oldImage = _GDIPlus_ImageLoadFromFile ( $sInImage ) $GC = _GDIPlus_ImageGetGraphicsContext ( $oldImage ) $newBmp = _GDIPlus_BitmapCreateFromGraphics ( $newW, $newH, $GC ) $newGC = _GDIPlus_ImageGetGraphicsContext ( $newBmp ) _GDIPlus_GraphicsDrawImageRect ( $newGC, $oldImage, 0, 0, $newW, $newH ) _GDIPlus_GraphicsDispose ( $GC ) _GDIPlus_GraphicsDispose ( $newGC ) _GDIPlus_ImageDispose ( $oldImage ) If $sOutImage = '' Then Return $newBmp Else _GDIPlus_ImageSaveToFile ( $newBmp, $sOutImage ) _GDIPlus_BitmapDispose ( $newBmp ) _GDIPlus_Shutdown () Return 1 EndIf EndFunc ;==> _ImageResize () gui erasure is a bit jerky i don't know why...
  13. I'm writing a script which displays the png image in gui, the image size is not fixed (up to 50 * 50 pixels). So I had some problems with it: 1. After pressing the button, image display correctly, but after minimum and restore windows, image display inaccurate (resized to 50 * 50) 2. After the display the image 2, image 1 and image 2 overlap How to solve this problem, thanks for the help Sorry, my english is bad #include <GDIPlus.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) _GDIPlus_Startup() #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 137, 67, 381, 238) GUISetOnEvent($GUI_EVENT_CLOSE, "_OnExit") $Pic1 = GUICtrlCreatePic("", 8, 8, 50, 50) $Button1 = GUICtrlCreateButton("Button1", 64, 8, 67, 25) GUICtrlSetOnEvent(-1, "_IMG") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func _OnExit() _GDIPlus_Shutdown() Exit EndFunc Func _IMG() MsgBox(0, "", "Show images 1") $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\icons1.png") $aBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($Pic1, 0x0172, 0, $aBitmap)) _WinAPI_DeleteObject($aBitmap) MsgBox(0, "", "Show images 2") $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\icons2.png") $aBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject(GUICtrlSendMsg($Pic1, 0x0172, 0, $aBitmap)) _WinAPI_DeleteObject($aBitmap) EndFunc
  14. Identicon.au3 v0.8 A simple UDF to create identicons or visual representations of any hash value. Based on Don Park's original Identicon program. Main features: 3x3 and 4x4 grid patterns.Aside from rotational symmetry there are also checkerboard and Space Invader (mirror symmetry) patterns.Adapted to handle hashes up to SHA512.Save as PNG, JPG, GIF or BMP identicons.Alpha-transparency support for PNG.The UDF and a demo:Identicon.au3 Identicon-Demo.au3 Version 0.8: * Initial public release. To do: * In the checkerboard pattern there is a bias for diamond shapes. * Improve image saving, BMP, GIF and JPG suck, much artifacts and dithering. * Transparency doesn't work with GIF (and BMP?) due to the wrong Bitmap format. * Add some more unique sprite shapes and preferably cap the shape arrays at powers of two as BitAND is faster than a modulus operation.
  15. I know there are snippet threads, but I'd like this one to be specific. I've see quite a few neat GDI+ code snippets (UEZ and Progandy come to mind first) to manipulate, create, etc, and I thought it'd be neat to be able to find them under one thread. I'm going to reserve the next 3 posts because I'm unsure at the moment if it's the "Quote" or "Spoiler" bbcode tags that has the 10 limit. You can link or post the snippets you find or create and I'll title them and put them in the threads for everyone to find. ( Going to have to remember to edit with regular editor! ) Some of these may not have titles, so I may create my own, if the author(s) want(s) a different one, let me know. _GDIPlus_WaterMark.au3 - Author: UEZ - Added: 2012-10-13 - Updated: _GDIPlus_BMPFromMemory – Author UEZ – Added: 2012-10-14 – Updated: Example – Needle Movement (4bit example provided, link to 32bit found in code) – Author: UEZ - Added: 2012-10-14 – Updated:
  16. Hi All, Is there any UDF available for converting RAW image format to PNG format? Thanks BlackEvil
  17. After reading a topic that supposedly has this fixed/solved - I am trying this - dependancy udf #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Res_File_Add=glasses.png, 10, glasses_png #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> #include "resources.au3" _Main() Func _Main() Local $listview, $hImage Local $Wow64 = "" If @AutoItX64 Then $Wow64 = "\Wow6432Node" Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $Wow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images" GUICreate("ImageList AddBitmap", 400, 300) $listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState() ; Load images $hImage = _GUIImageList_Create(16, 32, 5, 3) _GUIImageList_AddBitmap($hImage, $sPath & "\Red.bmp") _GUIImageList_AddBitmap($hImage, $sPath & "\Green.bmp") _GUIImageList_AddEx($hImage, "glasses_png") _GUICtrlListView_SetImageList($listview, $hImage, 1) ; Add columns _GUICtrlListView_AddColumn($listview, "Items", 120) ; Add items _GUICtrlListView_AddItem($listview, "Item 1", 0) _GUICtrlListView_AddItem($listview, "Item 2", 1) _GUICtrlListView_AddItem($listview, "Item 3", 2) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Func _GUIImageList_AddEx($hImageList, $sResource) Local $handleimg = _ResourceGet($sResource, $RT_BITMAP) _GUIImageList_Add($hImageList, $handleimg) _WinAPI_DeleteObject($handleimg) Return 1 EndFunc ;==>_GUIImageList_AddEx But no avail, i am thinking am i doing some stupid mistake here but cant seem to find it...
×
×
  • Create New...