开发者

Load jpg file in winapi

I want to load a jpg file. I tried to use the LoadImage function but it returns NULL if my image is not bmp. What can I do? Here is my code:

hBitmap =(HBITMAP)LoadImage(0, L"D:\\1.jpg", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE).
开发者_如何转开发


You can have a look at WIC.

Windows Imaging Component (WIC) API enables applications to work with all common image formats. It allows developers to not have to understand intricate details of the image formats they work with. WIC has built-in support for popular formats such as JPEG, PNG, TIFF, and GIF as well as an extensibility model so that developers can create their own WIC decoder and encoder (CODEC) and get platform level support for their image format. WIC is available on Windows XP (SP2 and greater), Windows Vista, Windows Server, and Windows 7.


Use GDI+, it has a JPEG decoder. Start that ball rolling with #include <gdiplus.h> and a small tutorial to know how to use the Image class and GdiplusStartup properly.


If you want to support really old stuff (Win9x etc,) IPicture / OleLoadPicture is your best bet

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