Jump to content
Sign in to follow this  
Skitty

Gravitational lensing effect on image?

Recommended Posts

Skitty

So I've been playing with some code I've got, most of which was ripped from UEZ and created some miscellaneous useless scripts and suddenly I felt compelled to find a way to add en effect to an image that would make it look like if there is a black hole in your desktop.

I've searched and searched to no avail and now I'm here. Anyone know how to add an effect to an image as picture related?

Posted Image

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%%scriptfile%_Obfuscated.au3"
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

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

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

Global $Img = @ScriptDir&"test.png"
Global $aM_Mask, $GUI, $hwnd
Global $IMAGE_BITMAP = 0
Global $STM_SETIMAGE = 0x0172
Init()
Func Init()
_GDIPlus_Startup()
Local $hwnd = GUICreate("Test", 300, 300, -1, -1,$WS_POPUP,-1,GUICreate("ghost"));$WS_EX_TOPMOST
GUICtrlCreatePic("",0,0,400,400,-1,0x00100000); only for enable dragging of the gui
GUISetBkColor(0x000000,$hwnd)
_ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser...
GUISetState()
Local $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
Local $Pos = WinGetPos($hwnd)
Local $TmpPos = $Pos
Local $image = _GDIPlus_ImageLoadFromFile($Img)
Local $matrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($matrix, 150, 150);True)
setTrans($hwnd)
Do
  $Pos = WinGetPos($hwnd)
  If ($Pos[0] <> $TmpPos[0]) Or ($Pos[1] <> $TmpPos[1]) Then
   GUISetState(@SW_HIDE)
   _GDIPlus_BitmapDispose($image)
   Sleep(100)
   _ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser..
   $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
   $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
   $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
   $image = _GDIPlus_ImageLoadFromFile($Img)
   $matrix = _GDIPlus_MatrixCreate()
   _GDIPlus_MatrixTranslate($matrix, 150, 150);True)
   GUISetState(@SW_SHOW)
   $Pos = WinGetPos($hwnd)
   $TmpPos = $Pos
  EndIf
  ;_GDIPlus_MatrixRotate($matrix, 0.01)
  _GDIPlus_GraphicsSetTransform($backbuffer, $matrix)
  _GDIPlus_GraphicsDrawImageRect($backbuffer, $image, -150, -150, 300, 300);-150,-150)
  _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300)
  Sleep(20)
Until 0

Return
EndFunc
Func close()
    Exit
EndFunc  ;==>close
Func setTrans($hW)
Local $x, $Startx, $Endx
    $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 460, "long", 460)

    For $y = 0 To 300
        $x = Abs((150 * 150 - (150 - $y) * (150 - $y)) ^ 0.5)
        $Startx = 150 + $x
        $Endx = 300
        addRegion($Startx, $y, $Endx, $y)
        $Startx = 0
        $Endx = 150 - $x
        addRegion($Startx, $y, $Endx, $y)
    Next
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hW, "long", $aM_Mask[0], "int", 1)
EndFunc  ;==>setTrans
Func addRegion($a, $b, $c, $d)
    Local $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $a, "long", $b, "long", $c + 1, "long", $d + 1)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 3)
EndFunc  ;==>addRegion

Edit: forgot to explain the script, the script basically takes a snapshot of the background area of where the gui is going to appear and then loads the image to the gui, which is a big circle really, I want to find a way of making the picture look a little warped before adding it to the gui so it will have a black hole effect or something.

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
Werty

You could use ImageMagick...

$img = ObjCreate("ImageMagickObject.MagickImage.1")
$img.Convert("test.jpg","-implode","-1","out.jpg")

Posted Image

Edited by Werty

Share this post


Link to post
Share on other sites
Skitty

You could use ImageMagick...

$img = ObjCreate("ImageMagickObject.MagickImage.1")
$img.Convert("test.jpg","-implode","-1","out.jpg")

