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

    • Miliardsto
      By Miliardsto
      hello Im wondering if it is possible to process image in autoit like this
      1. firstly there is colorfull wallpaper
      2. Fill all colors (exception rose color) - with white
      3. Fill rose color with black color
      I see Gdi functions have things to manipulate images
      https://imgur.com/a/lFdY26g
    • UEZ
      By UEZ
      Here a little tool to display the histogram of an image (inspired by this thread):
      )

      ;#AutoIt3Wrapper_Icon=Histogram1.ico #AutoIt3Wrapper_Compile_Both=y ;#AutoIt3Wrapper_Res_Field=CompanyName|UEZ Software Development ;#AutoIt3Wrapper_Res_Field=ProductName|GDI+ Show Histogram ;#AutoIt3Wrapper_Res_Field=ProductVersion|%AutoItVer% #AutoIt3Wrapper_Res_Fileversion=0.9.8.0 ;#AutoIt3Wrapper_Res_Field=Build|2015-07-10 #AutoIt3Wrapper_Res_LegalCopyright=UEZ Software Development #AutoIt3Wrapper_Res_Language=1033 ;#AutoIt3Wrapper_Res_Field=URL|http://www.autoitscript.com/forum/index.php?showtopic=147777 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UPX_Parameters=--best --lzma #AutoIt3Wrapper_Run_After=upx.exe --best --lzma "GDI+ Show Histogram_x64.exe" #AutoIt3Wrapper_UseX64=n #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Opt("MouseCoordMode", 2) _GDIPlus_Startup() If @error Then Exit MsgBox(0x40010, "Error", "GDI+ Show Histogram can run on operating systems Vista or newer only!") Global $ghGDIPDll = $__g_hGDIPDll, $aRes Global Const $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]") Global Const $aFullScreen = WinGetPos($hFullScreen) Global Enum $HistogramFormatARGB, $HistogramFormatPARGB, $HistogramFormatRGB, $HistogramFormatGray, _ ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms534129(v=vs.85).aspx $HistogramFormatB, $HistogramFormatG, $HistogramFormatR, $HistogramFormatA Global $tStructChannel0 = DllStructCreate("uint channel0[256]") Global $pStructChannel0 = DllStructGetPtr($tStructChannel0) Global $tStructChannel1 = DllStructCreate("uint channel1[256]") Global $pStructChannel1 = DllStructGetPtr($tStructChannel1) Global $tStructChannel2 = DllStructCreate("uint channel2[256]") Global $pStructChannel2 = DllStructGetPtr($tStructChannel2) Global $tStructChannel3 = DllStructCreate("uint channel3[256]") Global $pStructChannel3 = DllStructGetPtr($tStructChannel3) Global $s, $sFile, $hImage, $bImgLoaded = False, $aLuminosity[257], $aCRGB[257] Global Const $STM_SETIMAGE = 0x0172, $iLineJoinBevel = 1, $frY = 0.299, $fgY = 0.587, $fbY = 0.114 Global Const $hGUI = GUICreate("GDI+ Show Histogram v0.98 beta by UEZ build 2015-07-13", 468, 310, -1, -1, Default, Default) GUISetBkColor(0xFFFFFF, $hGUI) Global Const $sLabel_Titel_Txt = "GDI+ Show Histogram" Global Const $iPosX_Label = 20, $iPosY_Label = 12 Global Const $iLabel_Titel_Shadow = GUICtrlCreateLabel($sLabel_Titel_Txt, $iPosX_Label, $iPosY_Label, 429, 57) GUICtrlSetFont(-1, 30, 400, 0, "Comic Sans MS", 4) GUICtrlSetColor(-1, 0xC0C0D8) Global Const $iLabel_Titel = GUICtrlCreateLabel($sLabel_Titel_Txt, $iPosX_Label - 4, $iPosY_Label - 4, 429, 57) GUICtrlSetFont(-1, 30, 400, 0, "Comic Sans MS", 4) GUICtrlSetColor(-1, 0x0000C0) GUICtrlSetBkColor(-1, -2) Global Const $iPic_Histogram = GUICtrlCreatePic("", 20, 90, 255, 127, -1, $WS_EX_STATICEDGE) GUICtrlSetCursor(-1, 14) Global Const $iPic_ColorGradient = GUICtrlCreatePic("", 20, 220, 255, 24, -1, $WS_EX_STATICEDGE) Global Const $iGroup = GUICtrlCreateGroup("Channel", 290, 84, 160, 164) Global Const $iRadio_L = GUICtrlCreateRadio("Luminosit&y (gray)", 300, 100, 110, 20) GUICtrlSetTip(-1, $frY & "*R, " & $fgY & "*G, " & $fbY & "*B") GUICtrlSetState($iRadio_L, $GUI_CHECKED) Global Const $iRadio_C = GUICtrlCreateRadio("&cRGB", 300, 130, 60, 20) GUICtrlSetTip(-1, "Combined average of RGB values") Global Const $iRadio_R = GUICtrlCreateRadio("&Red", 300, 160, 60, 20) Global Const $iRadio_G = GUICtrlCreateRadio("&Green", 300, 190, 60, 20) Global Const $iRadio_B = GUICtrlCreateRadio("&Blue", 300, 220, 60, 20) GUICtrlCreateGroup("", -99, -99, 1, 1) Global Const $iButton_Save = GUICtrlCreateButton("&Save", 209, 265, 70, 30) GUICtrlSetTip(-1, "Click button to save all histogram images") GUICtrlSetState(-1, $GUI_DISABLE) Global Const $iButton_Load = GUICtrlCreateButton("&Load", 290, 265, 70, 30) GUICtrlSetTip(-1, "Click button to load an image") Global Const $iButton_Exit = GUICtrlCreateButton("E&xit", 390, 265, 60, 30) Global $sLabelCredit_Txt = "coded by UEZ'13" Global $aLabelCredit_Pos[StringLen($sLabelCredit_Txt)][4], $u, $iFS = 6.5, $iY = 280 For $u = 0 To UBound($aLabelCredit_Pos) - 1 $aLabelCredit_Pos[$u][0] = StringMid($sLabelCredit_Txt, $u + 1, 1) $aLabelCredit_Pos[$u][1] = 20 + $u * ($iFS - 0.25) $aLabelCredit_Pos[$u][2] = $iY $aLabelCredit_Pos[$u][3] = GUICtrlCreateLabel($aLabelCredit_Pos[$u][0], $aLabelCredit_Pos[$u][1], $aLabelCredit_Pos[$u][2], $iFS, $iFS * 1.8) GUICtrlSetFont(-1, $iFS, 400, 0, "Comic Sans MS", 2) GUICtrlSetColor(-1, 0x006000) Next Global $aLabelCredit_AnimPos[300] For $u = 0 To UBound($aLabelCredit_AnimPos) - 1 $aLabelCredit_AnimPos[$u] = $iY Next Global Const $fLimes = 2.2, $fStep = 0.1 Global $iPT = 0, $z = Int((UBound($aLabelCredit_AnimPos) - ($fLimes * $fStep * 100)) / 2) For $u = 0 To $fLimes Step $fStep $aLabelCredit_AnimPos[$z] = $iY + Sin($iPT * 4) * 10 $z += 1 $iPT += 0.075 Next Global $ihGui_PreviewSize = 256, $iBGColor = 0xF0F0F0 Global $hGui_Preview = GUICreate("", $ihGui_PreviewSize, $ihGui_PreviewSize + 58, -1, -1, $WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST, $hGUI) Global $iPic_Preview = GUICtrlCreatePic("", 0, 0, $ihGui_PreviewSize, $ihGui_PreviewSize) Global $idLabel_Info = GUICtrlCreateLabel("", 0, $ihGui_PreviewSize, $ihGui_PreviewSize * 2, 58) GUICtrlSetFont(-1, 8.5, 400, 0, "Arial", 5) GUICtrlSetColor(-1, $iBGColor) GUICtrlSetBkColor(-1, 0x333333) Global Const $hTexture_Checkerboard = _GDIPlus_CreateCheckerboardTexture(8, 0xFFFBFBFB, 0xFFFFFFFF) Global $hHBmp_L = _GDIPlus_CreateColorGradient("L", 256, 24) Global $hHBmp_C = _GDIPlus_CreateColorGradient("C", 256, 24) Global $hHBmp_R = _GDIPlus_CreateColorGradient("R", 256, 24) Global $hHBmp_G = _GDIPlus_CreateColorGradient("G", 256, 24) Global $hHBmp_B = _GDIPlus_CreateColorGradient("B", 256, 24) Global Const $hHBmp_HL = _GDIPlus_BitmapCreateFromScan0(256, 127) Global Const $hCtxt_HL = _GDIPlus_ImageGetGraphicsContext($hHBmp_HL) Global Const $hHBmp_HC = _GDIPlus_BitmapCloneArea($hHBmp_HL, 0, 0, 256, 127, 0x0026200A) Global Const $hCtxt_HC = _GDIPlus_ImageGetGraphicsContext($hHBmp_HC) Global Const $hHBmp_HR = _GDIPlus_BitmapCloneArea($hHBmp_HL, 0, 0, 256, 127, 0x0026200A) Global Const $hCtxt_HR = _GDIPlus_ImageGetGraphicsContext($hHBmp_HR) Global Const $hHBmp_HG = _GDIPlus_BitmapCloneArea($hHBmp_HL, 0, 0, 256, 127, 0x0026200A) Global Const $hCtxt_HG = _GDIPlus_ImageGetGraphicsContext($hHBmp_HG) Global Const $hHBmp_HB = _GDIPlus_BitmapCloneArea($hHBmp_HL, 0, 0, 256, 127, 0x0026200A) Global Const $hCtxt_HB = _GDIPlus_ImageGetGraphicsContext($hHBmp_HB) _GDIPlus_GraphicsClear($hCtxt_HL, 0xFFFFFFFF) _hBmpToPicControl($iPic_ColorGradient, $hHBmp_L) Global $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HL) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) GUISetState(@SW_HIDE, $hGui_Preview) GUISetState(@SW_SHOW, $hGUI) ControlFocus($hGUI, "", $iButton_Load) Global $hPen_H = _GDIPlus_PenCreate() $s = "L" Global $iDummyL = GUICtrlCreateDummy(), $iDummyC = GUICtrlCreateDummy(), $iDummyR = GUICtrlCreateDummy(), $iDummyG = GUICtrlCreateDummy(), $iDummyB = GUICtrlCreateDummy() Global $iHistogramFormat, $hHBmp_Preview, $aPosCtrl, $aPosWin, $aMouseInfo, $aPos_hWnd, $imp, $iVal, $iMpos_oldx, $iMpos_oldy, $sType, $iPaletteType, $iPixelFormat Global $fAverage_L, $fAverage_cRGB, $iAverage_R, $iAverage_B, $iAverage_G, $o = 0 Global $bShow = False, $bHide = False, $bIsAlpha = False, $bIsGray = False Global Const $iEntries = 256 Global Const $tagCOLORPALETTE = "uint Flags;" & _ ; Palette flags "uint Count;" & _ ; Number of color entries "uint ARGB[" & $iEntries & "];" ; Palette color AdlibRegister("AnimateLabel", 60) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $iButton_Exit AdlibUnRegister("AnimateLabel") GUIDelete($hGui_Preview) GUIDelete($hGUI) _WinAPI_DeleteObject($hHBmp_L) _WinAPI_DeleteObject($hHBmp_C) _WinAPI_DeleteObject($hHBmp_L) _WinAPI_DeleteObject($hHBmp_R) _WinAPI_DeleteObject($hHBmp_G) _WinAPI_DeleteObject($hHBmp_B) If $hHBmp_Preview Then _WinAPI_DeleteObject($hHBmp_Preview) _GDIPlus_PenDispose($hPen_H) _GDIPlus_BrushDispose($hTexture_Checkerboard) _GDIPlus_GraphicsDispose($hCtxt_HL) _GDIPlus_GraphicsDispose($hCtxt_HC) _GDIPlus_GraphicsDispose($hCtxt_HR) _GDIPlus_GraphicsDispose($hCtxt_HG) _GDIPlus_GraphicsDispose($hCtxt_HB) _GDIPlus_BitmapDispose($hHBmp_HL) _GDIPlus_BitmapDispose($hHBmp_HC) _GDIPlus_BitmapDispose($hHBmp_HR) _GDIPlus_BitmapDispose($hHBmp_HG) _GDIPlus_BitmapDispose($hHBmp_HB) _GDIPlus_Shutdown() $tStructChannel0 = 0 $tStructChannel1 = 0 $tStructChannel2 = 0 $tStructChannel3 = 0 Exit Case $iRadio_L, $iDummyL If $s <> "L" Then _hBmpToPicControl($iPic_ColorGradient, $hHBmp_L) If $bImgLoaded Then $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HL) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) EndIf $s = "L" EndIf Case $iRadio_C, $iDummyC If $s <> "C" Then _hBmpToPicControl($iPic_ColorGradient, $hHBmp_C) If $bImgLoaded Then $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HC) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) EndIf $s = "C" EndIf Case $iRadio_R, $iDummyR If $s <> "R" Then _hBmpToPicControl($iPic_ColorGradient, $hHBmp_R) If $bImgLoaded Then $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HR) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) EndIf $s = "R" EndIf Case $iRadio_G, $iDummyG If $s <> "G" Then _hBmpToPicControl($iPic_ColorGradient, $hHBmp_G) If $bImgLoaded Then $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HG) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) EndIf $s = "G" EndIf Case $iRadio_B, $iDummyB If $s <> "B" Then _hBmpToPicControl($iPic_ColorGradient, $hHBmp_B) If $bImgLoaded Then $hB_H = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hHBmp_HB) _hBmpToPicControl($iPic_Histogram, $hB_H, 1) EndIf $s = "B" EndIf Case $iButton_Load $sFile = FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.bmp;*.gif)", 3) If @error Then ContinueCase If $bImgLoaded Then _GDIPlus_ImageDispose($hImage) $hImage = _GDIPlus_ImageLoadFromFile($sFile) If @error Then MsgBox(0x40010, "Error", "Unable to load image", 30) ContinueCase EndIf GUICtrlSetState($iButton_Save, $GUI_ENABLE) $aRes = _GDIPlus_ImageGetFlags($hImage) If BitAND($aRes[0], $GDIP_IMAGEFLAGS_HASALPHA) Then $bIsAlpha = True Else $bIsAlpha = False EndIf If BitAND($aRes[0], $GDIP_IMAGEFLAGS_COLORSPACE_GRAY) Then $bIsGray = True Else $bIsGray = False EndIf $hHBmp_Preview = _GetImage($sFile, $ihGui_PreviewSize, $iBGColor) _hBmpToPicControl($iPic_Preview, $hHBmp_Preview, 1) If Not $bIsAlpha Then $pStructChannel3 = 0 $iHistogramFormat = $HistogramFormatRGB Else $pStructChannel3 = DllStructGetPtr($tStructChannel3) $iHistogramFormat = $HistogramFormatARGB EndIf _GDIPlus_BitmapGetHistogram($hImage, $iHistogramFormat, _GDIPlus_BitmapGetHistogramSize($iHistogramFormat), $pStructChannel0, $pStructChannel1, $pStructChannel2, $pStructChannel3) _GDIPlus_CreateHistogram() $bImgLoaded = True If BitAND(GUICtrlRead($iRadio_L), $GUI_CHECKED) Then $s = "" GUICtrlSendToDummy($iDummyL) ElseIf BitAND(GUICtrlRead($iRadio_C), $GUI_CHECKED) Then $s = "" GUICtrlSendToDummy($iDummyC) ElseIf BitAND(GUICtrlRead($iRadio_R), $GUI_CHECKED) Then $s = "" GUICtrlSendToDummy($iDummyR) ElseIf BitAND(GUICtrlRead($iRadio_G), $GUI_CHECKED) Then $s = "" GUICtrlSendToDummy($iDummyG) Else $s = "" GUICtrlSendToDummy($iDummyB) EndIf Case $iButton_Save If $sFile = "" Then ContinueLoop $sType = "png" $o += _GDIPlus_ImageSaveToFile($hHBmp_HL, StringRegExpReplace($sFile, "(.*)\..*", "$1") & "_Luminosity." & $sType) $o += _GDIPlus_ImageSaveToFile($hHBmp_HC, StringRegExpReplace($sFile, "(.*)\..*", "$1") & "_cRGB." & $sType) $o += _GDIPlus_ImageSaveToFile($hHBmp_HR, StringRegExpReplace($sFile, "(.*)\..*", "$1") & "_Red." & $sType) $o += _GDIPlus_ImageSaveToFile($hHBmp_HG, StringRegExpReplace($sFile, "(.*)\..*", "$1") & "_Green." & $sType) $o += _GDIPlus_ImageSaveToFile($hHBmp_HB, StringRegExpReplace($sFile, "(.*)\..*", "$1") & "_Blue." & $sType) If $o = 5 Then MsgBox(64 + 262144, "Information", "Images properly saved to " & StringRegExpReplace($sFile, "(.*)\\.*", "$1"), 30, $hGUI) Else MsgBox(16 + 262144, "Error", "One or more images could not saved to " & StringRegExpReplace($sFile, "(.*)\\.*", "$1") & ".", 30, $hGUI) EndIf EndSwitch If WinActive($hGUI) Then $aMouseInfo = GUIGetCursorInfo($hGUI) Switch $aMouseInfo[4] Case $iPic_Histogram If $bImgLoaded Then $aPos_hWnd = WinGetPos($hGUI) $imp = Max(1, Min(256, -19 + $aMouseInfo[0])) Switch $s Case "L" $iVal = $aLuminosity[$imp] Case "C" $iVal = $aCRGB[$imp] Case "R" $iVal = DllStructGetData($tStructChannel0, "channel0", $imp) Case "G" $iVal = DllStructGetData($tStructChannel1, "channel1", $imp) Case "B" $iVal = DllStructGetData($tStructChannel2, "channel2", $imp) EndSwitch If $iMpos_oldx <> $aMouseInfo[0] Or $iMpos_oldy <> $aMouseInfo[1] Then ToolTip("Index: " & $imp & ", Value: " & Round($iVal, 0) & ", Average: " & Round($fAverage_L, 2), $aPos_hWnd[0] + $aMouseInfo[0] - 60, $aMouseInfo[1] + $aPos_hWnd[1] - 20) $iMpos_oldx = $aMouseInfo[0] $iMpos_oldy = $aMouseInfo[1] EndIf ShowPreview($iPic_Histogram) $bShow = True $bHide = False EndIf Case Else If Not $bHide Then GUISetState(@SW_HIDE, $hGui_Preview) $bHide = True ToolTip("") EndIf $bShow = False EndSwitch EndIf WEnd Func AnimateLabel() Local Static $v = Int((UBound($aLabelCredit_AnimPos) - ($fLimes * $fStep * 100)) / 2) Local $u For $u = 0 To UBound($aLabelCredit_Pos) - 1 GUICtrlSetPos($aLabelCredit_Pos[$u][3], $aLabelCredit_Pos[$u][1], $aLabelCredit_AnimPos[$v - $u]) Next If $v - $u < 0 Then $v = UBound($aLabelCredit_AnimPos) - 1 $v -= 1 EndFunc ;==>AnimateLabel Func Min($a, $b) If $a < $b Then Return $a Return $b EndFunc ;==>Min Func Max($a, $b) If $a > $b Then Return $a Return $b EndFunc ;==>Max Func ShowPreview($iCtrl) $aPosWin = WinGetPos($hGUI) $aPosCtrl = ControlGetPos($hGUI, "", $iCtrl) Local $iNewX, $iNewX1 = $aPosWin[0] - $ihGui_PreviewSize + 10, $iNewX2 = $aPosWin[0] + $aPosWin[2] - 10 $iNewX = $iNewX1 If $iNewX1 < $aFullScreen[0] Then $iNewX = $iNewX2 EndIf WinMove($hGui_Preview, "", $iNewX, $aPosWin[1] + 50) GUISetState(@SW_SHOWNOACTIVATE, $hGui_Preview) EndFunc ;==>ShowPreview Func _GetImage($sFile, $iWH, $iBkClr = 0xFFFFFF, $bCheckerboard_Bg = True) Local $hBmp1, $hBitmap, $hGraphic, $hImage, $iW, $iH, $aGS, $hBmp2, $aFTS $aFTS = FileGetTime($sFile) If @error Then Return SetError(1, 0, 0) $hBmp1 = _WinAPI_CreateBitmap($iWH, $iWH, 1, 32) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp1) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) _WinAPI_DeleteObject($hBmp1) $hImage = _GDIPlus_ImageLoadFromFile($sFile) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) GUICtrlSetData($idLabel_Info, StringRegExpReplace($sFile, ".*\\(.*)", "$1") & @LF & Round(FileGetSize($sFile) / 1024, 0) & " kb (" & $iW & " x " & $iH & ")" & @LF & $aFTS[0] & "/" & $aFTS[1] & "/" & $aFTS[2] & " " & $aFTS[3] & ":" & $aFTS[4] & ":" & $aFTS[5] & @LF & "Alpha: " & $bIsAlpha & ", Gray: " & $bIsGray) $aGS = _GetScale($iW, $iH, $iWH) Switch $bCheckerboard_Bg Case True ;~ _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $iWH, $iWH, $hTexture_Checkerboard) _GDIPlus_GraphicsClear($hGraphic, BitOR(0xFF000000, $iBkClr)) _GDIPlus_GraphicsFillRect($hGraphic, $aGS[0], $aGS[1], $aGS[2], $aGS[3], $hTexture_Checkerboard) Case False _GDIPlus_GraphicsClear($hGraphic, BitOR(0xFF000000, $iBkClr)) EndSwitch _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $aGS[0], $aGS[1], $aGS[2], $aGS[3]) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphic) $hBmp2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hBmp2 EndFunc ;==>_GetImage Func _GetScale($iW, $iH, $iWH) Local $aRet[4] If $iW <= $iWH And $iH <= $iWH Then $aRet[2] = $iW $aRet[3] = $iH $aRet[0] = ($iWH - $aRet[2]) / 2 $aRet[1] = ($iWH - $aRet[3]) / 2 ElseIf $iW > $iH Then $aRet[2] = $iWH $aRet[3] = $iH / ($iW / $iWH) $aRet[0] = 0 $aRet[1] = ($iWH - $aRet[3]) / 2 ElseIf $iW < $iH Then $aRet[2] = $iW / ($iH / $iWH) $aRet[3] = $iWH $aRet[0] = ($iWH - $aRet[2]) / 2 $aRet[1] = 0 ElseIf $iW = $iH Then $aRet[2] = $iWH $aRet[3] = $iWH $aRet[0] = 0 $aRet[1] = 0 EndIf Return $aRet EndFunc ;==>_GetScale Func _hBmpToPicControl($iCID, ByRef $hBmp, $iFlag = 0) Local $hOldBmp $hOldBmp = GUICtrlSendMsg($iCID, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp) If $hOldBmp Then _WinAPI_DeleteObject($hOldBmp) If $iFlag Then _WinAPI_DeleteObject($hBmp) EndFunc ;==>_hBmpToPicControl Func _GDIPlus_CreateHistogram($sRounding = "Ceiling") Local $iMaxL, $iMaxC, $iMaxR, $iMaxG, $iMaxB, $a, $r, $g, $b, $yR, $yG, $yB, $iRedAv, $iGreenAv, $iBlueAv For $i = 1 + $bIsAlpha To 256 If $bIsAlpha Then ;~ ConsoleWrite("Alpha: " & DllStructGetData($tStructChannel0, "channel0", $i) & @CRLF) $r = DllStructGetData($tStructChannel1, "channel1", $i) $yR = $r * $frY If DllStructGetData($tStructChannel1 , "channel1", $i) > $iMaxR Then $iMaxR = $r $g = DllStructGetData($tStructChannel2, "channel2", $i) $yG = $g * $fgY If DllStructGetData($tStructChannel2 , "channel2", $i) > $iMaxG Then $iMaxG = $g $b = DllStructGetData($tStructChannel3, "channel3", $i) $yB = $b * $fbY If DllStructGetData($tStructChannel3 , "channel3", $i) > $iMaxB Then $iMaxB = $b $fAverage_cRGB += $r + $g + $b $fAverage_L += $yR + $yG + $yB Else $r = DllStructGetData($tStructChannel0, "channel0", $i) $yR = $r * $frY If DllStructGetData($tStructChannel0 , "channel0", $i) > $iMaxR Then $iMaxR = $r $g = DllStructGetData($tStructChannel1, "channel1", $i) $yG = $g * $fgY If DllStructGetData($tStructChannel1 , "channel1", $i) > $iMaxG Then $iMaxG = $g $b = DllStructGetData($tStructChannel2, "channel2", $i) $yB = $b * $fbY If DllStructGetData($tStructChannel2 , "channel2", $i) > $iMaxB Then $iMaxB = $b EndIf $fAverage_cRGB += $r + $g + $b $fAverage_L += $yR + $yG + $yB $aLuminosity[$i] = $yR + $yG + $yB If $aLuminosity[$i] > $iMaxL Then $iMaxL = $aLuminosity[$i] $aCRGB[$i] = ($r + $g + $b) / 3 If $aCRGB[$i] > $iMaxC Then $iMaxC = $aCRGB[$i] Next $fAverage_cRGB /= 256 * 3 $fAverage_L /= 256 _GDIPlus_GraphicsClear($hCtxt_HL, 0xFFFFFFFF) _GDIPlus_GraphicsClear($hCtxt_HC, 0xFFFFFFFF) _GDIPlus_GraphicsClear($hCtxt_HR, 0xFFFFFFFF) _GDIPlus_GraphicsClear($hCtxt_HG, 0xFFFFFFFF) _GDIPlus_GraphicsClear($hCtxt_HB, 0xFFFFFFFF) Local $iDL = 1, $iDC = 1, $iDR = 1, $iDG = 1, $iDB = 1 Local $sRoundings = "Round,Ceiling,Floor," If Not StringInStr($sRoundings, $sRounding) Then $sRounding = "Ceiling" If $iMaxL > 128 Then ;~ $iDL = Ceiling($iMaxL / 128) $iDL = Execute($sRounding & "(" & $iMaxL / 128 & ")") Else $iDL = 1 / (128 / $iMaxL) EndIf If $iMaxC > 128 Then ;~ $iDC = Ceiling($iMaxC / 128) $iDC = Execute($sRounding & "(" & $iMaxC / 128 & ")") Else $iDC = 1 / (128 / $iMaxC) EndIf If $iMaxR > 128 Then ;~ $iDR = Ceiling($iMaxR / 128) $iDR = Execute($sRounding & "(" & $iMaxR / 128 & ")") Else $iDR = 1 / (128 / $iMaxR) EndIf If $iMaxG > 128 Then ;~ $iDG = Ceiling($iMaxG / 128) $iDG = Execute($sRounding & "(" & $iMaxG / 128 & ")") Else $iDG = 1 / (128 / $iMaxG) EndIf If $iMaxB > 128 Then ;~ $iDB = Ceiling($iMaxB / 128) $iDB = Execute($sRounding & "(" & $iMaxB / 128 & ")") Else $iDB = 1 / (128 / $iMaxB) EndIf For $i = 1 To 256 _GDIPlus_PenSetColor($hPen_H, 0xFF000000) _GDIPlus_GraphicsDrawLine($hCtxt_HL, $i - 1, 127, $i - 1, 127 - (Int($aLuminosity[$i] / $iDL)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFF000000) _GDIPlus_GraphicsDrawLine($hCtxt_HC, $i - 1, 127, $i - 1, 127 - (Int($aCRGB[$i] / $iDC)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFFB00000) If $bIsAlpha Then _GDIPlus_GraphicsDrawLine($hCtxt_HR, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel1, "channel1", $i) / $iDR)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFF00B000) _GDIPlus_GraphicsDrawLine($hCtxt_HG, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel2, "channel2", $i) / $iDG)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFF0000B0) _GDIPlus_GraphicsDrawLine($hCtxt_HB, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel3, "channel3", $i) / $iDB)), $hPen_H) Else _GDIPlus_GraphicsDrawLine($hCtxt_HR, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel0, "channel0", $i) / $iDR)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFF00B000) _GDIPlus_GraphicsDrawLine($hCtxt_HG, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel1, "channel1", $i) / $iDG)), $hPen_H) _GDIPlus_PenSetColor($hPen_H, 0xFF0000B0) _GDIPlus_GraphicsDrawLine($hCtxt_HB, $i - 1, 127, $i - 1, 127 - (Int(DllStructGetData($tStructChannel2, "channel2", $i) / $iDB)), $hPen_H) EndIf Next EndFunc ;==>_GDIPlus_CreateHistogram Func _GDIPlus_CreateColorGradient($sColorChannel, $iW, $iH, $bHBitmap = True) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;~ _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2) Local $hPen = _GDIPlus_PenCreate() _GDIPlus_PenSetLineJoin($hPen, $iLineJoinBevel) Local $i, $c For $i = 0 To $iW $c = Hex($i, 2) Switch $sColorChannel Case "L" _GDIPlus_PenSetColor($hPen, "0xFF" & $c & $c & $c) Case "C" _GDIPlus_PenSetColor($hPen, "0xFF" & $c & $c & $c) Case "R" _GDIPlus_PenSetColor($hPen, "0xFF" & $c & "0000") Case "G" _GDIPlus_PenSetColor($hPen, "0xFF00" & $c & "00") Case "B" _GDIPlus_PenSetColor($hPen, "0xFF0000" & $c) EndSwitch _GDIPlus_GraphicsDrawLine($hCtxt, $i, 0, $i, $iH, $hPen) Next _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_PenDispose($hPen) If $bHBitmap Then Local $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBmp EndIf Return $hBitmap EndFunc ;==>_GDIPlus_CreateColorGradient Func _GDIPlus_CreateCheckerboardTexture($iSquareSize = 80, $iCol1 = 0xFFECECEC, $iCol2 = 0xFFDFDFDF) Local $hPatternBitmap = _GDIPlus_BitmapCreateFromScan0(2 * $iSquareSize, 2 * $iSquareSize) Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hPatternBitmap) Local $hBrush0 = _GDIPlus_BrushCreateSolid($iCol1) Local $hBrush1 = _GDIPlus_BrushCreateSolid($iCol2) _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iSquareSize, $iSquareSize, $hBrush0) _GDIPlus_GraphicsFillRect($hCtxt, $iSquareSize, 0, $iSquareSize, $iSquareSize, $hBrush1) _GDIPlus_GraphicsFillRect($hCtxt, 0, $iSquareSize, $iSquareSize, $iSquareSize, $hBrush1) _GDIPlus_GraphicsFillRect($hCtxt, $iSquareSize, $iSquareSize, $iSquareSize, $iSquareSize, $hBrush0) Local $hTexture = _GDIPlus_TextureCreate($hPatternBitmap) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_BitmapDispose($hPatternBitmap) _GDIPlus_BitmapDispose($hBrush0) _GDIPlus_BitmapDispose($hBrush1) Return $hTexture EndFunc ;==>_CreatePatternTexture  
      GdipBitmapGetHistogram(), GdipBitmapGetHistogramSize() and 2 more GDI+ functions requires GDI+ v1.1 which means this will only run on Vista or higher operating systems.
      I hope the values are correct especially the value for luminosity.
      Br,
      UEZ
    • 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)
×