Jump to content

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


JScript
 Share

Recommended Posts

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

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

*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!

Link to comment
Share on other sites

  • 1 month later...
  • 2 years later...
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

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!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • 2 weeks later...

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!

Link to comment
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
 Share

×
×
  • Create New...