Sign in to follow this  
Followers 0
gottygolly

GDI+ image blinking.

3 posts in this topic

I've started to mess around with GDI+ stuff and I just wrote this messing around but I ran into a problem where I don't know how to move the image (screen capture). I looked for stuff and I found some things but none of them seem to work.

#include<gdiplus.au3>
#include <ScreenCapture.au3>
#include<winapi.au3>
Global Const $iW = 750,$iH = 600
$gui = GUICreate("",$iW,$iH,-1,-1)
Opt("GUIOnEventMode",1)
GUISetOnEvent(-3,"_Exit")
$mp_x = ""
$mp_y = ""
GUISetState()
_GDIPlus_Startup()
$capture = _ScreenCapture_Capture()
$tt = _GDIPlus_ImageAttributesCreate()
$hwnd = _GDIPlus_GraphicsCreateFromHWND($gui)
$bit = _GDIPlus_BitmapCreateFromHBITMAP($capture)
$context = _GDIPlus_ImageGetGraphicsContext($bit)
;_GDIPlus_GraphicsDrawImage($context,$bit,0,0)
_GDIPlus_GraphicsDrawImageRectRect($hwnd,$bit,100,100,$iW,$iH,0,0,$iW,$iH,$tt)
_GDIPlus_GraphicsSetSmoothingMode($context,2)
While 1
   $mp = GUIGetCursorInfo($gui)
   If $mp[0] <> $mp_x Or $mp[1] <> $mp_y Then
      _GDIPlus_GraphicsClear($hwnd,0xFFFFFFFF)
   $gg = _GDIPlus_GraphicsDrawImageRectRect($hwnd,$bit,$mp[0],$mp[1],$iW,$iH,0,0,$iW,$iH,$tt)
   $mp_x = $mp[0]
   $mp_y = $mp[1]
   EndIf
   Sleep(10)
WEnd

Func _Exit()
   _GDIPlus_GraphicsDispose($context)
   _GDIPlus_GraphicsDispose($hwnd)
   _GDIPlus_Shutdown
   Exit
EndFunc

Thanks in advance.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try somethin' like that here.

 

#include <gdiplus.au3>
#include <ScreenCapture.au3>

Global Const $iW = 750, $iH = 600
$gui = GUICreate("", $iW, $iH, -1, -1)
Opt("GUIOnEventMode", 1)
GUISetOnEvent(-3, "_Exit")
$mp_x = ""
$mp_y = ""
GUISetState()
_GDIPlus_Startup()
$capture = _ScreenCapture_Capture()
$hwnd = _GDIPlus_GraphicsCreateFromHWND($gui)
$bit = _GDIPlus_BitmapCreateFromHBITMAP($capture)
$hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
$context = _GDIPlus_ImageGetGraphicsContext($hBitmap)

While 1
    $mp = GUIGetCursorInfo($gui)
    If $mp[0] <> $mp_x Or $mp[1] <> $mp_y Then
        _GDIPlus_GraphicsClear($context)
        _GDIPlus_GraphicsDrawImageRectRect($context, $bit, $mp[0], $mp[1], $iW, $iH, 0, 0, $iW, $iH)
        _GDIPlus_GraphicsDrawImage($hwnd, $hBitmap, 0, 0)
        $mp_x = $mp[0]
        $mp_y = $mp[1]
    EndIf
    Sleep(10)
WEnd

Func _Exit()
    _WinAPI_DeleteObject($capture)
    _GDIPlus_GraphicsDispose($context)
    _GDIPlus_GraphicsDispose($hwnd)
    _GDIPlus_BitmapDispose($bit)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown
    Exit
EndFunc   ;==>_Exit
 

 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Thank you UEZ hopefully i wont forget about this

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  
Followers 0