haha, awesome! Thanks, this is actually a little cool, now I'm gonna see what I can do with this.

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%%scriptfile%_Obfuscated.au3"
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Include <WindowsConstants.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
HotKeySet("{ESC}","close")
Global $Img = @ScriptDir&"test.png"
Global $ImgMgc = ObjCreate("ImageMagickObject.MagickImage.1")
Global $aM_Mask, $GUI, $hwnd
Global $IMAGE_BITMAP = 0
Global $STM_SETIMAGE = 0x0172
Init()
Func Init()
_GDIPlus_Startup()
Local $hwnd = GUICreate("Test", 300, 300, -1, -1,$WS_POPUP,$WS_EX_TOPMOST,GUICreate("ghost"));
GUICtrlCreatePic("",0,0,400,400,-1,0x00100000); only for enable dragging of the gui
GUISetBkColor(0x000000,$hwnd)
_ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser...
If IsObj($ImgMgc) Then
  $ImgMgc.Convert($Img,"-implode","-1",$Img)
EndIf
GUISetState()
Local $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
Local $Pos = WinGetPos($hwnd)
Local $TmpPos = $Pos
Local $image = _GDIPlus_ImageLoadFromFile($Img)
Local $matrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($matrix, 150, 150);True)
setTrans($hwnd)
Do
  $Pos = WinGetPos($hwnd)
  If ($Pos[0] <> $TmpPos[0]) Or ($Pos[1] <> $TmpPos[1]) Then
   GUISetState(@SW_HIDE)
   _GDIPlus_BitmapDispose($image)
   Sleep(100)
   _ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser..
   If IsObj($ImgMgc) Then
    $ImgMgc.Convert($Img,"-implode","-1",$Img)
   EndIf
   $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
   $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
   $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
   $image = _GDIPlus_ImageLoadFromFile($Img)
   $matrix = _GDIPlus_MatrixCreate()
   _GDIPlus_MatrixTranslate($matrix, 150, 150);True)
   GUISetState(@SW_SHOW)
   $Pos = WinGetPos($hwnd)
   $TmpPos = $Pos
  EndIf
  ;_GDIPlus_MatrixRotate($matrix, 0.01)
  _GDIPlus_GraphicsSetTransform($backbuffer, $matrix)
  _GDIPlus_GraphicsDrawImageRect($backbuffer, $image, -150, -150, 300, 300);-150,-150)
  _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300)
  Sleep(20)
Until 0

Return
EndFunc

Func close()
    Exit
EndFunc  ;==>close
Func setTrans($hW)
Local $x, $Startx, $Endx
    $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 460, "long", 460)

    For $y = 0 To 300
        $x = Abs((150 * 150 - (150 - $y) * (150 - $y)) ^ 0.5)
        $Startx = 150 + $x
        $Endx = 300
        addRegion($Startx, $y, $Endx, $y)
        $Startx = 0
        $Endx = 150 - $x
        addRegion($Startx, $y, $Endx, $y)
    Next
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hW, "long", $aM_Mask[0], "int", 1)
EndFunc  ;==>setTrans
Func addRegion($a, $b, $c, $d)
    Local $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $a, "long", $b, "long", $c + 1, "long", $d + 1)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 3)
EndFunc  ;==>addRegion

Posted Image

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
UEZ

Try this:

Lens Effect:

;original code by eukalyptus (Black Hole) - modified by UEZ
#include <gdiplus.au3>
#include <guiconstantsex.au3>
#include <screencapture.au3>
#include <windowsconstants.au3>
HotKeySet("{ESC}", "_Exit")

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)

_GDIPlus_Startup()

Global $iWidth = @DesktopWidth
Global $iHeight = @DesktopHeight

Global $iSize = 150
Global $fArea = 0.70

Global $hBmp = _ScreenCapture_Capture("", -$iSize , -$iSize, $iWidth + $iSize, $iHeight + $iSize, False)
Global $hBGBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
_WinAPI_DeleteObject($hBmp)

Global $hGui = GUICreate("Lens Effect", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor(0xABCDEF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF)

Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
;~ DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hGfxBuffer, "int", 7)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)

GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

;~ _WinAPI_ShowCursor(False)

Global $iOMPosX, $iOMPosY, $aMPos

While 1
    $aMPos = MouseGetPos()
    If $aMPos[0] <> $iOMPosX Or $aMPos[1] <> $iOMPosY Then
         _Draw()
         $iOMPosX = $aMPos[0]
         $iOMPosY = $aMPos[1]
    EndIf
    Sleep(30)
WEnd

Func _Draw()
    Local $aPos = MouseGetPos()
    $aPos[0] -= $iSize / 2
    $aPos[1] -= $iSize / 2
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)
    Local $hBitmap = _GDIPlus_BitmapCloneArea($hBGBitmap, $aPos[0] + $iSize, $aPos[1] + $iSize , $iSize, $iSize)

    Local $hTexture = _GDIPlus_TextureCreate($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)

    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iSize, $iSize, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    Local $fScale = 1
    Local $hMatrix = _GDIPlus_MatrixCreate()

    _GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $iSize, $iSize, $hTexture)
    _GDIPlus_GraphicsSetSmoothingMode($hContext, 2)

    Local $fTmp = 0
    For $i = 2 To Floor($iSize / 3.333)
        $fTmp = $i * ($iSize * $fArea) / ($iSize / 2)
        $fScale = (($iSize - $fTmp) / ($iSize - $i * 2))

        _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
        _GDIPlus_MatrixTranslate($hMatrix, $iSize / 2, $iSize / 2)
        _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
        _GDIPlus_MatrixTranslate($hMatrix, -$iSize / 2, -$iSize / 2)
        _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
        _GDIPlus_GraphicsFillEllipse($hContext, $i, $i, $iSize - $i * 2, $iSize - $i * 2, $hTexture)
    Next

    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
    _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_BrushDispose($hTexture)

    _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBitmap, $aPos[0] - 1, $aPos[1] + 1)

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc   ;==>_Draw

Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
EndFunc   ;==>WM_ERASEBKGND

Func _Exit()
    _WinAPI_ShowCursor(True)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_BitmapDispose($hBGBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit

Func _GDIPlus_TextureCreate($hImage, $iWrapMode = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "ptr", $hImage, "int", $iWrapMode, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[3]
EndFunc   ;==>_GDIPlus_TextureCreate

Func _GDIPlus_MatrixSetElements($hMatrix, $nM11, $nM12, $nM21, $nM22, $nDX, $nDY)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", $nM11, "float", $nM12, "float", $nM21, "float", $nM22, "float", $nDX, "float", $nDY)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_MatrixSetElements

Lens Effect with Black Dot:

;original code by eukalyptus (Black Hole) - modified by UEZ
#include <gdip.au3>
#include <guiconstantsex.au3>
#include <screencapture.au3>
#include <windowsconstants.au3>
HotKeySet("{ESC}", "_Exit")

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)

_GDIPlus_Startup()

Global $iWidth = @DesktopWidth
Global $iHeight = @DesktopHeight

Global $iSize = 150
Global $fArea = 0.6666

Global $hBmp = _ScreenCapture_Capture("", -$iSize , -$iSize, $iWidth + $iSize, $iHeight + $iSize, False)
Global $hBGBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
_WinAPI_DeleteObject($hBmp)

Global $hGui = GUICreate("Lens Effect", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor(0xABCDEF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF)

Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)


Global $hBrush = _CreateBrush()

GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

;~ _WinAPI_ShowCursor(False)

Global $iOMPosX, $iOMPosY, $aMPos

While 1
    $aMPos = MouseGetPos()
    If $aMPos[0] <> $iOMPosX Or $aMPos[1] <> $iOMPosY Then
         _Draw()
         $iOMPosX = $aMPos[0]
         $iOMPosY = $aMPos[1]
    EndIf
    Sleep(50)
WEnd

Func _Draw()
    Local $aPos = MouseGetPos()
    $aPos[0] -= $iSize / 2
    $aPos[1] -= $iSize / 2
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)
    Local $hBitmap = _GDIPlus_BitmapCloneArea($hBGBitmap, $aPos[0] + $iSize, $aPos[1] + $iSize , $iSize, $iSize)

    Local $hTexture = _GDIPlus_TextureCreate($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)

    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iSize, $iSize, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    Local $fScale = 1
    Local $hMatrix = _GDIPlus_MatrixCreate()

    _GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $iSize, $iSize, $hTexture)
    _GDIPlus_GraphicsSetSmoothingMode($hContext, 2)

    Local $fTmp = 0
    For $i = 2 To Floor($iSize / 3.333)
        $fTmp = $i * ($iSize * $fArea) / ($iSize / 2)
        $fScale = (($iSize - $fTmp) / ($iSize - $i * 2))

        _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
        _GDIPlus_MatrixTranslate($hMatrix, $iSize / 2, $iSize / 2)
        _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
        _GDIPlus_MatrixTranslate($hMatrix, -$iSize / 2, -$iSize / 2)
        _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
        _GDIPlus_GraphicsFillEllipse($hContext, $i, $i, $iSize - $i * 2, $iSize - $i * 2, $hTexture)
    Next

    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
    _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)

    _GDIPlus_GraphicsFillRect($hContext, 0, 0, $iSize, $iSize, $hBrush)

    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_BrushDispose($hTexture)

    _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBitmap, $aPos[0] - 1, $aPos[1] + 1)

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc   ;==>_Draw

Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
EndFunc   ;==>WM_ERASEBKGND

