Jump to content

Recommended Posts

  • 6 months later...
Posted

hi again!
any1 could change that script to fix the watermark on every resolution?

if i change x y to my monitor resolution it will doesnt work on other resolution :S

would be awesome if the watermark stays always in right side down in the corner on every resolution,

please help me

Posted (edited)

retaly,

do you mean when you maximize the GUI to fullscreen? If yes, I accidentely forgot to disable the maximize button.

The reorganisation / resizing of the GUI elements (controls) are not working properly when changing the GUI size.

Uploaded the version where the max. button is disabled.

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

Posted

i mean, im using 1024x768 resolution on my pc, and if i add x and y coordinate to 900, the watermark will be in right corner down on the screenshot, but if i change to lower or higher resolution, x and y stay 900 and it doesnt will be in the corner already, in highest resolution i see the watermark almost in center of picture, in lower i dont see watermark

i hope u understand me :S

i gave my script for my friend in .exe format, he tryed out, made one screenshot, but he use other resolution like mine and he got only one simple screenshot w/o watermark.

Posted

Ok, I will test it  what happens when I change the resolution and the script is running.

Thanks for your feedback!

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

Posted (edited)

kk

its working well if u add x 0 and y 0, the problem is if u  want to put watermark on right corner down under clock etc
i hope u understood, and ty, if u could fix it please post it, important :(

ind this script what u modified before some posts to me:
 

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

Global Const $tagGDIPCOLORMATRIX = "float m[25];"

#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Screenshot", 180, 146, 232, 134)
$Group1 = GUICtrlCreateGroup("Screenshot", 16, 8, 145, 121)
$Label1 = GUICtrlCreateLabel("Hotkey - F10", 56, 48, 65, 17)
$exit = GUICtrlCreateButton("Exit", 48, 80, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

; Initialize GDI+ library
_GDIPlus_Startup()

HotKeySet("{F10}", "screenshot")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $exit
            _GDIPlus_Shutdown()
            Exit
    EndSwitch
WEnd

Func screenshot()
    Local $hHBitmap, $hBitmap, $hBitmapStamp
    Local Static $iCounter = 0
    ; Capture screen
    $hHBitmap = _ScreenCapture_Capture()
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
    _WinAPI_DeleteObject($hHBitmap)
    $hBitmapStamp = _GDIPlus_BitmapCreateFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\logo4.gif") ; <<<<<<<<<<<< change this
    _GDIPlus_StampImage($hBitmap, $hBitmapStamp)
    ; Save image
    _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\Screenshoot" & StringFormat("%02d", $iCounter) & ".jpg")
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBitmapStamp)
    $iCounter += 1
EndFunc ;==>screenshot

Func _GDIPlus_StampImage(ByRef $hBmp, $hBmp_Stamp, $iPos = 1, $iRotation_WM = 100, $fAlpha = 0.75, $iAdjX = 0, $iAdjY = 0, $bFill = False, $iMinW = 8, $iMinH = 8)
    If $fAlpha < 0 Then $fAlpha = 0
    If $fAlpha > 1 Then $fAlpha = 1
    Local $iW = _GDIPlus_ImageGetWidth($hBmp), $iH = _GDIPlus_ImageGetHeight($hBmp)

    Local $hCtxt_Stamp = _GDIPlus_ImageGetGraphicsContext($hBmp)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hCtxt_Stamp, "int", 7)
    Local $iW_Stamp = _GDIPlus_ImageGetWidth($hBmp_Stamp), $iH_Stamp = _GDIPlus_ImageGetHeight($hBmp_Stamp)
    Local $hAttribute_Alpha = _GDIPlus_ImageAttributesCreate()
    Local $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0, 0, 0, -(1 - $fAlpha))
    Local $pColorMatrix = DllStructGetPtr($tColorMatrix)
    _GDIPlus_ImageAttributesSetColorMatrix($hAttribute_Alpha, 0, True, $pColorMatrix)
    Local $fSize = $iRotation_WM / 100, $hBrush_Fill
    If $bFill Then
        Local $hBmp_Fill = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
        $hBmp_Fill = $hBmp_Fill[6]
        Local $hCtxt_Fill = _GDIPlus_ImageGetGraphicsContext($hBmp_Fill)
        If $fSize <> 1.00 Then
            Local $iWn = Int($iW_Stamp * $fSize), $iHn = Int($iH_Stamp * $fSize)
            Local $hBmp_tmp = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWn, "int", $iHn, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
            $hBmp_tmp = $hBmp_tmp[6]
            Local $hCtxt_tmp = _GDIPlus_ImageGetGraphicsContext($hBmp_tmp)
            DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hCtxt_tmp, "int", 7)
            _GDIPlus_GraphicsDrawImageRect($hCtxt_tmp, $hBmp_Stamp, 0, 0, $iWn, $iHn)
            $hBrush_Fill = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "ptr", $hBmp_tmp, "int", 0, "int*", 0)
            $hBrush_Fill = $hBrush_Fill[3]
            _GDIPlus_BitmapDispose($hBmp_tmp)
            _GDIPlus_GraphicsDispose($hCtxt_tmp)
        Else
            $hBrush_Fill = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "ptr", $hBmp_Stamp, "int", 0, "int*", 0)
            $hBrush_Fill = $hBrush_Fill[3]
        EndIf
        _GDIPlus_GraphicsFillRect($hCtxt_Fill, 0, 0, $iW, $iH, $hBrush_Fill)
        _GDIPlus_GraphicsDrawImageRectRectIA($hCtxt_Stamp, $hBmp_Fill, 0, 0, $iW, $iH, $iAdjX, $iAdjY, $iW, $iH, $hAttribute_Alpha)
        _GDIPlus_BrushDispose($hBrush_Fill)
        _GDIPlus_GraphicsDispose($hCtxt_Fill)
        _GDIPlus_BitmapDispose($hBmp_Fill)
    Else
        Local $iX, $iY, $fW = $iW_Stamp * $fSize, $fH = $iH_Stamp * $fSize, $fX = 0, $fY = 0
        Switch $iPos
            Case 1
                $iX = Min($iMinW, $iW)
                $iY = Min($iMinH, $iH)
            Case 2
                $iX = Abs(($iW - $iW_Stamp) / 2)
                $iY = Min($iMinH, $iH)
                $fX = ($iW_Stamp - $iW_Stamp * $fSize) / 2
            Case 3
                $iX = Abs($iW - $iW_Stamp - Min($iMinW, $iW))
                $iY = Min($iMinH, $iH)
                $fX = ($iW_Stamp - $iW_Stamp * $fSize)
            Case 4
                $iX = Min($iMinW, $iW)
                $iY = Abs(($iH - $iH_Stamp) / 2)
                $fY = ($iH_Stamp - $iH_Stamp * $fSize) / 2
            Case 5
                $iX = Abs(($iW - $iW_Stamp) / 2)
                $iY = Abs(($iH - $iH_Stamp) / 2)
                $fX = ($iW_Stamp - $iW_Stamp * $fSize) / 2
                $fY = ($iH_Stamp - $iH_Stamp * $fSize) / 2
            Case 6
                $iX = Abs($iW - $iW_Stamp - Min($iMinW, $iW))
                $iY = Abs(($iH - $iH_Stamp) / 2)
                $fX = ($iW_Stamp - $iW_Stamp * $fSize)
                $fY = ($iH_Stamp - $iH_Stamp * $fSize) / 2
            Case 7
                $iX = Min($iMinW, $iW)
                $iY = Abs($iH - Min($iMinH, $iH) - $iH_Stamp)
                $fY = ($iH_Stamp - $iH_Stamp * $fSize)
            Case 8
                $iX = Abs(($iW - $iW_Stamp) / 2)
                $iY = Abs($iH - Min($iMinH, $iH) - $iH_Stamp)
                $fX = ($iW_Stamp - $iW_Stamp * $fSize) / 2
                $fY = ($iH_Stamp - $iH_Stamp * $fSize)
            Case 9
                $iX = Abs($iW - $iW_Stamp - Min($iMinW, $iW))
                $iY = Abs($iH - Min($iMinH, $iH) - $iH_Stamp)
                $fX = ($iW_Stamp - $iW_Stamp * $fSize)
                $fY = ($iH_Stamp - $iH_Stamp * $fSize)
        EndSwitch
        _GDIPlus_GraphicsDrawImageRectRectIA($hCtxt_Stamp, $hBmp_Stamp, 0, 0, $iW_Stamp, $iH_Stamp, $iX + $fX + $iAdjX, $iY + $fY + $iAdjY, $fW, $fH, $hAttribute_Alpha)
    EndIf
    _GDIPlus_GraphicsDispose($hCtxt_Stamp)
    _GDIPlus_ImageAttributesDispose($hAttribute_Alpha)
