I am writing code in C ++, gdi +.
I use the Image method GetThumbnail () to get a sketch. However, I need to convert it to HBITMAP. I know that the following code can get GetHBITMAP:
Bitmap* img;
HBITMAP temp;
Color color;
img->GetHBITMAP(color, &temp); // if img is Bitmap* this works well。
But how can I quickly convert Image * to Bitmap *? Many thanks!
Actually, now I have to use the following method:
int width = sourceImg->GetWidth();
int height = sourceImg->GetHeight();
Bitmap* Result;
result = new Bitmap(width, height,PixelFormat32bppRGB);
Graphics gr(result);
gr.DrawImage(&sourceImg,0,0,width,height);
I really don't know why they do not provide the Image * -> Bitmap * method. but let the GetThumbnail () API return an Image object ....
source
share