Func _Exit()
    _WinAPI_ShowCursor(True)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_BitmapDispose($hBGBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit

Func _CreateBrush()
    Local $fTmp = $iSize * 0.7
    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, $fTmp, $fTmp, $iSize - $fTmp * 2, $iSize - $fTmp * 2)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFF7F7F7)
    Local $aColor[2] = [1, 0x00111111]
    _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColor)
    _GDIPlus_PathBrushSetFocusScales($hBrush, 0.25, 0.25)
    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)
    _GDIPlus_PathDispose($hPath)

    Return $hBrush
EndFunc   ;==>_CreateBrush

It is a modification of eukalyptus' Black Hole example.

Br,

UEZ

Edit: add code to display also border instead of black ellipse

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
Skitty

Try this:

;original code by eukalyptus (Black Hole) - modified by UEZ
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "_Exit")

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)

_GDIPlus_Startup()

Global $iWidth = @DesktopWidth
Global $iHeight = @DesktopHeight

Global $iSize = 150
Global $fArea = 0.70

Global $hBmp = _ScreenCapture_Capture("", 0, 0, $iWidth - 1, $iHeight - 1, False)
Global $hBGBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
_WinAPI_DeleteObject($hBmp)

Global $hGui = GUICreate("Lense Effect", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor(0xABCDEF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF)

Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)

GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

;~ _WinAPI_ShowCursor(False)

Global $iOMPosX, $iOMPosY, $aMPos

While 1
    $aMPos = MouseGetPos()
    If $aMPos[0] <> $iOMPosX Or $aMPos[1] <> $iOMPosY Then
         _Draw()
         $iOMPosX = $aMPos[0]
         $iOMPosY = $aMPos[1]
    EndIf
    Sleep(50)
WEnd