EndFunc ;==>_GDIPlus_StampImage

Func Min($a, $b)
    If $a < $b Then Return $a
    Return $b
EndFunc ;==>Min

Func _GDIPlus_ColorMatrixCreateTranslate($nRed, $nGreen, $nBlue, $nAlpha = 0)
    Local $ii, $tCM, $aFactors[4] = [$nRed, $nGreen, $nBlue, $nAlpha]
    $tCM = _GDIPlus_ColorMatrixCreate()
    For $ii = 0 To 3
        DllStructSetData($tCM, "m", $aFactors[$ii], 21 + $ii)
    Next
    Return $tCM
EndFunc ;==>_GDIPlus_ColorMatrixCreateTranslate

Func _GDIPlus_ColorMatrixCreate()
    Return _GDIPlus_ColorMatrixCreateScale(1, 1, 1, 1)
EndFunc ;==>_GDIPlus_ColorMatrixCreate

Func _GDIPlus_ColorMatrixCreateScale($nRed, $nGreen, $nBlue, $nAlpha = 1)
    Local $tCM
    $tCM = DllStructCreate($tagGDIPCOLORMATRIX)
    DllStructSetData($tCM, "m", $nRed, 1)
    DllStructSetData($tCM, "m", $nGreen, 7)
    DllStructSetData($tCM, "m", $nBlue, 13)
    DllStructSetData($tCM, "m", $nAlpha, 19)
    DllStructSetData($tCM, "m", 1, 25)
    Return $tCM
