Question: On Win32, what do you use to load images like jpg and gif into the program window? GDI+? Any good examples to refer?
Asked by Xumbrego (161.148.171.x) on June 27 2011, 7:21pm
Reply on June 27 2011, 7:51pm (edited at June 27 2011, 8:46pm):LICE has functions for these, using jpeglib, giflib, libpng, etc.. check out the test app or SnapEase, here is what you'd typically do:
case WM_PAINT:
{
PAINTSTRUCT ps;
if (BeginPaint(hwnd,&ps))
{
LICE_IBitmap *f = LICE_LoadImage("whatever.jpg");
if (f)
{
LICE_SysBitmap bm;
bm.resize(f->getWidth(),f->getHeight());
LICE_Blit(&bm,f,0,0,0,0,f->getWidth(),f->getHeight(),1.0f,LICE_BLIT_MODE_COPY);
BitBlt(ps.hdc,0,0,f->getWidth(),f->getHeight(),bm.getDC(),0,0,SRCCOPY);
delete f;
}
EndPaint(hwnd,&ps);
}
}
break;
You could also remove the LICE_Blit and pass a sysbitmap into LICE_LoadImage() directly, but I did it the above way since often you'll want to composite things in lice before drawing them anyway...