Jump to content

How to create a pbitmap from graphics?


memerim
 Share

Recommended Posts

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:
image.thumb.png.1ccce09a371c8507113e2e4ff6ec4ce5.png
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 by memerim
Link to comment
Share on other sites

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 by ad777

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

Link to comment
Share on other sites

@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 by ad777

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

Link to comment
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
 Share

×
×
  • Create New...