Jump to content
Sign in to follow this  
Celtic88

heelp GDIplus !

Recommended Posts

Celtic88

Can you determine the quality of the picture "$hHBmp" in this example 

; thank to uez
#include <GDIplus.au3>
#include <ScreenCapture.au3>

Global $STM_SETIMAGE = 0x0172
Global $ghGDIPDll

$hGUI = GUICreate("Displays an image from Hb in button control", 900, 555)
$idButton = GUICtrlCreatePic("", 0, 0, 900, 555, 0xE)
GUISetState()

_GDIPlus_Startup()
Load_BMP_From_Hb(GUICtrlGetHandle($idButton))
_GDIPlus_Shutdown()

While 1
    Sleep(10)
    $msg = GUIGetMsg()
    If $msg = -3 Or $msg = $idButton Then ExitLoop
WEnd
GUIDelete($hGUI)
Exit

Func Load_BMP_From_Hb($CTRL)
    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, 900, 555)
    _WinAPI_DeleteObject(_SendMessage($CTRL, $STM_SETIMAGE, 0, $hHBmp))
    _WinAPI_UpdateWindow($CTRL)
    _WinAPI_DeleteObject($hHBmp)
EndFunc   ;==>Load_BMP_From_hb
Edited by Mrbenkali

Share this post


Link to post
Share on other sites
JLogan3o13

Is this a quiz or are you asking how to determine pic quality?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Celtic88

I am   sooo nooob  :sweating:  My question is 

  Is it impossible to change the quality of the image without saving  thank youu  :bye:

my English is very weak   :( 

Edited by Mrbenkali

Share this post


Link to post
Share on other sites
Celtic88

Is this a quiz or are you asking how to determine pic quality?

yes Question to Answer !

Share this post


Link to post
Share on other sites
UEZ

What do you mean with "change the quality of the image" exactly? The take screenshot looks very good.

Br,

UEZ

Edited by 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Celtic88

Change the quality to weakest!

Share this post


Link to post
Share on other sites
UEZ

Something like this here?

 

#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = @DesktopWidth / 2, $iH = @DesktopHeight / 2
    Local $hGUI = GUICreate("GDI+ test", $iW , $iH, -1, -1)
    GUISetState()

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, @DesktopWidth / 2, @DesktopHeight / 2) ;create a GDI bitmap by capturing 1/4 of desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
    
    Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("jpg") ;create CLSID for a JPG image file type
    Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID) ;convert CLSID GUID to binary form and returns $tagGUID structure
    Local $pEncoder = DllStructGetPtr($tGUID) ;get pointer of $tagGUID structure
    Local $tParams = _GDIPlus_ParamInit(1) ;initialize an encoder parameter list and return $tagGDIPPENCODERPARAMS structure
    Local $tData = DllStructCreate("int Quality") ;create struct to set JPG quality setting
    DllStructSetData($tData, "Quality", 10) ;quality 0-100 (0: lowest, 100: highest)
    Local $pData = DllStructGetPtr($tData) ;get pointer from quality struct
    _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) ;add a value to an encoder parameter list
    Local $pParams = DllStructGetPtr($tParams) ;get pointer of encoder parameter list
    Local $pStream = _WinAPI_CreateStreamOnHGlobal() ;create stream
    _GDIPlus_ImageSaveToStream($hBitmap, $pStream, $pEncoder, $pParams) ;save the bitmap in JPG format in memory
    Local $hBitmapFromStream = _GDIPlus_BitmapCreateFromStream($pStream) ;create bitmap from a stream (here from the JPG in memory)
    
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)  ;create a graphics object from a window handle
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmapFromStream, 0, 0) ;display streamed image
    
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBitmapFromStream)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func _WinAPI_CreateStreamOnHGlobal($hGlobal = 0, $fDeleteOnRelease = 1)
    Local $Ret = DllCall('ole32.dll', 'long', 'CreateStreamOnHGlobal', 'handle', $hGlobal, 'bool', $fDeleteOnRelease, 'ptr*', 0)
    If @error Then Return SetError(@error, @extended, 0)
    If $Ret[0] Then Return SetError(10, $Ret[0], 0)

    Return $Ret[3]
EndFunc   ;==>_WinAPI_CreateStreamOnHGlobal

Func _GDIPlus_ImageSaveToStream($hImage, $pStream, $pEncoder, $pParams = 0)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipSaveImageToStream", "handle", $hImage, "ptr", $pStream, "ptr", $pEncoder, "ptr", $pParams)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc

Func _GDIPlus_BitmapCreateFromStream($pStream)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromStream", "ptr", $pStream, "handle*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetExtended($aResult[0], $aResult[2])
EndFunc
Br,

UEZ

Edited by UEZ
  • Like 1

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Celtic88

UEZ

Just one word . you ARE THE BEST .

Share this post


Link to post
Share on other sites
Celtic88

Another question :> how it can be put in this example 

; Example by ProgAndy
#include <ScreenCapture.au3>
#include "AVIWriter.au3" ; http://www.autoitscript.com/forum/topic/86748-avi-writing-udf/

Hotkeyset("{ESC}","close")

Break(0)


FileDelete(@DesktopDir & "\test.avi")

_StartAviLibrary()

$avi = _CreateAvi(@DesktopDir & "\test.avi", 5,200,200)

Do
    $m = MouseGetPos()
    $hBmp = _ScreenCapture_Capture("", $m[0] - 100, $m[1] - 100, $m[0] + 100, $m[1] + 100, True)
    _AddHBitmapToAvi($avi, $hBmp)
    _WinAPI_DeleteObject($hBmp)
    Sleep(200)
Until False



Func close()
    _CloseAvi($avi)
    _StopAviLibrary()
    exit
EndFunc;==>close

Share this post


Link to post
Share on other sites
UEZ

Instead of providing low quality JPGs to the function change the avi compression settings to low.

_AddHBitmapToAvi() sends uncompressed GDI bitmaps to the avi encoder that means you cannot send a JPG directly.

Check out AVIWriter Extented.au3 somewhere in the same thread how to select a compression codec.

Br,

UEZ

  • Like 1

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
Celtic88

Ah oky Thank you very much 

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
Sign in to follow this  

×