Jump to content
JScript

_GUIResourcePic.au3 (UDF) - Supports GIF animation using GDI+

Recommended Posts

JScript

Function Reference


_GUIResourcePic.au3

Functions related to the image control in the GUI.

Sintax:

_GUICtrlPic_Create( FileName, Left, Top [, Width [, Height [, Style [, ExStyle ]]]]]] )
_GUICtrlPic_SetImage( controlID, FileName [, FixSize ]])
_GUICtrlPic_Delete( controlID )
_GUICtrlPic_Release( controlID )
_GUICtrlPic_SetState( controlID, state )
_GUICtrlPic_GetInfo( FileName or Control ID )

Supports:

; Images in the format: .bmp, .jpg, .png, .gif {animated} and other formats of files for resources (.exe, .dll, .ocx, .cpl...).
; For the "resources", use the "FileName" in this format:
"MyFile.ext|RessourceName|ResourceType".
; It can be a URL path as well!

Download:

Version: 1.8.2012.2600b

_GUIResourcePic_(RedirectLink).html

17.0k (Previous downloads: 140)

Example_Include_HD_GIF_(RedirectLink).html

36.08k (Previous downloads: 135)

Note: Added new function! I've made significant changes in the code, including the syntax of some functions!

Now uses GDI+ to render the images.

Example of use is included!

Sample:

CPU in 0,60%.

http://www.youtube.com/watch?v=NZZB-G9C1Kg

Direct download: _GUIResourcePic.mp4

Fixes:

1.8.2012.2600b

  • Add -> _GUICtrlPic_Release() to remove image and frees memory used by the control without deleting it!
  • Add -> Internal function __GRP_WM_DESTROY(), reason: If the window is closed, ensures that the memory is released if the control has not been deleted by _GUICtrlPic_Delete() function!
  • FIX -> You can use the native function GUICtrlDelete() to delete a control from _GUICtrlPic_Create()!
  • FIX -> _GUICtrlPic_SetImage() did not remove the previous image, thanks to Belini.
1.8.0312.2600b
  • 03/08/2012 -> Now you can use the function _GUICtrlPic_SetImage() in the following static controls: GUICtrlCreatePic() or GUICtrlCreateLabel()!
1.7.2912.2600b
  • 29/07/2012 -> Added new function: _GUICtrlPic_GetInfo()!

    Now first build a list / array of image frames to speed up drawing!

    Resize the picture with quality, thanks to the asdf8 at

    Some bugs were corrected and the UDF has been optimized for more faster execution, thanks to Belini!

1.7.2012.2600b
  • 20/07/2012 -> Some bugs were corrected and the UDF has been optimized for faster execution!
1.07b
  • 07/07/2012 -> The UDF has been completely rewritten, now uses GDI+ to render the images.

    Based on http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=1776 and Prog@ndy work concept!

    Styles and ExStyles:

    ;----> State

    $GUI_GIFSTART ; If image is GIF animated, start/resume animation!

    $GUI_GIFSTOP ; If image is GIF animated, stop/pause animation!

    ;----> Style (GIS = Gif Image Styles)

    $GIS_ASPECTRATIOFIX ; Fix the image size based on aspect ratio.

    $GIS_HALFTRANSPARENCY ; The images are rendered with the window background color. This Style is default.

    $GIS_FULLTRANSPARENCY ; The frames are rendered in full transparency independent of the background color of the window! Note: This Style consumes more CPU because the exstyle $WS_EX_TRANSPARENT is added to each frame in real time! Not valid if the image does not have transparency!

    ;----> Default Style to _GUICtrlPic_Create()!

    $GIS_SS_DEFAULT_PIC = BitOR($GIS_HALFTRANSPARENCY, $SS_NOTIFY)

    ;----> ExStyle (GIS_EX = Gif Image Extended Styles)

    $GIS_EX_DEFAULTRENDER ; To use _GUIImageList_Draw in rendering of images, use less CPU. This ExStyle is default!

    $GIS_EX_CTRLSNDRENDER ; The frames is render using GUICtrlSendMsg, but consumes much more CPU!!! Note: If you use this ExStyle, only $GRP_FULLTRANSPARENCY is used for rendering images!

1.02b

  • 09/05/2012 -> After updating the code, the images with transparency were not being shown as they should, changed code again!
  • 09/05/2012 -> Fixes in the _GUICtrlPic_SetImage() function, the measures were not being updated according to the parameter FixSiz , identified by @Belini, thank you!

Regards,

João Carlos.

Edited by JScript
  • Like 4

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites
Tlem

Wonderful.

Tank you very much.


Best Regards.Thierry

Share this post


Link to post
Share on other sites
Tlem

Re-edit your code line 324. You have wrote :

