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

Talk about things C/C++, some related to AutoHotkey
Posts: 89
Joined: 03 Nov 2013, 05:46

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

21 May 2014, 06:10

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.
Posts: 723
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania

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

12 Jun 2019, 10:08

I want to do the same thing... have you found the solution?

Thank you very much in advance.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 0 guests