1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
image( const string & filename) : graphics(hdcimage),img(towstring(filename).c_str())
{
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
//Load the image from a file
const size_t len = filename.length() + 1;
wchar_t wcstring[len];
swprintf(wcstring, len, L"%s", filename.c_str());
Gdiplus::Image img2(wcstring);
HBITMAP hbitmap=CreateBitmap(img2.GetWidth(),img2.GetHeight(),1,32,NULL);
SelectObject(hdcimage, hbitmap);
Gdiplus::Graphics graphics(hdcimage);
graphics.DrawImage(&img2, 0, 0, img2.GetWidth(), img2.GetHeight());
Gdiplus::Font fnt(L"Verdana", 10);
Gdiplus::SolidBrush solidBrush(Gdiplus::Color(255, 255, 0, 0));
Gdiplus::PointF pt(2, 2);
Gdiplus::Pen pen(Gdiplus::Color(255,0,255,0));
graphics.DrawString(L"Drawing Text", -1,&fnt, pt,&solidBrush );
graphics.DrawLine(&pen, 0, 0, 200, 100);
imageweight=img2.GetWidth();
imageheight=img2.GetHeight();
UINT count = 0;
count = img2.GetFrameDimensionsCount();
GUID* pDimensionIDs = (GUID*)malloc(sizeof(GUID)*count);
img2.GetFrameDimensionsList(pDimensionIDs, count);
framecount=img2.GetFrameCount(&pDimensionIDs[0]);
framedelay =img2.GetPropertyItemSize(PropertyTagFrameDelay);
img.FromFile(wcstring);
MessageBox(NULL,to_string(img.GetWidth()).c_str(),"gif width",MB_OK);
}
|