Jump to content

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


JScript
 Share

Recommended Posts

About CPU usage, it is only while the frames are being scaled, after which the CPU usage drops significantly!

And about losing quality, it depends on how you're scaling the image...

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

In code I have found scaling only for animation (in functions __grp_buildlist) - there scaling occurs on each frame (loads processor) and with poor quality.

For a static image scaling is not found, images obtained with increasing very poor quality.

All this can be easily verified.

Link to comment
Share on other sites

For a static image scaling is not found, images obtained with increasing very poor quality.

Execute this example:
#include <File.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
; Local include.
#include "_GUIResourcePic.au3"

_Example()

; Example GUI
Func _Example()
    Local $bUrlImage

    GUICreate("Show a simple image with no animation", 800, 600, 0, 0)

    $bUrlImage = InetRead("http://www.autoitscript.com/site/wp-content/themes/TheCorporation/images/logo.png")

    _GUICtrlPic_Create($bUrlImage, 0, 0, 0, 0)

    GUISetState()

    _GUICtrlPic_Create($bUrlImage, 50, 50, 300, 300, $GIS_ASPECTRATIOFIX)
    _GUICtrlPic_Create($bUrlImage, 120, 120, 400, 400, $GIS_ASPECTRATIOFIX)
    _GUICtrlPic_Create($bUrlImage, 230, 230, 300, 300, $GIS_ASPECTRATIOFIX)
    _GUICtrlPic_Create($bUrlImage, 320, 320, 0, 0, $GIS_ASPECTRATIOFIX)
    _GUICtrlPic_Create($bUrlImage, 390, 390, 100, 100, $GIS_ASPECTRATIOFIX)
    _GUICtrlPic_Create($bUrlImage, 430, 430, 50, 50, $GIS_ASPECTRATIOFIX)

    While 1
        Switch GUIGetMsg()
            Case -3
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>_Example
The quality of the resized image will depend solely on the image itself, is not it?

In code I have found scaling only for animation (in functions __grp_buildlist) - there scaling occurs on each frame (loads processor) and with poor quality.

The above code it proved otherwise?

Do you have any idea how to improve the quality of images scaled and even reduce the CPU consumption while images being resized?


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

The quality of the resized image will depend solely on the image itself, is not it?

Try replacing in function _GUICtrlPic_Create :

; Check if gif is animated...

Switch $iFrameCount

Case 0

; Shows the single frame in the control.

__GRP_hImgToCtrl($iCtrlID, $hOImage, $pDimensionIDs, 0)

to :

; Check if gif is animated...
Switch $iFrameCount
Case 0
; Shows the single frame in the control.
If ($iWidth > 0 And $iWidth <> $iOWidth) Or ($iHeight > 0 And $iHeight <> $iOHeight) Then
Local $NewImage = __GDIPCreateBitmapFromScan0($iWidth, $iHeight, 0, $GDIP_PXF32ARGB, 0)
Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($NewImage)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGraphics, "int", 7)
_GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hOImage, 0, 0, $iOWidth, $iOHeight, 0, 0, $iWidth, $iHeight)
_GDIPlus_ImageDispose($hOImage)
_GDIPlus_GraphicsDispose($hGraphics)
$hOImage = $NewImage
EndIf
__GRP_hImgToCtrl($iCtrlID, $hOImage, $pDimensionIDs, 0)

and run a example.

Do you have any idea how to improve the quality of images scaled and even reduce the CPU consumption while images being resized?

In functions of the __grp_buildlist needed to change the size, only if there has been an event window $WM_SIZE Edited by asdf8
Link to comment
Share on other sites

Now it's perfect! Thanks!

In functions of the __grp_buildlist needed to change the size, only if there has been an event window $WM_SIZE

I disagree, if I want the animated GIF has different dimensions of the original without having to use the WM_SIZE event?

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

@asdf8

The final code looks like this:

; Resize the picture with quality, thanks to the asdf8!
; http://www.autoitscript.com/forum/topic/100167-guiresourcepicau3-udf-supports-gif-animation-using-gdi/page__st__20#entry1004411
If $iReSize Then
    Local $hOBitmap = __GDIPCreateBitmapFromScan0($iWidth, $iHeight, 0, $GDIP_PXF32ARGB, 0)
    Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hOBitmap)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGraphic, "int", 7)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hOImage, 0, 0, $iWidth, $iHeight)
    _GDIPlus_ImageDispose($hOImage)
    _GDIPlus_GraphicsDispose($hGraphic)
    $hOImage = $hOBitmap
EndIf
; Shows the single frame in the control.
__GRP_hImgToCtrl($iCtrlID, $hOImage, $pDimensionIDs, 0)
Thanks!

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

Link to comment
Share on other sites

Not yet, I do not like to release a version after another in a short time...

I'm doing testing and optimizing, when I fix some bugs I'll post a new version!

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

Fixes:

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!

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

Seems to be that the zip file is corrupt. Example 4 cannot be extracted.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Fixes:

1.8.0312.2600b

  • 03/08/2012 -> Now you can use the function _GUICtrlPic_SetImage() in the following static controls: GUICtrlCreatePic() or GUICtrlCreateLabel()!
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

Whats that "2600b" in your ... erm ...version number? (feels OS (XP) related to me, but my brain is withholding why I think that.)

1.7.2012.2600b

1.7.2912.2600b

1.8.0312.2600b

<major>.<month>.<[month-day:two digits][year:last 2 digits]>.<???>

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

I'll try to explain:

1. => The major version number

.8 => The current month, so I just modify the major version when the year changes

.03 => The last day on which the code was finalized and tested

12 => The current year

2600 => Tested on Windows XP (Build 2600)

b => (beta) The code is still being implemented, is not the final version.

It was a way I found to guide me in when I making changes that will be adopted in all the code I write.

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

  • 3 weeks later...

Fixes:

1.8.2012.2600b

  • Add -> _GUICtrlPic_Release() to 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.
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

  • 2 months later...
  • 1 month later...

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...