Func _Draw()
    Local $aPos = MouseGetPos()
    $aPos[0] -= $iSize / 2
    $aPos[1] -= $iSize / 2
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)
    Local $hBitmap = _GDIPlus_BitmapCloneArea($hBGBitmap, $aPos[0], $aPos[1], $iSize, $iSize)

    Local $hTexture = _GDIPlus_TextureCreate($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)

    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iSize, $iSize, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    Local $fScale = 1
    Local $hMatrix = _GDIPlus_MatrixCreate()

    _GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $iSize, $iSize, $hTexture)
    _GDIPlus_GraphicsSetSmoothingMode($hContext, 2)

    Local $fTmp = 0
    For $i = 2 To Floor($iSize / 3.333)
        $fTmp = $i * ($iSize * $fArea) / ($iSize / 2)
        $fScale = (($iSize - $fTmp) / ($iSize - $i * 2))

        _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
        _GDIPlus_MatrixTranslate($hMatrix, $iSize / 2, $iSize / 2)
        _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
        _GDIPlus_MatrixTranslate($hMatrix, -$iSize / 2, -$iSize / 2)
        _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
        _GDIPlus_GraphicsFillEllipse($hContext, $i, $i, $iSize - $i * 2, $iSize - $i * 2, $hTexture)
    Next

    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
    _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_BrushDispose($hTexture)

    _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBitmap, $aPos[0] - 1, $aPos[1] + 1)

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc   ;==>_Draw

Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
EndFunc   ;==>WM_ERASEBKGND

Func _Exit()
    _WinAPI_ShowCursor(True)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_BitmapDispose($hBGBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit

Func _GDIPlus_TextureCreate($hImage, $iWrapMode = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "ptr", $hImage, "int", $iWrapMode, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[3]
EndFunc   ;==>_GDIPlus_TextureCreate

Func _GDIPlus_MatrixSetElements($hMatrix, $nM11, $nM12, $nM21, $nM22, $nDX, $nDY)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", $nM11, "float", $nM12, "float", $nM21, "float", $nM22, "float", $nDX, "float", $nDY)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_MatrixSetElements

It is a modification of eukalyptus' Black Hole example.

Br,

UEZ

That's pretty cool and saved, thanks.

Also, I wanted to ask you but didn't want to PM you, so now that you're here, I wanted to know if you could help me out by adding a little dot to the center of the image created by the script so that no matter where I move it, there would always be a black circle making it look a little more authentic, I've been trying to get some code that will change the pixel color at the very center to a black color so that it will always look like the image I posted above, if it's not asking to much.

Thanks for the examples, I find most of your GDI stuff pretty entertaining!


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
UEZ

Have a look above (post #4).

Is this what you want?

Br,

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
Skitty

Have a look above (post #4).

Is this what you want?

Br,

UEZ

wow, I really appreciate that, that's what I was after, now I'm off to implement this on the original script I posted, thanks for the help UEZ! :)


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites
Skitty

Have a look above (post #4).

Is this what you want?

Br,

UEZ

Ok, so I got back from some stuff and went back to this, and after about 3 hours... I finally got it to work, this is exactly the effect I was looking for!

#NoTrayIcon
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%%scriptfile%_Obfuscated.au3"
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Obfuscator_Ignore_Funcs=WM_DROPFILES_FUNC
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include "GDIp.au3"

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

Global $Img = @DesktopDir & "test.png"
Global $ImgMgc = ObjCreate("ImageMagickObject.MagickImage.1")

If Not IsObj($ImgMgc) Then
Exit MsgBox(16, "Error", "You need to install the ImageMagic COM object.")
EndIf

Global $aM_Mask, $GUI, $hwnd
Global $IMAGE_BITMAP = 0
Global $STM_SETIMAGE = 0x0172
Global $gaDropFiles[1]

Init()

Func Init()
_GDIPlus_Startup()
Local $hwnd = GUICreate("Test", 300, 300, -1, -1, $WS_POPUP, -1, GUICreate("ghost"));$WS_EX_TOPMOST
Local $Pic = GUICtrlCreatePic("", 0, 0, 400, 400, -1, $GUI_WS_EX_PARENTDRAG); only for enable dragging of the gui
GUISetBkColor(0x000000, $hwnd)
;_ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser...
CreateImg($hwnd, $Img, 0.50)

If IsObj($ImgMgc) Then
$ImgMgc.Convert($Img, "-implode", "-15", $Img)
EndIf

GUISetState()

Local $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

Local $Pos = WinGetPos($hwnd)
Local $TmpPos = $Pos

Local $image = _GDIPlus_ImageLoadFromFile($Img)
Local $matrix = _GDIPlus_MatrixCreate()

_GDIPlus_MatrixTranslate($matrix, 150, 150);True)
;_GDIPlus_MatrixRotate($matrix, 0.01)
_GDIPlus_GraphicsSetTransform($backbuffer, $matrix)
_GDIPlus_GraphicsDrawImageRect($backbuffer, $image, -150, -150, 300, 300);-150,-150)
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300)

setTrans($hwnd)

Local $Msg, $SEC = @SEC
While 1
Sleep(20)
$Msg = GUIGetMsg($hwnd)
Switch $Msg
Case $Pic
$Pos = WinGetPos($hwnd)
If ($Pos[0] <> $TmpPos[0]) Or ($Pos[1] <> $TmpPos[1]) Then
GUISetState(@SW_HIDE)
_GDIPlus_BitmapDispose($image)
Sleep(100)
CreateImg($hwnd, $Img, 0.50)

If IsObj($ImgMgc) Then
$ImgMgc.Convert($Img, "-implode", "-18", $Img)
EndIf

$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
$image = _GDIPlus_ImageLoadFromFile($Img)
$matrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($matrix, 150, 150);True)
GUISetState(@SW_SHOW)
$Pos = WinGetPos($hwnd)
$TmpPos = $Pos
EndIf

