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

    • 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!
    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix
    • DeathChicken
      By DeathChicken
      If possible please add or edit the comments to explain how this works.
       
      ;includes functions from other things
      #include <GDIPlus.au3>
      #include <ScreenCapture.au3>
      ;hotkeys
      HotKeySet("{ESC}", _exit)
      HotKeySet("{F1}", _scan)
      ;global variables
      Global $win_title                    ;name of the window
      Global $area_x                        ;
      Global $area_y                        ;
      Global $area_w                       ;
      Global $area_h                        ;
      Global $cursor                         ;
      Global $rect_file                      ;
      Global $hbmpscreen              ;
      Global $i=  1043                      ;moves the rect
      Global $ii=    378                      ;moves the rect
      Global $x=1044                        ;inner rect offset
      Global $y=501                          ;inner rect offset
      Global $hbmprect                    ;image inside rect
      Global $hscreen                        ;image whole screen
                                         
      _GDIPlus_Startup()                    ;?
      ;display hotkeys on screen
      ToolTip("Press F1 to scan | Press ESC to Exit",0,0)
                                          ;infinite loop to keep prog running
      While 1
          Sleep(100)
      WEnd
      Func _scan()
      ;~ reads your screen area:
      _read()
      ;~ converts screen captured into bmp
      _convert()
      ;~ .  Loads converted bmp to be read
      _loadBMP()
      ;~ compares the bmp of your scanned screen to the actual screen that is being displayed
      _compare()
      EndFunc
                                          ;reads screen
      Func _read()
          $hscreen = _ScreenCapture_CaptureWnd("", WinGetHandle($win_title), $area_x, $area_y, $area_x + $area_w, $area_y + $area_h, $cursor)
      EndFunc
                                          ;converts screen into bmp
      Func _convert()
          _GDIPlus_BitmapCreateFromHBITMAP($hscreen)
      EndFunc
                                          ;loads converted screen
      Func _loadBMP()
      _GDIPlus_BitmapCreateFromFile($rect_file)
      EndFunc
                                          ;compares savedBMP to current screen
      Func _compare()
      ;If(                              below code                                     ) = (                   below code           ) Then
      If _GDIPlus_BitmapGetPixel($hbmpscreen, ($i + $x) - $area_x, ($ii + $y) - $area_y) = _GDIPlus_BitmapGetPixel($hbmprect, $x, $y) Then
      ;display message box titled found with a message of found
      MsgBox("","","found")
      ;if above is not correct then
      EndIf
      EndFunc
                                          ;exit func
      Func _exit()
          Exit
      EndFunc
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.