Luigi Posted December 2, 2012 Share Posted December 2, 2012 (edited) Hi, I try draw diferents buffers in the same Gui, without manipulate it like one big handler (or unique), but, divide it in little handlers and control each one in diferent way. The idea is a window with normal controls (GUICtrlCrateButton and similars) and with two or more _GDIPlus_ImageGetGraphicsContext... I search in the forum and found wonderful exemples (but very complex to me at this moment), I cant see 'where' are correct form to write this two controls/handlers. I will try many times, but does not work... I need help to draw pics/handlers. Thanks. expandcollapse popup#include <Misc.au3> #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) $hGui = GUICreate("GDI+ Two buffers", 1200, 600, -1, -1) GUISetBkColor(0xAABBCC, $hGui) GUISetOnEvent(-3, "close") GUISetState() _GDIPlus_Startup() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) $hBitmat00 = _GDIPlus_BitmapCreateFromGraphics(80, 440, $hGraphics) $hBitmat01 = _GDIPlus_BitmapCreateFromGraphics(880, 560, $hGraphics) $hBuffer00 = _GDIPlus_ImageGetGraphicsContext($hBitmat00) $hBuffer01 = _GDIPlus_ImageGetGraphicsContext($hBitmat01) $hFile0 = _GDIPlus_ImageLoadFromFile("bar.png") $pic0 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hFile0) _GDIPlus_BitmapDispose($hFile0) $hFile1 = _GDIPlus_ImageLoadFromFile("04.png") $pic1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hFile1) _GDIPlus_BitmapDispose($hFile1) Do _GDIPlus_GraphicsClear($hBuffer00) _GDIPlus_GraphicsClear($hBuffer01) _GDIPlus_GraphicsDrawImage($hBitmat00, $pic0, 0, 0) _GDIPlus_GraphicsDrawImage($hBitmat01, $pic1, 0, 0) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmat00, 5, 45, 80, 440) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmat01, 90, 5, 880, 560) Sleep(15) Until False Func close() _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_GraphicsDispose($hBuffer00) _GDIPlus_BitmapDispose($hBitmat00) _GDIPlus_GraphicsDispose($hBuffer01) _GDIPlus_BitmapDispose($hBitmat01) _GDIPlus_Shutdown() Exit EndFunc ;==>close Edited December 2, 2012 by detefon Visit my repository Link to comment Share on other sites More sharing options...
Luigi Posted December 2, 2012 Author Share Posted December 2, 2012 I can write this. Is the best way to write 3 or more BackBuffers in one Gui? expandcollapse popup#include #include Global Const $width = 520 Global Const $height = 480 Global $title = "GDI+" Global $xx = 0, $yy = 0 Global $posX = 40, $posY = 10 Opt("GUIOnEventMode", 1) $hGui = GUICreate($title, $width, $height) GUISetOnEvent($GUI_EVENT_CLOSE, "close") GUISetState() _GDIPlus_Startup() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) $hBitmap00 = _GDIPlus_BitmapCreateFromGraphics(400, 400, $hGraphics) $hBitmap01 = _GDIPlus_BitmapCreateFromGraphics(40, 400, $hGraphics) $hBitmap02 = _GDIPlus_BitmapCreateFromGraphics(400, 40, $hGraphics) $hBackBuffer00 = _GDIPlus_ImageGetGraphicsContext($hBitmap00) $hBackBuffer01 = _GDIPlus_ImageGetGraphicsContext($hBitmap01) $hBackBuffer02 = _GDIPlus_ImageGetGraphicsContext($hBitmap02) $hPic = _GDIPlus_ImageLoadFromFile("00.png") $hVer = _GDIPlus_ImageLoadFromFile("vertical.png") $hHor = _GDIPlus_ImageLoadFromFile("horizontal.png") Do _GDIPlus_GraphicsClear($hBackBuffer00, 0x11aabbcc) _GDIPlus_GraphicsClear($hBackBuffer01, 0x11aabbcc) _GDIPlus_GraphicsClear($hBackBuffer02, 0x11aabbcc) If _limite($xx, 0, 360) And $yy == 0 Then $xx += 2 If $xx == 360 And _limite($yy, 0, 360) Then $yy += 2 If $yy == 360 And _limite($xx, 0, 360) Then $xx -= 2 If $xx == 0 And _limite($yy, 0, 360) Then $yy -= 2 _GDIPlus_GraphicsDrawImageRect($hBackBuffer00, $hPic, $xx, $yy, 40, 40) _GDIPlus_GraphicsDrawImageRect($hBackBuffer01, $hVer, 0, $yy, 40, 40) _GDIPlus_GraphicsDrawImageRect($hBackBuffer02, $hHor, $xx, 0, 40, 40) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap00, $posX, $posY, 400, 400) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap01, $posX + 410, $posY, 40, 400) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap02, $posX , $posY+410, 400, 40) Sleep(10) Until False Func close() _GDIPlus_GraphicsDispose($hBackBuffer00) _GDIPlus_BitmapDispose($hBitmap00) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_GraphicsDispose($hBackBuffer01) _GDIPlus_BitmapDispose($hBitmap01) _GDIPlus_GraphicsDispose($hBackBuffer02) _GDIPlus_BitmapDispose($hBitmap02) _GDIPlus_Shutdown() Exit EndFunc ;==>close Func _limite($input, $min, $max) If $input >= $min And $input <= $max Then Return True Else Return False EndIf EndFunc ;==>_limite Visit my repository Link to comment Share on other sites More sharing options...
UEZ Posted December 2, 2012 Share Posted December 2, 2012 What do you want to achieve using 3 different graphics context handles? The only reason I can see is when you want to rotate each objects. 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Andreik Posted December 2, 2012 Share Posted December 2, 2012 This is what you asked for? expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> Global Const $width = 520 Global Const $height = 480 Global $title = "GDI+" Global $xx = 0, $yy = 0 Global $posX = 40, $posY = 10 Opt("GUIOnEventMode", 1) $hGui = GUICreate($title, $width, $height) GUISetOnEvent($GUI_EVENT_CLOSE, "close") GUISetState() _GDIPlus_Startup() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphics) $hBackBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) $hPic = _GDIPlus_ImageLoadFromFile("00.png") $hVer = _GDIPlus_ImageLoadFromFile("vertical.png") $hHor = _GDIPlus_ImageLoadFromFile("horizontal.png") Do _GDIPlus_GraphicsClear($hBackBuffer, 0x11AABBCC) If _limite($xx, 0, 360) And $yy == 0 Then $xx += 2 If $xx == 360 And _limite($yy, 0, 360) Then $yy += 2 If $yy == 360 And _limite($xx, 0, 360) Then $xx -= 2 If $xx == 0 And _limite($yy, 0, 360) Then $yy -= 2 _GDIPlus_GraphicsDrawImageRect($hBackBuffer, $hPic, $posX, $posY, 400, 400) _GDIPlus_GraphicsDrawImageRect($hBackBuffer, $hVer, $posX + 410, $posY, 40, 400) _GDIPlus_GraphicsDrawImageRect($hBackBuffer, $hHor, $posX , $posY+410, 400, 40) _GDIPlus_GraphicsDrawImage($hGraphics,$hBitmap,0,0) Sleep(10) Until False Func close() _GDIPlus_ImageDispose($hHor) _GDIPlus_ImageDispose($hVer) _GDIPlus_ImageDispose($hPic) _GDIPlus_GraphicsDispose($hBackBuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Exit EndFunc ;==>close Func _limite($input, $min, $max) If $input >= $min And $input <= $max Then Return True Else Return False EndIf EndFunc ;==>_limite When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Luigi Posted December 2, 2012 Author Share Posted December 2, 2012 (edited) @UEZ, I am new with GDIPlus and try many things, but this moment I want build a little image editor, like this below. Need write a zoom tool... perhaps another time.Maybe I thinking wrong, but is not all graphics context handles is updated every time, this is a reason to break a big control in small controls, or this is not necessary? Thanks for your reply.@Andreik, realy thank you for your reply, but not is this I want. Thanks.This script is not ready, still a draft, but is half functional.expandcollapse popup#include #include Global $hMouseMsg, $hMsg, $barColor[4], $board[4], $iColorX, $iColorY, $iPenX, $iPenY, $iPenSwtich, $iBoardSwtich, $iBoardX, $iBoardY Global Const $width = 1300 Global Const $height = 700 Global $title = "Grafico" Global $xx = 0, $yy = 0 Global $posX = 130, $posY = 50 $hGui = GUICreate($title, $width, $height) GUISetState() _GDIPlus_Startup() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) $hBitmap00 = _GDIPlus_BitmapCreateFromGraphics(1160, 640, $hGraphics) $hBitmap01 = _GDIPlus_BitmapCreateFromGraphics(80, 480, $hGraphics) $hBitmap02 = _GDIPlus_BitmapCreateFromGraphics(80, 80, $hGraphics) $hBackBuffer00 = _GDIPlus_ImageGetGraphicsContext($hBitmap00) $hBackBuffer01 = _GDIPlus_ImageGetGraphicsContext($hBitmap01) $hBackBuffer02 = _GDIPlus_ImageGetGraphicsContext($hBitmap02) $hPic = _GDIPlus_ImageLoadFromFile("00.png") $hVer = _GDIPlus_ImageLoadFromFile("bar2.png") $hHor = _GDIPlus_ImageLoadFromFile("horizontal.png") $hPen = _GDIPlus_PenCreate(0x99AAAA00, 3, 2) $hPen2 = _GDIPlus_PenCreate(0xFFFF1100, 3, 2) $hPen3 = _GDIPlus_PenCreate(0x99AAAA00, 1, 2) _board($barColor, 10, 50 + 80, 80, 480) _board($board, 130, 50, 1160, 640) Func _board(ByRef $arr, $xx, $yy, $lar, $alt) $arr[0] = $xx $arr[1] = $yy $arr[2] = $xx + $lar $arr[3] = $yy + $alt EndFunc ;==>_board Do $hMouseMsg = GUIGetCursorInfo($hGui) _GDIPlus_GraphicsClear($hBackBuffer00, 0x11aabbcc) _GDIPlus_GraphicsClear($hBackBuffer01, 0x11aabbcc) _GDIPlus_GraphicsClear($hBackBuffer02, 0x11aabbcc) ;_GDIPlus_GraphicsDrawImageRect($hBackBuffer00, $hPic, $xx, $yy, 40, 40) _GDIPlus_GraphicsDrawImageRect($hBackBuffer01, $hVer, 0, 0, 80, 480) _GDIPlus_GraphicsDrawRect($hBackBuffer01, $iPenX - 1, $iPenY - 1, 38, 38, $hPen2) _GDIPlus_GraphicsDrawImageRectRect($hBackBuffer02, $hVer, $iPenX - 1, $iPenY - 1, 40, 40, 0, 0, 80, 80) If _limite($hMouseMsg[0], $barColor[0], $barColor[2]) And _limite($hMouseMsg[1], $barColor[1], $barColor[3]) Then $iColorX = $hMouseMsg[0] - Mod($hMouseMsg[0] - $barColor[0] - 1, 40) - $barColor[0] - 1 $iColorY = $hMouseMsg[1] - Mod($hMouseMsg[1] - $barColor[1] - 1, 40) - $barColor[1] - 1 If Not $iPenSwtich Then $iPenSwtich = 1 _GDIPlus_GraphicsDrawRect($hBackBuffer01, $iColorX + 1, $iColorY + 1, 38, 38, $hPen) Else _GDIPlus_GraphicsDrawRect($hBackBuffer01, $iColorX + 1, $iColorY + 1, 38, 38, $hPen) If $iPenSwtich Then $iPenSwtich = 0 EndIf If _limite($hMouseMsg[0], $board[0], $board[2]) And _limite($hMouseMsg[1], $board[1], $board[2]) Then $iBoardX = $hMouseMsg[0] - Mod($hMouseMsg[0] - $board[0] - 1, 40) - $board[0] - 1 $iBoardY = $hMouseMsg[1] - Mod($hMouseMsg[1] - $board[1] - 1, 40) - $board[1] - 1 _GDIPlus_GraphicsDrawRect($hBackBuffer00, $iBoardX + 1, $iBoardY + 1, 38, 38, $hPen3) Else EndIf _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap00, $posX, $posY, 1160, 640) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap01, 10, $posY + 80, 80, 480) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap02, 10, 50, 80, 80) $hMsg = GUIGetMsg() Switch $hMsg Case $GUI_EVENT_CLOSE _exit() Case $GUI_EVENT_PRIMARYDOWN If $iPenSwtich Then $iPenX = $iColorX + 1 $iPenY = $iColorY + 1 EndIf EndSwitch Sleep(10) Until False Func _exit() _GDIPlus_GraphicsDispose($hBackBuffer00) _GDIPlus_BitmapDispose($hBitmap00) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_GraphicsDispose($hBackBuffer01) _GDIPlus_BitmapDispose($hBitmap01) _GDIPlus_GraphicsDispose($hBackBuffer02) _GDIPlus_BitmapDispose($hBitmap02) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen2) _GDIPlus_PenDispose($hPen3) _GDIPlus_Shutdown() Exit EndFunc ;==>_exit Func _limite($input, $min, $max) If $input >= $min And $input <= $max Then Return True Else Return False EndIf EndFunc ;==>_limite Edited December 2, 2012 by detefon Visit my repository 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