;_GDIPlus_MatrixRotate($matrix, 0.01)
_GDIPlus_GraphicsSetTransform($backbuffer, $matrix)
_GDIPlus_GraphicsDrawImageRect($backbuffer, $image, -150, -150, 300, 300);-150,-150)
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300)
EndSwitch
If @SEC <> $SEC Then
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300)
$SEC = @SEC
EndIf
WEnd
Return
EndFunc   ;==>Init

Func CreateImg($hGui, $ImgPath, $fArea)
If Not IsHWnd($hGui) Then
Exit MsgBox(0, "", "error")
EndIf
Local $iWidth = 300
Local $iHeight = 300
Local $iSize = 300

Local $hBmp = _ScreenCapture_CaptureWnd("", $hGui, 0, 0, $iWidth, $iHeight, False)
Local $hBGBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
Local $hBrush = _CreateBrush($iSize, $fArea)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBGBitmap)
_GDIPlus_GraphicsFillRect($hContext, 0, 0, $iSize, $iSize, $hBrush)

_GDIPlus_ImageSaveToFile($hBGBitmap, $ImgPath)

_WinAPI_DeleteObject($hBmp)
_GDIPlus_BitmapDispose($hBGBitmap)
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_BitmapDispose($hBGBitmap)

Return $ImgPath
EndFunc   ;==>CreateImg

Func _CreateBrush($iSize, $fArea)
Local $fTmp = $iSize * $fArea * 1.20
Local $hPath = _GDIPlus_PathCreate()
;_GDIPlus_PathAddEllipse($hPath, $fTmp, $fTmp, $iSize - $fTmp * 2, $iSize - $fTmp * 2)
_GDIPlus_PathAddEllipse($hPath, $fTmp - 25, $fTmp - 25, -10, -10)

Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
_GDIPlus_PathBrushSetCenterColor($hBrush, 0xFF000000)
Local $aColor[2] = [1, 0x00000000]
_GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColor)
_GDIPlus_PathBrushSetFocusScales($hBrush, 0.5, 0.5)
_GDIPlus_PathBrushSetGammaCorrection($hBrush, True)
_GDIPlus_PathDispose($hPath)

Return $hBrush
EndFunc   ;==>_CreateBrush

Func close()
_GDIPlus_Shutdown()
Exit
EndFunc   ;==>close


Func setTrans($hW)
Local $x, $Startx, $Endx
$aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 460, "long", 460)


For $y = 0 To 300
$x = Abs((150 * 150 - (150 - $y) * (150 - $y)) ^ 0.5)
$Startx = 150 + $x
$Endx = 300
addRegion($Startx, $y, $Endx, $y)
$Startx = 0
$Endx = 150 - $x
addRegion($Startx, $y, $Endx, $y)
Next

DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hW, "long", $aM_Mask[0], "int", 1)
EndFunc   ;==>setTrans

Func addRegion($a, $b, $c, $d)
Local $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $a, "long", $b, "long", $c + 1, "long", $d + 1)
DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 3)
EndFunc   ;==>addRegion

Also, I wonder why the tab spaces always disappear when I post code...

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

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  

  • Similar Content

    • Xandy
      By Xandy
      Special thanks: AdmiralAlkex, Melba23, MrCrearoR, Dragon Warrior 3, SDL
      MapIt is a tile world editor.  MapIt was built around the concept of reversing Dragon Warrior map images.  MapIt can take image input and produce a tile and world array.  
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      A full list of hotkeys can be assigned in the: Help Menu\Hotkeys
       
      MapParser is a C++ project that scans images for unique tiles. 
      MapIt can be downloaded without MapParser. MapParser can be toggled off in the Scan_Image dialog. Without MapParser, MapIt will use the Scan_Tiles() function written in AutoIt ; which is 100 * slower Idk. If MapParser.exe will not run for you:      Installing Visual C++ Redistributable for Visual Studio 2015 should fix it: https://www.microsoft.com/en-us/download/details.aspx?id=48145   
      You can start with example world and tiles.
      Example world was made following these steps:
      Started with a tile map image of DragonWarrior3 town of: Reeve From MapIt World Menu \ New \ Scan_Image dialog, I set the area to exclude the key legend to the far right of image. After scanning the map image to world and tile array.  I removed a few of the map artifacts.  More work could be done on this world; removing unwanted tiles, but it is fine for now. I saved my world to disk.  This creates folder: Worldname: Containing folder of Tiles and a Worldname.txt. Using The Gimp, I edited some tiles to have a transparent color: Stairs, Trees, Desk Tables, Chest-of-drawers, Chairs, Signs, Doors, Beds. I changed the world layers to 2: World Menu \ Properties. F9 Finds all selected tile on current layer and changes to a new selected tile on new layer. I used F9 to change all Trees on layer: 0 to Trees on layer: 1. Then I used F9 to change all Trees on layer: 0 to Grass on layer: 0  
      In this video you can see how I used the Tile Menu \ Replace From Disk option to remap tile images to my custom tiles.  Conveniently my tiles already have a transparent pixel.
      See video for how that was done:
      To use the example world:
      First unzip the world save file: http://songersoft.com/programming/mapit/worlds/Reeve_Swapped.zip From the World Menu: choose \Load Navigate to the Reeve_Swapped.txt located in the extracted zip. Or you can scan any image.
      The map images I used are here: http://www.realmofdarkness.net/dq/games/nes/dw3/maps/world
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
    • Atoxis
      By Atoxis
      Howdy, I've gone through a lot of au3 forums, and I once had a working Imagesearch script that I got from here.  However, and i'm just totally not sure how but my imagesearch scripts aren't working anymore.
      I'm not new to au3 but i'm not the most experienced with it's syntax/commands.

      Anyways, I've looked over the big threads involving imagesearch.

      Does anyone have a working Imagesearch x64 for win10 that is currently working as of the date with the post.

      Dll's and what not is fine, just when I tell the script to run, I want to be able to find the image on the screen!
      Can't find a working copy so if anyone has one please send it my way lol.

      I've taken all the imagesearch downloads and what not and have played with them but I can't get any of them working on my end, despite others saying they're working.
      Thanks.
    • lenclstr746
      By lenclstr746
      HELLO GUYS
      I'm a work on a background see and click bot project 
      I can complete it if your help me
      (using imagesearch , gdi+ and  fastfind)
    • dadalt95
      By dadalt95
      I would like to know if it's possible to pass an image recognition (captcha) system.
       
      What are the ways to achieve this?
      Just the references or links is enough for me by now.
       
      Thanks by now!
       
      Thanks!
    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix
×