Jump to content
Sign in to follow this  
voldor

Compose Images

Recommended Posts

voldor

Hello everybody.

I would like to do a screenshot of a part of the screen and use it to compose a new image from the screenshot and one already on the disk and save the result on the disk too but i do not know how to do that.

Can anybody help me ?

Thanks for your help

Edited by voldor

Share this post


Link to post
Share on other sites
DirtDBaK

Have you tried it yourself?

Have you looked through other screen capturing scripts??

You actually have to put some effort into creating a script.


[center][/center]

Share this post


Link to post
Share on other sites
voldor

Hello,

yes i've tryied it myself using this API BMP.au3

But i'm not able to save the modified picture in a .tiff format. Do you have any idea ?

BMP.au3

Share this post


Link to post
Share on other sites
smashly

Hi, this requires aan os that has GDI+ and at least autoit 3.2.10.0

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>


$OpenImage = "C:\WINDOWS\Web\Wallpaper\Ascent.jpg"
$SaveNewImage = @ScriptDir & "\example.tif"

_CatureToImage(0, 0, 100, 100, $OpenImage, 300, 200, $SaveNewImage, "TIF")

; Parameters for _CatureToImage()
; $crX = Capture Region X coordinate of the upper left corner of the screen
; $crY = Capture Region Y coordinate of the upper left corner of the screen
; $crW = Capture Region Width of the area to capture
; $crH = Capture Region Height of the area to capture
; $iFile = Input file path that you want the capture drawn onto.
; $pX = Position X coordinate of the upper left corner of the $iFile were to draw the capture
; $pY = Position Y coordinate of the upper left corner of the $iFile were to draw the capture
; $sFile = Save file path and full name (With file extension eg: "C:\MyPic.tif")
; $Enc = Encoder used to encode the $sFile to ( eg: "BMP" , "JPG", "PNG", "TIF")

Func _CatureToImage($crX, $crY, $crW, $crH, $iFile, $pX, $pY, $sFile, $Enc)  
    Local $hImage1, $hGraphic, $hBitmap1, $hImage2, $sCLSID
    
    _GDIPlus_Startup ()

    $hImage1 = _GDIPlus_ImageLoadFromFile($iFile) 
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)

    $hBitmap1 = _ScreenCapture_Capture("", $crX, $crY, $crW, $crH)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1)

    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, $pX, $pY, $crW, $crH)

    $sCLSID = _GDIPlus_EncodersGetCLSID($Enc)

    _GDIPlus_ImageSaveToFileEx($hImage1, $sFile, $sCLSID)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_ImageDispose ($hImage1)
    _GDIPlus_ImageDispose ($hImage2)
    _WinAPI_DeleteObject ($hBitmap1)


    _GDIPlus_ShutDown ()
EndFunc

; _GDIPLus_GraphicsDrawImageRect() function is in Autoit current Beta , 
; Comment out this function below if your using Current Beta 3.2.11.0
Func _GDIPLus_GraphicsDrawImageRect($hGraphics, $hImage, $iX, $iY, $iW, $iH)
    Local $aResult
    $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectI", "hwnd", $hGraphics, "hwnd", $hImage, _
                                                        "int", $iX, "int", $iY, "int", $iW, "int", $iH)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_GDIPlus_GraphicsDrawImageRect
Cheers

Share this post


Link to post
Share on other sites
voldor

[thanks a lot for your precious help

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  

×