Return Return StringTrimLeft($sGetSysColor, 4) & StringTrimLeft(StringTrimRight($sGetSysColor, 2), 2) & StringTrimRight($sGetSysColor, 4)

2x Return make an error in Scite. >_<

Edited by Tlem

Best Regards.Thierry

Share this post


Link to post
Share on other sites
JScript

Re-edit your code line 324. You have wrote :

Return Return StringTrimLeft($sGetSysColor, 4) & StringTrimLeft(StringTrimRight($sGetSysColor, 2), 2) & StringTrimRight($sGetSysColor, 4)

2x Return make an error in Scite. >_<

Thank you my friend...

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites
JScript

*New update*

Sintax:

_GUICtrlPic_Create( FileName, Left, Top [, Width [, Height [, Style [, ExStyle ]]]]]] )
_GUICtrlPic_SetImage( controlID, FileName [, FixSize ]])
_GUICtrlPic_Delete( controlID )
_GUICtrlPic_SetState( controlID, state )
Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites
DivSar

Hi,

All the pic png, gif are not transparent.

How I can have transparent background pic ???

Thanks.

Share this post


Link to post
Share on other sites
subzerostig

Thanks, I really needed this but couldn't find anything that could do this


There are 10 types of people in this world. Those that understand binary, and those that do not

Share this post


Link to post
Share on other sites
Belini
JScript

Now the UDF uses GDI+ to render the images!

Based on http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=1776 and Prog@ndy work concept.

Very low CPU usage, in most case uses 0%!!!

Gif with 720x305x24fps uses 0,12% (Core i7)

Regards,

João Carlos.


http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites
Vinh

Can I use GuiCtrlDelete to delete control create with this udf?

Share this post


Link to post
Share on other sites
JScript

Yes and no, the correct is use _GUICtrlPic_Delete (ControlID) function!

Other built-in functions can be used.

Edit: If you add the following code at the end of __GRP_DrawFrame() function, you can delete using the native function.

In which case the memory will be safely released!

If Not GUICtrlGetHandle($avGRP_CTRLIDS[$iIndex][0]) Then
; If image is GIF animated...
__GRP_ReleaseGIF($iIndex)
EndIf

Regards,

João Carlos.

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites
asdf8

Hi,

I liked this job. Slightly changed it for yourself.

Changes:

- improved use as UDF

- slightly modified to work with resource files

_GUIResourcePic.zip

Share this post


Link to post
Share on other sites
JScript

Cool, I'm very glad you liked it!

But looking at what you did, I did not see anything that no longer exist in the UDF!

You said:

- improved use as UDF

Ok, I liked

And:

- slightly modified to work with resource files

But the UDF has already work with resources, see:
; For the "resources", use the "FileName" in this format: "MyFile.ext|RessourceName|ResourceType".

In any case, thank you for the improvements! ;)

Regards,

João Carlos.

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites
asdf8

JScript,

may make sense to change the format for "resources" :

; For the "resources", use the "FileName" in this format: "RessourceName|[RessourceFile = 0[|ResourceType = 10]]".
  • Like 1

Share this post


Link to post
Share on other sites
asdf8

