showing JPEGs, PNGs and GIFs (WinAPI noob!)

Started by
5 comments, last by Skizz 17 years, 2 months ago
Hi I've programmed quite a number of things with SDL. Now I would like to learn some more about the WinAPI. What keywords should I google if I wanted to program a simple picture viewer (as a first step) that displays JPEGs, PNGs and GIFs? Is it possible to do that in "pure" WinAPI (maybe even without DirectX)? Or are there any open/free libraries I could use? (except SDL/SDL_image) thanks! RomanH
Advertisement
I guess this could be something interesting for you:

DevIL - OpenIL

Quote from website:

Quote:
Currently, DevIL can load .bmp, .cut, .dds, .doom, .gif, .ico, .jpg, .lbm, .mdl, .mng, .pal, .pbm, .pcd, .pcx, .pgm, .pic, .png, .ppm, .psd, .psp, .raw, .sgi, .tga and .tif .hdr files.
Formats supported for saving include .bmp, .dds, .h, .jpg, .pal, .pbm, .pcx, .hdr, .pgm,.png, .ppm, .raw, .sgi, .tga and .tif.

DevIL currently supports the following APIs for display: OpenGL, Windows GDI, SDL, DirectX and Allegro. Compilers that can compile DevIL or use it include Djgpp, MSVC++, Linux gcc, Delphi, Visual Basic, Power Basic and Dev-C++.
Next time I give my advice, I'll buy some bubblegum so I won't your kick ass!
Vanilla GDI has no functions for loading images from disk. It does have functions to load images from resource files (LoadImage). To load images not found in resources, you must write the loader yourself. The structure of a BMP file is:

BITMAPFILEHEADER
BITMAPINFOHEADER or BITMAPV4HEADER or BITMAPV5HEADER
array of RGBQUAD
image data

You must load these structures from the file, and create Bitmap objects from them. It's not an easy or short task to load image files in GDI. GDI+ and DirectX have library functions to load more file types with much less code. From Win98 onwards, GDI supported PNG and JPEG. Here is an MSDN article about GDI bitmaps and how to load them.

It'll be far easier to use a 3rd party library like the one mentioned above.

Skizz

Thanks for the info. I've taken a look at DevIL and it looks like it's exactly what I need.

Thanks!

RomanH
Quote:Original post by Skizz
Vanilla GDI has no functions for loading images from disk. It does have functions to load images from resource files (LoadImage).


A bit of a contradiction here because LoadImage can load images from a file. GDI+ is definitely more flexible though :)
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
Hi!

thanks for trying to help. In the meantime I have experimented with the FreeImage library a little and had some first successes. I'm now able to display tons of different formats in a window.

Free Image Hosting at www.ImageShack.us

thanks!

RomanH
Quote:Original post by JY
Quote:Original post by Skizz
Vanilla GDI has no functions for loading images from disk. It does have functions to load images from resource files (LoadImage).


A bit of a contradiction here because LoadImage can load images from a file. GDI+ is definitely more flexible though :)

You learn something new everyday.

Skizz

This topic is closed to new replies.

Advertisement