IM: im_plus.h Source File
From IM - An Imaging Tool
im_plus.h
Go to the documentation of this file.00001 /** \file 00002 * \brief C++ Wrapper for File Access 00003 * 00004 * See Copyright Notice in im_lib.h 00005 */ 00006 00007 #ifndef __IM_PLUS_H 00008 #define __IM_PLUS_H 00009 00010 00011 /** \brief C++ Wrapper for the Image File Structure 00012 * 00013 * \par 00014 * Usage is just like the C API. Open and New are replaced by equivalent constructors. \n 00015 * Close is replaced by the destructor. Error checking is done by the Error() member. \n 00016 * Open and New errors are cheked using the Failed() member. 00017 * \ingroup file */ 00018 class imImageFile 00019 { 00020 imFile* ifile; 00021 int error; 00022 00023 imImageFile() {}; 00024 00025 public: 00026 00027 imImageFile(const char* file_name) 00028 { this->ifile = imFileOpen(file_name, &this->error); } 00029 00030 imImageFile(const char* file_name, const char* format) 00031 { this->ifile = imFileNew(file_name, format, &this->error); } 00032 00033 ~imImageFile() 00034 { if (this->ifile) imFileClose(this->ifile); } 00035 00036 int Failed() 00037 { return this->ifile == 0; } 00038 00039 int Error() 00040 { return this->error; } 00041 00042 void SetAttribute(const char* attrib, int data_type, int count, const void* data) 00043 { imFileSetAttribute(this->ifile, attrib, data_type, count, data); } 00044 00045 const void* GetAttribute(const char* attrib, int *data_type, int *count) 00046 { return imFileGetAttribute(this->ifile, attrib, data_type, count); } 00047 00048 void GetInfo(char* format, char* compression, int *image_count) 00049 { imFileGetInfo(this->ifile, format, compression, image_count); } 00050 00051 void ReadImageInfo(int index, int *width, int *height, int *color_mode, int *data_type) 00052 { this->error = imFileReadImageInfo(this->ifile, index, width, height, color_mode, data_type); } 00053 00054 void GetPalette(long* palette, int *palette_count) 00055 { imFileGetPalette(this->ifile, palette, palette_count); } 00056 00057 void ReadImageData(void* data, int convert2bitmap, int color_mode_flags) 00058 { this->error = imFileReadImageData(this->ifile, data, convert2bitmap, color_mode_flags); } 00059 00060 void SetInfo(const char* compression) 00061 { imFileSetInfo(this->ifile, compression); } 00062 00063 void SetPalette(long* palette, int palette_count) 00064 { imFileSetPalette(this->ifile, palette, palette_count); } 00065 00066 void WriteImageInfo(int width, int height, int color_mode, int data_type) 00067 { this->error = imFileWriteImageInfo(this->ifile, width, height, color_mode, data_type); } 00068 00069 void WriteImageData(void* data) 00070 { this->error = imFileWriteImageData(this->ifile, data); } 00071 }; 00072 00073 #endif