happytc 0 Posted August 19, 2011 Normally, the function of _ScreenCapture_Capture() can capture rectangle image. But how to capture polygon image? I know rectangle image can be changed to polygon image through transparent color. but how to? Please give a example. Share this post Link to post Share on other sites
monoscout999 10 Posted August 19, 2011 I don`t get it well.. you capture the rectangle where the polygon is. Share this post Link to post Share on other sites
JohnOne 1,603 Posted August 19, 2011 GDI voodoo. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
happytc 0 Posted August 19, 2011 Lots of capturing software(Such as PicPick, FSCapture) have one functionality, so-called FREEHAND capture. You can move mouse to get irregular orbit. Then they can capture a picture through the orbit. If using au3, how to realize this functionality? Share this post Link to post Share on other sites
happytc 0 Posted August 19, 2011 GDI voodoo.I also knew using GDI+ could realize it.But how to? Share this post Link to post Share on other sites
monoscout999 10 Posted August 19, 2011 soo. let me explain what i get from this...You capture a non Rectangular image from the screen.The capture image is always a rectangle, so what you want is that the part of the image where is not the shape you want to capture, set to tranparent.For ex.The black part represents what you want to capture, the grey part represents tranparent areas. Share this post Link to post Share on other sites
happytc 0 Posted August 19, 2011 soo. let me explain what i get from this...You capture a non Rectangular image from the screen.The capture image is always a rectangle, so what you want is that the part of the image where is not the shape you want to capture, set to tranparent.For ex.The black part represents what you want to capture, the grey part represents tranparent areas.Yeah, I have known the principle it's just like you said. But I want to know how to realize it through GDI+ Share this post Link to post Share on other sites
monoscout999 10 Posted August 19, 2011 (edited) Sorry i ask for me... because i never do something like this... so The problem is to recognizing the shape Is this for a window? Edited August 19, 2011 by monoscout999 Share this post Link to post Share on other sites
happytc 0 Posted August 19, 2011 (edited) Sorry i ask for me... because i never do something like this...so The problem is to recognizing the shapeIs this for a window?for current screen.like following record(It's very cool) Edited August 19, 2011 by happytc Share this post Link to post Share on other sites
UEZ 1,273 Posted August 20, 2011 (edited) Try this (it is a fast hack!): expandcollapse popup;code by UEZ 2011 #AutoIt3Wrapper_UseX64=n #include <Misc.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) _GDIPlus_Startup() $hHBitmap = _ScreenCapture_Capture("", 0, 0, @DesktopWidth, @DesktopHeight, False) $hTexture = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) $hTextureBrush = _GDIPlus_TextureCreate($hTexture) _WinAPI_DeleteObject($hHBitmap) $hGUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hTexture, 0, 0) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2) $hPen = _GDIPlus_PenCreate(0xFFFF0000, 2) Global $dll = DllOpen("user32.dll") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $exitloop = False $min_x = @DesktopWidth $min_y = @DesktopHeight $max_x = 0 $max_y = 0 $mo = MouseGetCursor() Global $aPoints[2^20][2] $p = 1 GUISetCursor(14, 1, $hGUI) While Sleep(100) $mxo = MouseGetPos(0) $myo = MouseGetPos(1) While _IsPressed("01", $dll) * Sleep(10) $mx = MouseGetPos(0) $my = MouseGetPos(1) _GDIPlus_GraphicsDrawLine($hGraphic, $mx, $my, $mxo, $myo, $hPen) $mxo = $mx $myo = $my $aPoints[$p][0] = $mx $aPoints[$p][1] = $my $min_x = Min($min_x, $mx) $min_y = Min($min_y, $my) $max_x = Max($max_x, $mx) $max_y = Max($max_y, $my) $p += 1 $exitloop = True WEnd If $exitloop Then ExitLoop WEnd GUISetCursor($mo, 1, $hGUI) ReDim $aPoints[$p][2] $aPoints[0][0] = $p - 1 _GDIPlus_GraphicsDispose($hGraphic) $new_w = $max_x - $min_x $new_h = $max_y - $min_y $hBitmap_Hidden = _GDIPlus_BitmapCreateFromScan0(@DesktopWidth, @DesktopHeight) $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap_Hidden) _GDIPlus_GraphicsClear($hContext, 0xFFFFFFFF) _GDIPlus_GraphicsFillPolygon($hContext, $aPoints, $hTextureBrush) $hBitmap_Capture = _GDIPlus_BitmapCloneArea($hBitmap_Hidden, $min_x, $min_y, $new_w, $new_h) ;~ _GDIPlus_ImageSaveToFile($hBitmap_Capture, "Testc.jpg") GUISetOnEvent(-3, "") GUIDelete($hGUI) $hGUI = GUICreate("Freehand Screen Capture by UEZ 2011", $new_w, $new_h) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap_Capture, 0, 0) GUISetOnEvent(-3, "_Exit") _GDIPlus_BitmapDispose($hBitmap_Hidden) _GDIPlus_BitmapDispose($hBitmap_Capture) _GDIPlus_GraphicsDispose($hContext) While Sleep(5000) WEnd Func Max($a, $b) If $a > $b Then Return $a Return $b EndFunc Func Min($a, $b) If $a < $b Then Return $a Return $b EndFunc Func _Exit() DllClose($dll) _GDIPlus_BrushDispose($hTextureBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_BitmapDispose($hTexture) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) $aPoints = 0 Exit EndFunc Hold down lmb and draw something to the screen. Release lmb to capture the polygone area. Br, UEZ PS: no Voodoo needed Edited August 27, 2019 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
wakillon 403 Posted February 29, 2012 @UEZ Didn't see this little pearl ! Thanks. AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites