memerim Posted January 26, 2022 Posted January 26, 2022 (edited) If i get a graphics from a call _GDIPlus_GraphicsCreateFromHDC How do i convert this graphics to a bitmap? What the function below return, isn't a bitmap? Func _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateBitmapFromGraphics", "int", $iWidth, "int", $iHeight, "handle", $hGraphics, _ "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[4] EndFunc ;==>_GDIPlus_BitmapCreateFromGraphics Theres an example in the docs: But the variable name is $g_hBitmap? hBitmap? Trying to understand how to use the function to get a bitmap from a graphics and save it to disk. Edited January 26, 2022 by memerim
ad777 Posted January 26, 2022 Posted January 26, 2022 (edited) If you want to know how to save the contents of a Graphics object to a bitmap, then the answer is that there's no direct approach for doing so.this how you save Bitmap from Graphics and save it to Disk. $g_hGfx = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGfx) ;create a Bitmap object based on a graphics object _GDIPlus_ImageSaveToFile($g_hBitmap,"D:\image.bmp");Save the bitmap to a file on disk, or do whatever else with it Edited January 26, 2022 by ad777 none
memerim Posted January 26, 2022 Author Posted January 26, 2022 (edited) _GDIPlus_BitmapCreateFromGraphics2 Its a different function? or did you mean FromGraphics? I mean from a hdc not a window. Edited January 26, 2022 by memerim
ad777 Posted January 26, 2022 Posted January 26, 2022 (edited) @memerim i mean't from Graphics. From HDC: $g_hGfx = _GDIPlus_GraphicsCreateFromHDC($hdc) ;create a graphics object from a hdc $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGfx) ;create a Bitmap object based on a graphics object Edited January 26, 2022 by ad777 none
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