EndFunc ;==>_GDIPlus_ColorMatrixCreateScale

Func _GDIPlus_ImageAttributesSetColorMatrix($hImageAttributes, $iColorAdjustType = 0, $fEnable = False, $pClrMatrix = 0, $pGrayMatrix = 0, $iColorMatrixFlags = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetImageAttributesColorMatrix", "handle", $hImageAttributes, "int", $iColorAdjustType, "int", $fEnable, "ptr", $pClrMatrix, "ptr", $pGrayMatrix, "int", $iColorMatrixFlags)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_ImageAttributesSetColorMatrix

Func _GDIPlus_ImageAttributesCreate()
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateImageAttributes", "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[1]
EndFunc ;==>_GDIPlus_ImageAttributesCreate

Func _GDIPlus_ImageAttributesDispose($hImageAttributes)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDisposeImageAttributes", "handle", $hImageAttributes)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_ImageAttributesDispose

Func _GDIPlus_GraphicsDrawImageRectRectIA($hGraphics, $hImage, $nSrcX, $nSrcY, $nSrcWidth, $nSrcHeight, $nDstX, $nDstY, $nDstWidth, $nDstHeight, $hImageAttributes = 0, $iUnit = 2)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectRect", "handle", $hGraphics, "handle", $hImage, "float", $nDstX, "float", $nDstY, "float", $nDstWidth, "float", $nDstHeight, "float", $nSrcX, "float", $nSrcY, "float", $nSrcWidth, "float", $nSrcHeight, "int", $iUnit, "handle", $hImageAttributes, "int", 0, "int", 0)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_GraphicsDrawImageRectRectIA
Edited by retaly
Posted (edited)

What I tried:

called the function _GDIPlus_StampImage($hBitmap, $hBitmapStamp, 9) at 1366x768 and pressed F10 -> image is the right bottom corner

changed the resolution to 800x600 and pressed F10 again -> image is still in the right bottom corner

 

How did you call the function?

 

$iPos is from 1 to 9 and $iAdjX / $iAdjY are adjustments only relatively to the $iPos. It makes no sense to use $iPos = 1 and add 900 px to $iAdjX / $iAdjY and change the screen resolution!

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

  • 10 months later...
Posted

UEZ, When I try to compile this today I get a lot of errors about "Already defined" functions, in _GDIPlus_

AutoIT 3.3.10.2 
OS WIN_7 
Build 7601 
Service Pack 1
Language 0406 (Danish)

Result here (expires 26 Oct 2014)

I am just a hobby programmer, and nothing great to publish right now.

  • 3 years later...
Posted

Put a ' ; ' in front of your line 55. $STM_SETIMAGE is declared in static constants.au3.

Or remove the line. It is no longer needed.

My best guess is that some of the includes have changed in the last 3 years since this thread has been active.

I ran into the same issue, that was the fix.

I copy the error "$STM_SETIMAGE" shown & look for it in all of the includes. If it has the same value you do not need that line.

If it has a different value you need advice from someone besides me.

 

  • 4 years later...
Posted

Hello!

i was looking for a watermark prog and i found your work.

i thought i test it.. but the irst rows generate error like this:

"D:\vkrisz81\AutoIt Watermark Image\Watermark Image.au3"(55,31) : error: $STM_SETIMAGE previously declared as a 'Const'.
Global  $STM_SETIMAGE = 0x0172

what can i do?

Posted
22 minutes ago, vkrisz81 said:

Hello!

i was looking for a watermark prog and i found your work.

i thought i test it.. but the irst rows generate error like this:

"D:\vkrisz81\AutoIt Watermark Image\Watermark Image.au3"(55,31) : error: $STM_SETIMAGE previously declared as a 'Const'.
Global  $STM_SETIMAGE = 0x0172

what can i do?

Just delete that line and it should work.

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

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