Created
February 11, 2016 14:42
-
-
Save elleryq/dd35b0750dc8467c211f to your computer and use it in GitHub Desktop.
Use GDI+ to combine image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| VOID OnPaint_TryCombineImage(HDC hdc) | |
| { | |
| Graphics graphics(hdc); | |
| Image image(L"qrcode1.bmp"); | |
| CLSID clsid; | |
| Status status; | |
| UINT num; // number of image encoders | |
| UINT size; // size, in bytes, of the image encoder array | |
| ImageCodecInfo* pImageCodecInfo; | |
| Bitmap bitmap(image.GetWidth()*3, image.GetHeight(), PixelFormat24bppRGB); | |
| Graphics* pg = Graphics::FromImage(&bitmap); | |
| SolidBrush solidBrush(Color(255, 255, 255, 255)); | |
| pg->FillRectangle(&solidBrush, 0, 0, image.GetWidth()*3, image.GetHeight()); | |
| pg->DrawImage(&image, 0, 0); | |
| pg->DrawImage(&image, 200, 0); | |
| CachedBitmap cachedBitmap(&bitmap, &graphics); | |
| graphics.DrawCachedBitmap(&cachedBitmap, 0, 0); | |
| GetImageEncodersSize(&num, &size); | |
| pImageCodecInfo = (ImageCodecInfo*)(malloc(size)); | |
| GetImageEncoders(num, size, pImageCodecInfo); | |
| clsid = pImageCodecInfo[0].Clsid; | |
| status = bitmap.Save(L"output.bmp", &clsid, NULL); | |
| printf("status=%d\n", status); | |
| delete pg; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment