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

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

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

Post by brandonhotkey » 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.

robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

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

Post by robodesign » 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.

Post Reply

Return to “C/C++”