Jump to content

Recommended Posts

Posted

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.

Posted (edited)

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!

Posted (edited)

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
Posted

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!

Posted (edited)

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

Posted
Posted (edited)

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!

Posted (edited)

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

Posted

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!

  • 3 weeks later...
Posted

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!

  • 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
×
×
  • Create New...