3 This file is part of libmspgl
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
9 #include <msp/core/except.h>
20 ilEnable(IL_ORIGIN_SET);
21 ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
30 ilDeleteImages(1, &id);
33 void Image::load(const std::string &fn)
36 if(!ilLoadImage(const_cast<char *>(fn.c_str())))
37 throw Exception("Error loading image "+fn);
40 PixelFormat Image::get_format() const
42 switch(ilGetInteger(IL_IMAGE_FORMAT))
44 case IL_COLOR_INDEX: return COLOR_INDEX;
45 case IL_LUMINANCE: return LUMINANCE;
46 case IL_LUMINANCE_ALPHA: return LUMINANCE_ALPHA;
47 case IL_RGB: return RGB;
48 case IL_RGBA: return RGBA;
49 case IL_BGR: return BGR;
50 case IL_BGRA: return BGRA;
51 default: throw InvalidParameterValue("Unknown pixel format in image");
55 unsigned Image::get_width() const
57 return ilGetInteger(IL_IMAGE_WIDTH);
60 unsigned Image::get_height() const
62 return ilGetInteger(IL_IMAGE_HEIGHT);
65 const void *Image::get_data() const
70 bool Image::init_done=false;