Its very easy to use GdiPlus to download various image formats, including jpeg, gif (animated), png, etc.
This code demonstrates how to quickly upload a single image frame to HBITMAP: -
#include <gdiplus.h> #pragma comment(lib,"gdiplus.lib") using namespace Gdiplus; HBITMAP LoadImageWithGdiPlus(LPCTSTR pszPngPath) { Image image(pszPngPath); int width = image.GetWidth(); int height = image.GetHeight(); BITMAPINFO bmi; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biClrImportant = 0; bmi.bmiHeader.biClrUsed = 0; bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biHeight = height; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biSize = sizeof (bmi.bmiHeader); bmi.bmiHeader.biSizeImage = 0; //calc later bmi.bmiHeader.biWidth = width; bmi.bmiHeader.biXPelsPerMeter = 0; bmi.bmiHeader.biYPelsPerMeter = 0; BYTE* pBmp = NULL; HBITMAP hbm = CreateDIBSection(NULL,&bmi,DIB_RGB_COLORS,(void**)&pBmp,NULL,0); HDC hdc = CreateCompatibleDC(NULL); HGDIOBJ hobj = SelectObject(hdc,hbm); Graphics graphics(hdc); graphics.DrawImage(&image,0,0); SelectObject(hdc,hobj); DeleteDC(hdc); return hbm; }
Chris becke
source share