Skip to main content
GameDev.net gamedev.net
🔒 Locked

image loading

Started by ronkfist Aug 7, 2006 at 3:30 AM 10 replies 1.6k views
Original Post
ronkfist
ronkfist
How do you load images? Right now I'm using something I made myself, but it can only load bitmaps. I was kinda proud when I wrote it :), but ive decided to ditch it and start using some library that supports multiple formats(png, bmp at least). There are just too many to test them all out, so what do you do? So far I've taken a look at CImg, but this one has a license I've never heard about. It can do stuff I dont need(like creating windows and such) and it depends on various other libraries. In other words this one seems too heavy for my needs.
deepdene
deepdene
Pretty broad question.

If you are talking about C++ then there are quite a few image loading API's out there, one common one is DevIL http://openil.sourceforge.net/

It works on quite a few different platforms and reads most image formats out there.

ronkfist
ronkfist
oh yea I was talking bout C++, I'll take a look at that. And forgot to mention I need it to work on multiple platforms, nix, windows and mac at least :)
deepdene
deepdene
BTW I had a quick look at CImg, the library dependency it has seems to be pretty standard ones

ImageMagick is for image manipulation, allows cropping, resizing etc.

libpng is for loading png files
libjpeg is for loading jpeg files
No idea what XMedCon is for though

CImg also seems to use template c++ code, Devil is more lightweight and its interface is a lot simpler (similar functionality though) and uses more external function C style approach.
ronkfist
ronkfist
hmm maybe I should just go with libpng, I prefer as lightweight as possible.
pulpfist
pulpfist
This 3D Model loader contains some simple bmp and tga loaders. I thought the tga loader could be of interrest to you if you want to support tga files.

Note that the code has some inconsistencies in the use of free/delete[].
CrazyCdn
CrazyCdn
I wouldn't recommend code that has leaks in it. nehe.gamedev.net has a tga loader that works (C code but works). There are also a few free image loading libraries out there. DevIL ( http://openil.sourceforge.net/ ) is cross platform.
"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin
kimi
kimi
Hi, ok I am relatively new to program in C/C++. Can someon tell me what are you all taking about?. I have never used graphics before. Ho can I display something graphical on screen. eg: colorful square, triangle.

I am still getting basic right. How to display and how can I make it move???

pulpfist
pulpfist
Quote:
Original post by kimi
Hi, ok I am relatively new to program in C/C++. Can someon tell me what are you all taking about?. I have never used graphics before. Ho can I display something graphical on screen. eg: colorful square, triangle.

I am still getting basic right. How to display and how can I make it move???


Displaying an image on a window require you to do two things:
1 Load the image file into memory (That is what we discuss)
2 Copy the image (now in memory) to the screen memory.

Since the process of displaying graphics is different on different OS's we need an API in addition to C++ to accomplish this.
On a MS Windows system we can use windows API, or if we want the benefits of hardware accelleration we can use directx or opengl.
There is a pretty good windows API tutorial online, but be aware that windows API is quite a challenge if your new to programming all together.
DeadXorAlive
DeadXorAlive
If you want something small for png, check out Lode's png loader, it's only a fraction of libpng, which is also quite cumbersome.
I've used SDL_Image, Devil and Lode's stuff. It depends on what you want really, I like SDL_Image because it's easy, Devil because it does a lot and Lode's png loader because it's so damn small (and easy).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.