Andreik Posted February 24, 2009 Posted February 24, 2009 How can I draw only one point with GDI+? I tried to draw with _GDIPlus_GraphicsDrawLine() but 2 points.
jvanegmond Posted February 24, 2009 Posted February 24, 2009 (edited) Try _GDIPlus_GraphicsFillRect with width 1 and heigth 1.Edit: I think the proper technique is to create a pen and use the pen to draw a pixel. Edited February 24, 2009 by Manadar github.com/jvanegmond
Andreik Posted February 24, 2009 Author Posted February 24, 2009 Try _GDIPlus_GraphicsFillRect with width 1 and heigth 1.Edit: I think the proper technique is to create a pen and use the pen to draw a pixel.Ok, I could create a pen but what function to choose to draw? _GDIPlus_GraphicsFillRect() work only for 2 pixels.
Malkey Posted February 24, 2009 Posted February 24, 2009 How can I draw only one point with GDI+? I tried to draw with _GDIPlus_GraphicsDrawLine() but 2 points. This example works and repaints very fast. expandcollapse popup#include <gdiplus.au3> #include <WindowsConstants.au3> ; Example modified from ; http://www.autoitscript.com/forum/index.php?s=&showtopic=89879&view=findpost&p=647719 Opt("GUIOnEventMode", 1) Global Const $Width = 500 Global Const $Height = 500 Global Const $PI = 3.14159265 $hWnd = GUICreate("Double buffering with GDI(+)", $Width, $Height) GUISetOnEvent(-3, "close") GUISetOnEvent(0xF, "MY_PAINT") _GDIPlus_Startup() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphics) $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) $ScreenDc = _WinAPI_GetDC($hWnd) GUISetState() _GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF) _AntiAlias($hBackbuffer) For $nun = 3 To 444 Step 3 _GDIPlus_BitmapSetPixel($hBitmap, $nun, $nun, 0xFF000000) Next $gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) $dc = _WinAPI_CreateCompatibleDC($ScreenDc) _WinAPI_SelectObject($dc, $gdibitmap) _WinAPI_BitBlt($ScreenDc, 0, 0, $Width, $Height, $dc, 0, 0, $SRCCOPY) GUIRegisterMsg(0xF, "MY_PAINT") Do Until Not Sleep(250) Func close() _WinAPI_DeleteDC($dc) _WinAPI_DeleteObject($gdibitmap) _WinAPI_ReleaseDC($hWnd, $ScreenDc) _GDIPlus_GraphicsDispose($hBackbuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Exit EndFunc ;==>close Func MY_PAINT($hWnd1, $MSG, $wParam, $lParam) ; Check, if the GUI with the Graphic should be repainted If $hWnd1 = $hWnd Then $Timer = TimerInit() ;_GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF) DllCall($ghGDIPDll, "int", "GdipGraphicsClear", "hwnd", $hBackbuffer, "int", 0xFFFFFFFF) ;_WinAPI_BitBlt($ScreenDc, 0, 0, $Width, $Height, $dc, 0, 0, $SRCCOPY) DllCall("GDI32.dll", "int", "BitBlt", "hwnd", $ScreenDc, "int", 0, "int", 0, "int", $Width, "int", $Height, _ "hwnd", $dc, "int", 0, "int", 0, "int", $SRCCOPY) ConsoleWrite(TimerDiff($Timer) & @CRLF) EndIf EndFunc ;==>MY_PAINT Func _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, $iARGB) Local $aRet $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapSetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "dword", $iARGB) Return EndFunc ;==>_GDIPlus_BitmapSetPixel Func _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) Local $tArgb, $pArgb, $aRet $tArgb = DllStructCreate("dword Argb") $pArgb = DllStructGetPtr($tArgb) $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "ptr", $pArgb) Return "0x" & Hex(DllStructGetData($tArgb, "Argb")) EndFunc ;==>_GDIPlus_BitmapGetPixel Func _AntiAlias($hGraphics) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", 2) If @error Then Return SetError(@error, @extended, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_AntiAlias
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