There is a problem - a low quality of the scaled images, and, herewith, for the animation greatly increases the CPU.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Atoxis
      By Atoxis
      Howdy, I've gone through a lot of au3 forums, and I once had a working Imagesearch script that I got from here.  However, and i'm just totally not sure how but my imagesearch scripts aren't working anymore.
      I'm not new to au3 but i'm not the most experienced with it's syntax/commands.

      Anyways, I've looked over the big threads involving imagesearch.

      Does anyone have a working Imagesearch x64 for win10 that is currently working as of the date with the post.

      Dll's and what not is fine, just when I tell the script to run, I want to be able to find the image on the screen!
      Can't find a working copy so if anyone has one please send it my way lol.

      I've taken all the imagesearch downloads and what not and have played with them but I can't get any of them working on my end, despite others saying they're working.
      Thanks.
    • odaylton
      By odaylton
      Hello everyone ,
      Text translated from Portuguese by google - please apologize for any errors

      Once again I need a light from the gurus of this wonderful website
      I am fanatic by combobox for its usability but I am not able to uncertain images within lists ...
      I know uncertain icons, and cursors but I am not able to insert gif or jpg images.
      1) How to solve this ...
      2) will the path is to convert gif into bmp and then uncertain ... how to do that?
      #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ;dados de mouse #include <WinAPIRes.au3> ;COMBO #include <GuiComboBoxEx.au3> ;Fonts #include <FontConstants.au3> ;obter imagem de arquivo #include <GDIPlus.au3> #include <WinAPIGdi.au3> Example() Func Example() Local $hGUI, $hImage, $hCombo, $hFont Local $idListview, $hImage Local $sWow64 = "" Local $Pasta = "C:\WINDOWS\Cursors\3dgarro.cur" Local $PastaROMs = @MyDocumentsDir & "\Stella\ROMs\" ;com barra no final $hGUI = GUICreate("ImageList", 500, 310) GUISetFont(14, 400, 0, "Arial") ;<<<<<<<<<<this does not work for _GUICtrlComboBoxEx_Create $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 494, 200) ;GUICtrlSetFont($hCombo, 14, 400, 0, "Arial");<<<<<<<<<<It does not work ; ;Create a handle to a font object $hFont = _WinAPI_CreateFont(30, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') ;Pass the handle to _WinAPI_SetFont _WinAPI_SetFont($hCombo, $hFont) $idListview = GUICtrlCreateListView("", 2, 50, 494, 250, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Initialize GDI+ library _GDIPlus_Startup() ; Load images $hImage = _GUIImageList_Create(120, 70, 6, 2) ;32,32,5,5) ; $DadosCombo = "Escolha|" & _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 120, 70)) ;Local $aCursors[] = [32650, 32512, 32515, 32649, 32651, 32513, 32648, 32646, 32643, 32645, 32642, 32644, 32516, 32514] For $i = 1 To 10 $sFile = FileOpenDialog("Please select an image", $PastaROMs, "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST)) If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30) $a = _GDIPlus_BitmapCreateFromFile ($sFile);<<<<< ok If @error Or Not $hImage Then MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!") Else $b=_GUIImageList_Add($hImage, $a);<<<<<< Return -1 $DadosCombo &= "|" & $i & "_img_princ.gif""|" & $b EndIf Next _GUICtrlListView_SetImageList($idListview, $hImage, 1) _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage) ; Add columns _GUICtrlListView_AddColumn($idListview, "Icons - Mouses", 350) ; Add items $a = StringSplit($DadosCombo, "|") For $i = 1 To $a[0] Step 2 _GUICtrlListView_AddItem($idListview, $a[$i], $a[$i + 1]) _GUICtrlComboBoxEx_AddString($hCombo, $a[$i], $a[$i + 1], $a[$i + 1]) Next ;AutoIt_Debugger_Command:Disable_Debug ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() ;AutoIt_Debugger_Command:Enable_Debug EndFunc ;==>Example tks
    • Xandy
      By Xandy
      MapIt is a tile world editor.  MapIt was built around the concept of reversing Dragon Warrior map images.  MapIt can take image input and produce a tile and world array.
      MapIt features Unity style dragable labels that adjust property values.

      MapParser is a C++ project that scans images for unique tiles.  MapParser is very fast.  Due to hard drive failure, many bugs were restored b/c I had to rewind many years.  Frustrated with the design, I wrote a new version from the ground up.  This New Version:  AutoIt Front-end, command line controls, and shared with the world; so that I can't lose it again.
      You can toggle the C++ MapParser off to see the difference in speeds between the MapParser CPP verse AutoIt function.  Function is named Scan_Tiles() in AutoIt.  You can also chose to download without MapParser.exe.
      At the moment Scanning a image resets the arrays, but you can add tiles after scanning.
      Images can be added as tiles without scan image at all.  Then configure settings to give your world parameters and manually fill the world data with tile indexes.
      Using the settings you can change tile size after a scan.  Example: you wanted to replace a map with different sized tiles.
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      Hotkeys, I use CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      Hotkeys are not saved to disk and thus are set to default between sessions.
      I might draw the world to pre-rendered surfaces and use them as multi-layer someday.  I do that in my AutoIt, DragonWarrior Remake but I could spend forever unsure what features are important for this.  The DW_Remake has a method of replacing a tile with a tile on two layers.  So you could replace a tree on the first layer with a grass, and a tree in the second layer.  This is all getting very confusing.
      I attempted to write the good code.  If something could be better, please advise.
      Fifth release.  Enjoy.
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
      Special thanks: @AdmiralAlkex, @Melba23, @MrCreatoR
      Main AutoIt source file: Will not run without other Includes and SDL DLLs.
      Last Update: 5/26/2018 3:45 PM EST
      REMOVED CODE BLOCK:  I was informed the this page loaded very slowly, one solution so far has been to remove the 2k lines in the code block.
      When I recieve more feedback from the User I may reduce image size or remove images.
      Next Version Added: $eSETTING_TILE_LAST_PATH I have the weekend, I want to write world layers with aBoard surfaces.  
    • lenclstr746
      By lenclstr746
      HELLO GUYS
      I'm a work on a background see and click bot project 
      I can complete it if your help me
      (using imagesearch , gdi+ and  fastfind)
    • dadalt95
      By dadalt95
      I would like to know if it's possible to pass an image recognition (captcha) system.
       
      What are the ways to achieve this?
      Just the references or links is enough for me by now.
       
      Thanks by now!
       
      Thanks!
×