Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
- #include <ScreenCapture.au3>
- ; Opt('MustDeclareVars', 1)
- ; $Path=@ScriptDir & "\широкий.jpg"
- ; $Path=@ScriptDir & "\высокий.jpg"
- ; $Path=@ScriptDir & "\Fender_1920x1620.jpg"
- $Path=@ScriptDir & "\0001.jpg"
- _Main($Path, @DesktopWidth, @DesktopHeight)
- Func _Main($Path, $DW, $DH)
- Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic, $width, $height
- ; $DW+=100
- ; $DH+=100
- _GDIPlus_Startup()
- $hImage2=_GDIPlus_ImageLoadFromFile($Path)
- ; If @error Then MsgBox(0, 'Ошибка', @error)
- ; Capture screen region
- $hBitmap2 = _ScreenCapture_Capture()
- $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)
- ; $hImage1=_GDIPlus_BitmapCloneArea($hImage2, 0, 0, $DW, $DH) ; клон с величиной по размеру экрана
- ; на один пиксел большего размера возвращает _ScreenCapture_Capture
- ; $wP = _GDIPlus_ImageGetWidth($hImage1)
- ; $hP = _GDIPlus_ImageGetHeight($hImage1)
- ; MsgBox(0, 'Message', $wP &@CRLF& $hP)
- ; вычисляем коэффициент трансформации
- $wP = _GDIPlus_ImageGetWidth($hImage2)
- $hP = _GDIPlus_ImageGetHeight($hImage2)
- If $wP/$DW<$hP/$DH Then
- $k=$DW/$wP
- ; MsgBox(0, '1', 'коэффициент=' &@CRLF& $k)
- Else
- $k=$DH/$hP
- ; MsgBox(0, '2', 'коэффициент=' &@CRLF& $k)
- EndIf
- If $k<1 Then
- $x1=($DW-$wP)/2
- $y1=($DH-$hP)/2
- Else
- $x1=0
- $y1=0
- EndIf
- ; дескриптор / сдвиг1 / сдвиг2 / ширина / высота
- ; $hImage2=_GDIPlus_BitmapCloneArea($hImage1, 0, 0, $DW, $DH)
- ; Draw one image in another
- $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
- ; поворот матрицы
- $hMatrix = _GDIPlus_MatrixCreate()
- ; _GDIPlus_MatrixRotate($hMatrix, 45) ; поворот
- ; трансформация
- ; $k=0.4
- ; $k=Round($k, 4)
- _GDIPlus_MatrixScale($hMatrix, $k, $k)
- _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
- _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, $x1, $y1)
- ; Сохранение результата
- _GDIPlus_ImageSaveToFile($hImage1, @ScriptDir & "\Fender_New.jpg")
- ; Очистить ресурсы
- _GDIPlus_MatrixDispose($hMatrix)
- _GDIPlus_ImageDispose($hImage1)
- _GDIPlus_ImageDispose($hImage2)
- _WinAPI_DeleteObject($hBitmap1)
- _WinAPI_DeleteObject($hBitmap2)
- _GDIPlus_Shutdown()
- EndFunc ;==>_Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement