Page 1 of 1

how to convert graphics to bitmap in GDI? (C++ or AHK)

Posted: 21 May 2014, 06:10
by brandonhotkey
I have this code:

Code: Select all

GpGraphics * pG;
// I create graphics from bitmap
result = Gdiplus::DllExports::GdipGetImageGraphicsContext(pBitmap, &pG);
 
// here to work with graphics
 
// here to check the image ... save to file
CLSID pngClsid;    
GetEncoderClsid(L"image/png", &pngClsid);
GpBitmap* pBitmap2;
result = Gdiplus::DllExports::GdipCreateBitmapFromGraphics(60, 60, pG, &pBitmap2);

pBitmap refers to bitmap (picture of window). I want to do rotation with the pBitmap2 but I cannot find out

1) how to insert the bitmap (picture) into the bitmap2 (empty one - just created)

2) how to get the graphics back to bitmap.

3) Edit: I think 1) is not what I really need. I need to convert graphics to bitmap. BUt when I call
GdipCreateBitmapFromGraphics I got blank file! So pls how to convert the graphics to bitmap?


result = Gdiplus::DllExports::GdipCreateBitmapFromGraphics(60, 60, pG, &pBitmap2);


If you know how to do it in AHK, pls help and I will find out how to do it in C++. If you know how to do it in C++ help me with C++ version directly.

Re: how to convert graphics to bitmap in GDI? (C++ or AHK)

Posted: 12 Jun 2019, 10:08
by robodesign
I want to do the same thing... have you found the solution?

Thank you very much in advance.