sandin Posted March 14, 2009 Share Posted March 14, 2009 Is there a way to move GDI+ graphic's content? In theory it should sound like this: Create Graphic and it's back buffer, capture the buffer's picture and then draw it somewhere on the original graphic, like this: expandcollapse popup#include <GuiConstantsEx.au3> #include <GDIPlus.au3> _Main() Func _Main() Local $hGUI = GUICreate("GDI+", 400, 300) Local $hWnd = WinGetHandle("GDI+") GUISetState() _GDIPlus_Startup () Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd) Local $bitmap = _GDIPlus_BitmapCreateFromGraphics(400, 300, $hGraphic) Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) Local $hBrush = _GDIPlus_BrushCreateSolid (0xFF000000) Local $tLayout = _GDIPlus_RectFCreate (1/400, 1/300, 0, 0) Local $font_size = 18 Local $hFormat = _GDIPlus_StringFormatCreate () Local $hFamily = _GDIPlus_FontFamilyCreate ("Arial") Local $hFont = _GDIPlus_FontCreate ($hFamily, $font_size, 2) _GDIPlus_GraphicsDrawStringEx ($backbuffer, "some GDI graph. content", $hFont, $tLayout, $hFormat, $hBrush) Local $GC = _GDIPlus_ImageGetGraphicsContext($bitmap) Local $newBmp = _GDIPlus_BitmapCreateFromGraphics(400, 300, $GC) Local $newGC = _GDIPlus_ImageGetGraphicsContext($newBmp) _GDIPlus_GraphicsDrawImageRect($newGC, $bitmap, 0, 0, 400, 300) _GDIPlus_GraphicsDrawImageRect($hGraphic, $bitmap, 0, 0, 400, 300) MsgBox(0, "", "now we move the GDI") for $i = 0 to 150 _move_the_gdi($hGraphic, $bitmap, $i/2, $i) Sleep(1) Next _move_the_gdi($hGraphic, $bitmap, 90, 180) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_GraphicsDispose($GC) _GDIPlus_GraphicsDispose($newGC) _GDIPlus_BitmapDispose($newBmp) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_Shutdown () EndFunc ;==>_Main func _move_the_gdi($grhp, $btmp, $_x_coord, $_y_coord) _GDIPlus_GraphicsDrawImageRect($grhp, $btmp, $_x_coord, $_y_coord, 400, 300) EndFunc is there a simpler way (without buffers)? Or maybe there's a GDI plus command for moving the graphic content which I've missed Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
monoceres Posted March 14, 2009 Share Posted March 14, 2009 Don't look at the graphics object as a container for pixel data, instead look at them as doors that allows you to adjust pixel data in real places. For example a graphics object created for an hwnd only adjust the pixels on the window, they are never saved anywhere else. Therefore you must save your data inside bitmaps if you want to save old contents and redraw it in a new place. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
sandin Posted March 14, 2009 Author Share Posted March 14, 2009 tnx for fast reply.At first I tried to save a content in bitmap, but I failed, I never got anything, that's why I made it with a buffer (related to this question)my first attempt wasn't much different from the this one Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now