diff options
author | scuri <scuri> | 2008-12-03 15:45:33 +0000 |
---|---|---|
committer | scuri <scuri> | 2008-12-03 15:45:33 +0000 |
commit | 5cb32502b777eb0dec8ec2d8a8c9714ed487b86f (patch) | |
tree | dd4da12c768ade65115f260c1d12d64aa180861b /src | |
parent | 41d2b4d6fbb26092580fe06cd997c238366eb532 (diff) |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/im_file.cpp | 82 | ||||
-rw-r--r-- | src/im_fileraw.cpp | 6 | ||||
-rw-r--r-- | src/im_format.cpp | 38 | ||||
-rw-r--r-- | src/im_format_avi.cpp | 61 | ||||
-rw-r--r-- | src/im_format_bmp.cpp | 52 | ||||
-rw-r--r-- | src/im_format_ecw.cpp | 40 | ||||
-rw-r--r-- | src/im_format_gif.cpp | 49 | ||||
-rw-r--r-- | src/im_format_ico.cpp | 52 | ||||
-rw-r--r-- | src/im_format_jp2.cpp | 48 | ||||
-rw-r--r-- | src/im_format_jpeg.cpp | 49 | ||||
-rw-r--r-- | src/im_format_krn.cpp | 45 | ||||
-rw-r--r-- | src/im_format_led.cpp | 50 | ||||
-rw-r--r-- | src/im_format_pcx.cpp | 56 | ||||
-rw-r--r-- | src/im_format_png.cpp | 49 | ||||
-rw-r--r-- | src/im_format_pnm.cpp | 48 | ||||
-rw-r--r-- | src/im_format_ras.cpp | 52 | ||||
-rw-r--r-- | src/im_format_raw.cpp | 54 | ||||
-rw-r--r-- | src/im_format_sgi.cpp | 49 | ||||
-rw-r--r-- | src/im_format_tga.cpp | 57 | ||||
-rw-r--r-- | src/im_format_tiff.cpp | 47 | ||||
-rw-r--r-- | src/im_format_wmv.cpp | 65 |
21 files changed, 616 insertions, 433 deletions
diff --git a/src/im_file.cpp b/src/im_file.cpp index 81e6128..a43b0d4 100644 --- a/src/im_file.cpp +++ b/src/im_file.cpp @@ -2,7 +2,7 @@ * \brief File Access * * See Copyright Notice in im_lib.h - * $Id: im_file.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_file.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include <stdlib.h> @@ -49,66 +49,66 @@ imFile* imFileOpen(const char* file_name, int *error) { assert(file_name); - imFormat* iformat = imFormatOpen(file_name, error); - if (!iformat) + imFileFormatBase* ifileformat = imFileFormatBaseOpen(file_name, error); + if (!ifileformat) return NULL; - imFileClear(iformat); + imFileClear(ifileformat); - iformat->attrib_table = new imAttribTable(599); + ifileformat->attrib_table = new imAttribTable(599); - iformat->counter = imCounterBegin(file_name); + ifileformat->counter = imCounterBegin(file_name); - return iformat; + return ifileformat; } imFile* imFileOpenAs(const char* file_name, const char* format, int *error) { assert(file_name); - imFormat* iformat = imFormatOpenAs(file_name, format, error); - if (!iformat) + imFileFormatBase* ifileformat = imFileFormatBaseOpenAs(file_name, format, error); + if (!ifileformat) return NULL; - imFileClear(iformat); + imFileClear(ifileformat); - iformat->attrib_table = new imAttribTable(599); + ifileformat->attrib_table = new imAttribTable(599); - iformat->counter = imCounterBegin(file_name); + ifileformat->counter = imCounterBegin(file_name); - return iformat; + return ifileformat; } imFile* imFileNew(const char* file_name, const char* format, int *error) { assert(file_name); - imFormat* iformat = imFormatNew(file_name, format, error); - if (!iformat) + imFileFormatBase* ifileformat = imFileFormatBaseNew(file_name, format, error); + if (!ifileformat) return NULL; - imFileClear(iformat); + imFileClear(ifileformat); - iformat->is_new = 1; - iformat->image_count = 0; - iformat->compression[0] = 0; + ifileformat->is_new = 1; + ifileformat->image_count = 0; + ifileformat->compression[0] = 0; - iformat->attrib_table = new imAttribTable(101); + ifileformat->attrib_table = new imAttribTable(101); - iformat->counter = imCounterBegin(file_name); + ifileformat->counter = imCounterBegin(file_name); - return iformat; + return ifileformat; } void imFileClose(imFile* ifile) { assert(ifile); - imFormat* iformat = (imFormat*)ifile; + imFileFormatBase* ifileformat = (imFileFormatBase*)ifile; imAttribTable* attrib_table = (imAttribTable*)ifile->attrib_table; imCounterEnd(ifile->counter); - iformat->Close(); + ifileformat->Close(); if (ifile->line_buffer) free(ifile->line_buffer); @@ -118,16 +118,16 @@ void imFileClose(imFile* ifile) void* imFileHandle(imFile* ifile, int index) { assert(ifile); - imFormat* iformat = (imFormat*)ifile; - return iformat->Handle(index); + imFileFormatBase* ifileformat = (imFileFormatBase*)ifile; + return ifileformat->Handle(index); } void imFileSetAttribute(imFile* ifile, const char* attrib, int data_type, int count, const void* data) { assert(ifile); assert(attrib); - imFormat* iformat = (imFormat*)ifile; - imAttribTable* atable = (imAttribTable*)iformat->attrib_table; + imFileFormatBase* ifileformat = (imFileFormatBase*)ifile; + imAttribTable* atable = (imAttribTable*)ifileformat->attrib_table; if (data) atable->Set(attrib, data_type, count, data); else @@ -138,8 +138,8 @@ const void* imFileGetAttribute(imFile* ifile, const char* attrib, int *data_type { assert(ifile); assert(attrib); - imFormat* iformat = (imFormat*)ifile; - imAttribTable* attrib_table = (imAttribTable*)iformat->attrib_table; + imFileFormatBase* ifileformat = (imFileFormatBase*)ifile; + imAttribTable* attrib_table = (imAttribTable*)ifileformat->attrib_table; return attrib_table->Get(attrib, data_type, count); } @@ -167,10 +167,10 @@ void imFileGetAttributeList(imFile* ifile, char** attrib, int *attrib_count) void imFileGetInfo(imFile* ifile, char* format, char* compression, int *image_count) { assert(ifile); - imFormat* iformat = (imFormat*)ifile; + imFileFormatBase* ifileformat = (imFileFormatBase*)ifile; if(compression) strcpy(compression, ifile->compression); - if(format) strcpy(format, iformat->format); + if(format) strcpy(format, ifileformat->iformat->format); if (image_count) *image_count = ifile->image_count; } @@ -214,7 +214,7 @@ int imFileReadImageInfo(imFile* ifile, int index, int *width, int *height, int * { assert(ifile); assert(!ifile->is_new); - imFormat* iformat = (imFormat*)ifile; + imFileFormatBase* ifileformat = (imFileFormatBase*)ifile; if (index >= ifile->image_count) return IM_ERR_DATA; @@ -233,7 +233,7 @@ int imFileReadImageInfo(imFile* ifile, int index, int *width, int *height, int * ifile->convert_bpp = 0; ifile->switch_type = 0; - int error = iformat->ReadImageInfo(index); + int error = ifileformat->ReadImageInfo(index); if (error) return error; if (!imImageCheckFormat(ifile->file_color_mode, ifile->file_data_type)) @@ -322,7 +322,7 @@ int imFileReadImageData(imFile* ifile, void* data, int convert2bitmap, int color { assert(ifile); assert(!ifile->is_new); - imFormat* iformat = (imFormat*)ifile; + imFileFormatBase* ifileformat = (imFileFormatBase*)ifile; if (ifile->image_index == -1) return IM_ERR_DATA; @@ -350,7 +350,7 @@ int imFileReadImageData(imFile* ifile, void* data, int convert2bitmap, int color imFileLineBufferInit(ifile); - int ret = iformat->ReadImageData(data); + int ret = ifileformat->ReadImageData(data); // here we can NOT change the file_color_mode we already returned to the user // so just check for gray and binary consistency @@ -389,12 +389,12 @@ int imFileWriteImageInfo(imFile* ifile, int width, int height, int user_color_mo { assert(ifile); assert(ifile->is_new); - imFormat* iformat = (imFormat*)ifile; + imFileFormatBase* ifileformat = (imFileFormatBase*)ifile; if (!imImageCheckFormat(user_color_mode, user_data_type)) return IM_ERR_DATA; - int error = iformat->CanWrite(ifile->compression, user_color_mode, user_data_type); + int error = ifileformat->iformat->CanWrite(ifile->compression, user_color_mode, user_data_type); if (error) return error; ifile->width = width; @@ -409,7 +409,7 @@ int imFileWriteImageInfo(imFile* ifile, int width, int height, int user_color_mo ifile->palette[1] = imColorEncode(255, 255, 255); } - return iformat->WriteImageInfo(); + return ifileformat->WriteImageInfo(); } int imFileWriteImageData(imFile* ifile, void* data) @@ -417,12 +417,12 @@ int imFileWriteImageData(imFile* ifile, void* data) assert(ifile); assert(ifile->is_new); assert(data); - imFormat* iformat = (imFormat*)ifile; + imFileFormatBase* ifileformat = (imFileFormatBase*)ifile; if (!imFileCheckConversion(ifile)) return IM_ERR_DATA; imFileLineBufferInit(ifile); - return iformat->WriteImageData(data); + return ifileformat->WriteImageData(data); } diff --git a/src/im_fileraw.cpp b/src/im_fileraw.cpp index da7ef81..530b6c9 100644 --- a/src/im_fileraw.cpp +++ b/src/im_fileraw.cpp @@ -2,7 +2,7 @@ * \brief RAW File Format Open/New Functions * * See Copyright Notice in im_lib.h - * $Id: im_fileraw.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_fileraw.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im.h" @@ -21,7 +21,7 @@ imFile* imFileOpenRaw(const char* file_name, int *error) { assert(file_name); - imFormat* iformat = imFormatInitRAW(); + imFileFormatBase* iformat = imFormatInitRAW(); *error = iformat->Open(file_name); if (*error) { @@ -42,7 +42,7 @@ imFile* imFileNewRaw(const char* file_name, int *error) { assert(file_name); - imFormat* iformat = imFormatInitRAW(); + imFileFormatBase* iformat = imFormatInitRAW(); *error = iformat->New(file_name); if (*error) { diff --git a/src/im_format.cpp b/src/im_format.cpp index be9892c..d389743 100644 --- a/src/im_format.cpp +++ b/src/im_format.cpp @@ -2,7 +2,7 @@ * \brief File Format Access * * See Copyright Notice in im_lib.h - * $Id: im_format.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ @@ -163,7 +163,7 @@ static char* utlFileGetExt(const char *file_name) return file_ext; } -imFormat* imFormatOpen(const char* file_name, int *error) +imFileFormatBase* imFileFormatBaseOpen(const char* file_name, int *error) { int i; @@ -191,18 +191,20 @@ imFormat* imFormatOpen(const char* file_name, int *error) { ext_mark[i] = 1; // Mark this format to avoid testing it again in the next phase - *error = iformat->Open(file_name); + imFileFormatBase* ifileformat = iformat->Create(); + *error = ifileformat->Open(file_name); if (*error != IM_ERR_NONE && *error != IM_ERR_FORMAT) // Error situation that must abort { // Only IM_ERR_FORMAT is a valid error here free(extension); delete [] ext_mark; + delete ifileformat; return NULL; } else if (*error == IM_ERR_NONE) // Sucessfully oppened the file { free(extension); delete [] ext_mark; - return iformat; + return ifileformat; } } } @@ -218,17 +220,18 @@ imFormat* imFormatOpen(const char* file_name, int *error) if (!ext_mark[i]) { imFormat* iformat = iFormatList[i]; - - *error = iformat->Open(file_name); + imFileFormatBase* ifileformat = iformat->Create(); + *error = ifileformat->Open(file_name); if (*error != IM_ERR_NONE && *error != IM_ERR_FORMAT) // Error situation that must abort { // Only IM_ERR_FORMAT is a valid error here delete [] ext_mark; + delete ifileformat; return NULL; } else if (*error == IM_ERR_NONE) // Sucessfully oppened the file { delete [] ext_mark; - return iformat; + return ifileformat; } } } @@ -238,7 +241,7 @@ imFormat* imFormatOpen(const char* file_name, int *error) return NULL; } -imFormat* imFormatOpenAs(const char* file_name, const char* format, int *error) +imFileFormatBase* imFileFormatBaseOpenAs(const char* file_name, const char* format, int *error) { assert(file_name); assert(format); @@ -257,17 +260,21 @@ imFormat* imFormatOpenAs(const char* file_name, const char* format, int *error) return NULL; } - *error = iformat->Open(file_name); + imFileFormatBase* ifileformat = iformat->Create(); + *error = ifileformat->Open(file_name); if (*error != IM_ERR_NONE && *error != IM_ERR_FORMAT) // Error situation that must abort + { + delete ifileformat; return NULL; + } else if (*error == IM_ERR_NONE) // Sucessfully oppened the file - return iformat; + return ifileformat; *error = IM_ERR_FORMAT; return NULL; } -imFormat* imFormatNew(const char* file_name, const char* format, int *error) +imFileFormatBase* imFileFormatBaseNew(const char* file_name, const char* format, int *error) { assert(file_name); assert(format); @@ -280,10 +287,13 @@ imFormat* imFormatNew(const char* file_name, const char* format, int *error) return NULL; } - *error = iformat->New(file_name); + imFileFormatBase* ifileformat = iformat->Create(); + *error = ifileformat->New(file_name); if (*error) + { + delete ifileformat; return NULL; + } - return iformat; + return ifileformat; } - diff --git a/src/im_format_avi.cpp b/src/im_format_avi.cpp index 3de98d4..632e45b 100644 --- a/src/im_format_avi.cpp +++ b/src/im_format_avi.cpp @@ -2,7 +2,7 @@ * \brief AVI - Windows Audio-Video Interleaved RIFF * * See Copyright Notice in im_lib.h - * $Id: im_format_avi.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_avi.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -41,7 +41,7 @@ static const char* iAVICompTable[15] = "CUSTOM" // (show compression dialog) }; -class imFormatAVI: public imFormat +class imFileFormatAVI: public imFileFormatBase { PAVIFILE file; PAVISTREAM stream; @@ -63,15 +63,8 @@ class imFormatAVI: public imFormat void InitMasks(imDib* dib); public: - imFormatAVI() - :imFormat("AVI", - "Windows Audio-Video Interleaved RIFF", - "*.avi;", - iAVICompTable, - 15, - 1) - {} - ~imFormatAVI() {} + imFileFormatAVI(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatAVI() {} int Open(const char* file_name); int New(const char* file_name); @@ -81,6 +74,22 @@ public: int ReadImageData(void* data); int WriteImageInfo(); int WriteImageData(void* data); +}; + +class imFormatAVI: public imFormat +{ +public: + imFormatAVI() + :imFormat("AVI", + "Windows Audio-Video Interleaved RIFF", + "*.avi;", + iAVICompTable, + 15, + 1) + {} + ~imFormatAVI() {} + + imFileFormatBase* Create(void) const { return new imFileFormatAVI(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; @@ -89,9 +98,9 @@ void imFormatRegisterAVI(void) imFormatRegister(new imFormatAVI()); } -int imFormatAVI::Open(const char* file_name) +int imFileFormatAVI::Open(const char* file_name) { - /* initializes avi file library */ + /* initializes avi file library, can be called many times */ AVIFileInit(); /* open existing file */ @@ -152,9 +161,9 @@ int imFormatAVI::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatAVI::New(const char* file_name) +int imFileFormatAVI::New(const char* file_name) { - /* initializes avi file library */ + /* initializes avi file library, can be called many times */ AVIFileInit(); /* creates a new file */ @@ -179,7 +188,7 @@ int imFormatAVI::New(const char* file_name) return IM_ERR_NONE; } -void imFormatAVI::Close() +void imFileFormatAVI::Close() { if (this->dib) imDibDestroy(this->dib); @@ -193,10 +202,10 @@ void imFormatAVI::Close() if (this->stream) AVIStreamRelease(this->stream); AVIFileRelease(this->file); - AVIFileExit(); + AVIFileExit(); /* called one for each AVIFileInit */ } -void* imFormatAVI::Handle(int index) +void* imFileFormatAVI::Handle(int index) { if (index == 1) return (void*)this->file; @@ -206,7 +215,7 @@ void* imFormatAVI::Handle(int index) return NULL; } -int imFormatAVI::ReadImageInfo(int index) +int imFileFormatAVI::ReadImageInfo(int index) { this->current_frame = index; @@ -280,7 +289,7 @@ int imFormatAVI::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatAVI::WriteImageInfo() +int imFileFormatAVI::WriteImageInfo() { if (dib) { @@ -423,7 +432,7 @@ int imFormatAVI::WriteImageInfo() return IM_ERR_NONE; } -void imFormatAVI::ReadPalette(unsigned char* bmp_colors) +void imFileFormatAVI::ReadPalette(unsigned char* bmp_colors) { /* convert the color map to the IM format */ for (int c = 0; c < this->palette_count; c++) @@ -435,7 +444,7 @@ void imFormatAVI::ReadPalette(unsigned char* bmp_colors) } } -void imFormatAVI::WritePalette(unsigned char* bmp_colors) +void imFileFormatAVI::WritePalette(unsigned char* bmp_colors) { /* convert the color map to the IM format */ for (int c = 0; c < this->palette_count; c++) @@ -446,7 +455,7 @@ void imFormatAVI::WritePalette(unsigned char* bmp_colors) } } -void imFormatAVI::InitMasks(imDib* dib) +void imFileFormatAVI::InitMasks(imDib* dib) { if (dib->bmih->biCompression == BI_BITFIELDS) { @@ -495,7 +504,7 @@ void imFormatAVI::InitMasks(imDib* dib) } } -void imFormatAVI::FixRGB(int bpp) +void imFileFormatAVI::FixRGB(int bpp) { int x; @@ -552,7 +561,7 @@ void imFormatAVI::FixRGB(int bpp) } } -int imFormatAVI::ReadImageData(void* data) +int imFileFormatAVI::ReadImageData(void* data) { imCounterTotal(this->counter, this->height, "Reading AVI Frame..."); @@ -596,7 +605,7 @@ int imFormatAVI::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatAVI::WriteImageData(void* data) +int imFileFormatAVI::WriteImageData(void* data) { imCounterTotal(this->counter, this->height, "Writing AVI Frame..."); diff --git a/src/im_format_bmp.cpp b/src/im_format_bmp.cpp index 809169b..5ec4938 100644 --- a/src/im_format_bmp.cpp +++ b/src/im_format_bmp.cpp @@ -2,7 +2,7 @@ * \brief BMP - Windows Device Independent Bitmap * * See Copyright Notice in im_lib.h - * $Id: im_format_bmp.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_bmp.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -283,7 +283,7 @@ static const char* iBMPCompTable[2] = "RLE" }; -class imFormatBMP: public imFormat +class imFileFormatBMP: public imFileFormatBase { imBinFile* handle; /* the binary file handle */ unsigned short bpp; /* number of bits per pixel */ @@ -299,6 +299,22 @@ class imFormatBMP: public imFormat void FixRGBOrder(); public: + imFileFormatBMP(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatBMP() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatBMP: public imFormat +{ +public: imFormatBMP() :imFormat("BMP", "Windows Device Independent Bitmap", @@ -309,23 +325,17 @@ public: {} ~imFormatBMP() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatBMP(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; + void imFormatRegisterBMP(void) { imFormatRegister(new imFormatBMP()); } -int imFormatBMP::Open(const char* file_name) +int imFileFormatBMP::Open(const char* file_name) { unsigned short id; unsigned int dword; @@ -404,7 +414,7 @@ int imFormatBMP::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatBMP::New(const char* file_name) +int imFileFormatBMP::New(const char* file_name) { /* opens the binary file for writing with intel byte order */ handle = imBinFileNew(file_name); @@ -418,12 +428,12 @@ int imFormatBMP::New(const char* file_name) return IM_ERR_NONE; } -void imFormatBMP::Close() +void imFileFormatBMP::Close() { imBinFileClose(handle); } -void* imFormatBMP::Handle(int index) +void* imFileFormatBMP::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -431,7 +441,7 @@ void* imFormatBMP::Handle(int index) return NULL; } -int imFormatBMP::ReadImageInfo(int index) +int imFileFormatBMP::ReadImageInfo(int index) { (void)index; unsigned int dword; @@ -614,7 +624,7 @@ int imFormatBMP::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatBMP::WriteImageInfo() +int imFileFormatBMP::WriteImageInfo() { // force bottom up orientation this->file_data_type = IM_BYTE; @@ -735,7 +745,7 @@ int imFormatBMP::WriteImageInfo() return IM_ERR_NONE; } -int imFormatBMP::ReadPalette() +int imFileFormatBMP::ReadPalette() { int nc; if (this->is_os2) @@ -762,7 +772,7 @@ int imFormatBMP::ReadPalette() return IM_ERR_NONE; } -int imFormatBMP::WritePalette() +int imFileFormatBMP::WritePalette() { unsigned char bmp_colors[256 * 4]; @@ -783,7 +793,7 @@ int imFormatBMP::WritePalette() return IM_ERR_NONE; } -void imFormatBMP::FixRGBOrder() +void imFileFormatBMP::FixRGBOrder() { int x; @@ -844,7 +854,7 @@ void imFormatBMP::FixRGBOrder() } } -int imFormatBMP::ReadImageData(void* data) +int imFileFormatBMP::ReadImageData(void* data) { imCounterTotal(this->counter, this->height, "Reading BMP..."); @@ -879,7 +889,7 @@ int imFormatBMP::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatBMP::WriteImageData(void* data) +int imFileFormatBMP::WriteImageData(void* data) { imCounterTotal(this->counter, this->height, "Writing BMP..."); diff --git a/src/im_format_ecw.cpp b/src/im_format_ecw.cpp index 0b77b56..bba99b0 100644 --- a/src/im_format_ecw.cpp +++ b/src/im_format_ecw.cpp @@ -23,20 +23,14 @@ static const char* iECWCompTable[2] = "JPEG-2000", }; -class imFormatECW: public imFormat +class imFileFormatECW: public imFileFormatBase { NCSFileView *pNCSFileView; // NCSEcwCompressClient *pClient; public: - imFormatECW() - :imFormat("ECW", - "ECW JPEG-2000 File Format", - "*.ecw;*.jp2;*.j2k;*.jpc;*.j2c;", - iECWCompTable, - 2, - 0) - {} + imFileFormatECW(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatECW() {} int Open(const char* file_name); int New(const char* file_name); @@ -46,6 +40,22 @@ public: int ReadImageData(void* data); int WriteImageInfo(){return 0;} // do nothing for now; int WriteImageData(void* data){(void)data; return 0;} // do nothing for now; +}; + +class imFormatECW: public imFormat +{ +public: + imFormatECW() + :imFormat("ECW", + "ECW JPEG-2000 File Format", + "*.ecw;*.jp2;*.j2k;*.jpc;*.j2c;", + iECWCompTable, + 2, + 0) + {} + ~imFormatECW() {} + + imFileFormatBase* Create(void) const { return new imFileFormatECW(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; @@ -54,7 +64,7 @@ void imFormatRegisterECW(void) imFormatRegister(new imFormatECW()); } -int imFormatECW::Open(const char* file_name) +int imFileFormatECW::Open(const char* file_name) { NCSError eError = NCScbmOpenFileView((char*)file_name, &this->pNCSFileView, NULL); if (eError != NCS_SUCCESS) @@ -82,7 +92,7 @@ int imFormatECW::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatECW::New(const char* file_name) +int imFileFormatECW::New(const char* file_name) { strcpy(this->compression, "JPEG-2000"); this->image_count = 1; @@ -91,7 +101,7 @@ int imFormatECW::New(const char* file_name) return IM_ERR_FORMAT; } -void imFormatECW::Close() +void imFileFormatECW::Close() { if (this->is_new) ;// NCSEcwCompressClose(this->pClient); @@ -99,7 +109,7 @@ void imFormatECW::Close() NCScbmCloseFileView(this->pNCSFileView); } -void* imFormatECW::Handle(int index) +void* imFileFormatECW::Handle(int index) { (void)index; @@ -109,7 +119,7 @@ void* imFormatECW::Handle(int index) return (void*)this->pNCSFileView; } -int imFormatECW::ReadImageInfo(int index) +int imFileFormatECW::ReadImageInfo(int index) { NCSFileViewFileInfoEx *pNCSFileInfo; imAttribTable* attrib_table = AttribTable(); @@ -245,7 +255,7 @@ static void iCopyDataBuffer(UINT8 **ppOutputLine, imbyte* line_buffer, int nBand memcpy(line_buffer, ppOutputLine[0], nBands*type_size*view_width); } -int imFormatECW::ReadImageData(void* data) +int imFileFormatECW::ReadImageData(void* data) { imAttribTable* attrib_table = AttribTable(); int i, *attrib_data, view_width, view_height, diff --git a/src/im_format_gif.cpp b/src/im_format_gif.cpp index ce371ba..390271a 100644 --- a/src/im_format_gif.cpp +++ b/src/im_format_gif.cpp @@ -2,7 +2,7 @@ * \brief GIF - Graphics Interchange Format * * See Copyright Notice in im_lib.h - * $Id: im_format_gif.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_gif.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -932,7 +932,7 @@ static const char* iGIFCompTable[1] = "LZW" }; -class imFormatGIF: public imFormat +class imFileFormatGIF: public imFileFormatBase { imBinFile* handle; iGIFData gif_data; @@ -941,6 +941,22 @@ class imFormatGIF: public imFormat int GIFWriteImageInfo(); public: + imFileFormatGIF(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatGIF() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatGIF: public imFormat +{ +public: imFormatGIF() :imFormat("GIF", "Graphics Interchange Format", @@ -951,14 +967,7 @@ public: {} ~imFormatGIF() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatGIF(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; @@ -967,7 +976,7 @@ void imFormatRegisterGIF(void) imFormatRegister(new imFormatGIF()); } -int imFormatGIF::Open(const char* file_name) +int imFileFormatGIF::Open(const char* file_name) { this->handle = imBinFileOpen(file_name); if (this->handle == NULL) @@ -1044,7 +1053,7 @@ int imFormatGIF::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatGIF::New(const char* file_name) +int imFileFormatGIF::New(const char* file_name) { this->handle = imBinFileNew(file_name); if (this->handle == NULL) @@ -1070,7 +1079,7 @@ int imFormatGIF::New(const char* file_name) return IM_ERR_NONE; } -void imFormatGIF::Close() +void imFileFormatGIF::Close() { if (this->is_new && !imBinFileError(this->handle)) imBinFileWrite(this->handle, (void*)";", 1, 1); @@ -1078,7 +1087,7 @@ void imFormatGIF::Close() imBinFileClose(this->handle); } -void* imFormatGIF::Handle(int index) +void* imFileFormatGIF::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -1086,7 +1095,7 @@ void* imFormatGIF::Handle(int index) return NULL; } -int imFormatGIF::GIFReadImageInfo() +int imFileFormatGIF::GIFReadImageInfo() { imbyte byte_value; imushort word_value; @@ -1165,7 +1174,7 @@ int imFormatGIF::GIFReadImageInfo() return IM_ERR_NONE; } -int imFormatGIF::GIFWriteImageInfo() +int imFileFormatGIF::GIFWriteImageInfo() { this->file_data_type = IM_BYTE; this->file_color_mode = imColorModeSpace(this->user_color_mode); @@ -1235,7 +1244,7 @@ int imFormatGIF::GIFWriteImageInfo() return IM_ERR_NONE; } -int imFormatGIF::ReadImageInfo(int index) +int imFileFormatGIF::ReadImageInfo(int index) { imAttribTable* attrib_table = AttribTable(); attrib_table->RemoveAll(); @@ -1316,7 +1325,7 @@ int imFormatGIF::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatGIF::WriteImageInfo() +int imFileFormatGIF::WriteImageInfo() { this->file_color_mode = imColorModeSpace(this->user_color_mode); this->file_color_mode |= IM_TOPDOWN; @@ -1396,7 +1405,7 @@ int imFormatGIF::WriteImageInfo() return iGIFCompressOutput(&gif_data, handle, gif_data.ClearCode); } -int imFormatGIF::ReadImageData(void* data) +int imFileFormatGIF::ReadImageData(void* data) { imCounterTotal(this->counter, this->height, "Reading GIF..."); @@ -1433,7 +1442,7 @@ int imFormatGIF::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatGIF::WriteImageData(void* data) +int imFileFormatGIF::WriteImageData(void* data) { imCounterTotal(this->counter, this->height, "Writing GIF..."); diff --git a/src/im_format_ico.cpp b/src/im_format_ico.cpp index d4d1884..b10f30e 100644 --- a/src/im_format_ico.cpp +++ b/src/im_format_ico.cpp @@ -2,7 +2,7 @@ * \brief ICO - Windows Icon * * See Copyright Notice in im_lib.h - * $Id: im_format_ico.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_ico.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -49,7 +49,7 @@ static const char* iICOCompTable[1] = "NONE" }; -class imFormatICO: public imFormat +class imFileFormatICO: public imFileFormatBase { imBinFile* handle; /* the binary file handle */ unsigned short bpp; /* number of bits per pixel */ @@ -62,6 +62,22 @@ class imFormatICO: public imFormat void FixRGBOrder(); public: + imFileFormatICO(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatICO() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatICO: public imFormat +{ +public: imFormatICO() :imFormat("ICO", "Windows Icon", @@ -72,23 +88,17 @@ public: {} ~imFormatICO() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatICO(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; + void imFormatRegisterICO(void) { imFormatRegister(new imFormatICO()); } -int imFormatICO::Open(const char* file_name) +int imFileFormatICO::Open(const char* file_name) { unsigned short word; @@ -145,7 +155,7 @@ int imFormatICO::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatICO::New(const char* file_name) +int imFileFormatICO::New(const char* file_name) { /* opens the binary file for writing with intel byte order */ handle = imBinFileNew(file_name); @@ -165,7 +175,7 @@ int imFormatICO::New(const char* file_name) return IM_ERR_NONE; } -void imFormatICO::Close() +void imFileFormatICO::Close() { if (this->is_new) { @@ -180,7 +190,7 @@ void imFormatICO::Close() imBinFileClose(handle); } -void* imFormatICO::Handle(int index) +void* imFileFormatICO::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -188,7 +198,7 @@ void* imFormatICO::Handle(int index) return NULL; } -int imFormatICO::ReadImageInfo(int index) +int imFileFormatICO::ReadImageInfo(int index) { this->file_data_type = IM_BYTE; unsigned int dword_value; @@ -270,7 +280,7 @@ int imFormatICO::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatICO::WriteImageInfo() +int imFileFormatICO::WriteImageInfo() { this->file_data_type = IM_BYTE; this->file_color_mode = imColorModeSpace(this->user_color_mode); @@ -368,7 +378,7 @@ int imFormatICO::WriteImageInfo() return IM_ERR_NONE; } -int imFormatICO::ReadPalette() +int imFileFormatICO::ReadPalette() { /* reads the color palette */ unsigned char bmp_colors[256 * 4]; @@ -389,7 +399,7 @@ int imFormatICO::ReadPalette() return IM_ERR_NONE; } -int imFormatICO::WritePalette() +int imFileFormatICO::WritePalette() { unsigned char bmp_colors[256 * 4]; @@ -410,7 +420,7 @@ int imFormatICO::WritePalette() return IM_ERR_NONE; } -void imFormatICO::FixRGBOrder() +void imFileFormatICO::FixRGBOrder() { if (this->bpp == 24) { @@ -455,7 +465,7 @@ static inline int PixelOffset(int is_top_down, int is_packed, int width, int hei return plane*width*height + row*width + col; } -int imFormatICO::ReadImageData(void* data) +int imFileFormatICO::ReadImageData(void* data) { imCounterTotal(this->counter, this->height, "Reading ICO..."); @@ -542,7 +552,7 @@ int imFormatICO::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatICO::WriteImageData(void* data) +int imFileFormatICO::WriteImageData(void* data) { imCounterTotal(this->counter, this->height, "Writing ICO..."); diff --git a/src/im_format_jp2.cpp b/src/im_format_jp2.cpp index 16e2c60..de25e88 100644 --- a/src/im_format_jp2.cpp +++ b/src/im_format_jp2.cpp @@ -3,7 +3,7 @@ * * See Copyright Notice in im_lib.h * See libJaper Copyright Notice in jasper.h - * $Id: im_format_jp2.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_jp2.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -103,6 +103,26 @@ static const char* iJP2CompTable[1] = "JPEG-2000", }; +class imFileFormatJP2: public imFileFormatBase +{ + int fmtid; + jas_stream_t *stream; + jas_image_t *image; + +public: + imFileFormatJP2(const imFormat* _iformat): imFileFormatBase(_iformat), image(0) {} + ~imFileFormatJP2() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + class imFormatJP2: public imFormat { int fmtid; @@ -118,18 +138,10 @@ public: 1, 0) { - image = 0; } ~imFormatJP2() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatJP2(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; @@ -166,7 +178,7 @@ void imFormatRegisterJP2(void) imFormatRegister(new imFormatJP2()); } -int imFormatJP2::Open(const char* file_name) +int imFileFormatJP2::Open(const char* file_name) { this->stream = jas_binfile_open(file_name, 0); if (this->stream == NULL) @@ -185,7 +197,7 @@ int imFormatJP2::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatJP2::New(const char* file_name) +int imFileFormatJP2::New(const char* file_name) { this->stream = jas_binfile_open(file_name, 1); if (this->stream == NULL) @@ -197,7 +209,7 @@ int imFormatJP2::New(const char* file_name) return IM_ERR_NONE; } -void imFormatJP2::Close() +void imFileFormatJP2::Close() { if (this->image) jas_image_destroy(this->image); @@ -205,7 +217,7 @@ void imFormatJP2::Close() jas_stream_close(this->stream); } -void* imFormatJP2::Handle(int index) +void* imFileFormatJP2::Handle(int index) { if (index == 0) return (void*)this->stream->obj_; @@ -217,7 +229,7 @@ void* imFormatJP2::Handle(int index) return NULL; } -int imFormatJP2::ReadImageInfo(int index) +int imFileFormatJP2::ReadImageInfo(int index) { (void)index; @@ -290,7 +302,7 @@ int imFormatJP2::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatJP2::WriteImageInfo() +int imFileFormatJP2::WriteImageInfo() { this->file_data_type = this->user_data_type; this->file_color_mode = imColorModeSpace(this->user_color_mode); @@ -377,7 +389,7 @@ int imFormatJP2::WriteImageInfo() return IM_ERR_NONE; } -int imFormatJP2::ReadImageData(void* data) +int imFileFormatJP2::ReadImageData(void* data) { int count = imFileLineBufferCount(this); @@ -419,7 +431,7 @@ int imFormatJP2::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatJP2::WriteImageData(void* data) +int imFileFormatJP2::WriteImageData(void* data) { int count = imFileLineBufferCount(this); imCounterTotal(this->counter, count, "Writing JP2..."); /* first time count */ diff --git a/src/im_format_jpeg.cpp b/src/im_format_jpeg.cpp index 91d0ae9..487db0b 100644 --- a/src/im_format_jpeg.cpp +++ b/src/im_format_jpeg.cpp @@ -3,7 +3,7 @@ * * See Copyright Notice in im_lib.h * See libJPEG Copyright Notice in jpeglib.h - * $Id: im_format_jpeg.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_jpeg.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -69,7 +69,7 @@ static const char* iJPEGCompTable[1] = "JPEG" }; -class imFormatJPEG: public imFormat +class imFileFormatJPEG: public imFileFormatBase { jpeg_decompress_struct dinfo; jpeg_compress_struct cinfo; @@ -84,6 +84,22 @@ class imFormatJPEG: public imFormat #endif public: + imFileFormatJPEG(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatJPEG() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatJPEG: public imFormat +{ +public: imFormatJPEG() :imFormat("JPEG", "JPEG File Interchange Format", @@ -94,14 +110,7 @@ public: {} ~imFormatJPEG() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatJPEG(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; @@ -110,7 +119,7 @@ void imFormatRegisterJPEG(void) imFormatRegister(new imFormatJPEG()); } -int imFormatJPEG::Open(const char* file_name) +int imFileFormatJPEG::Open(const char* file_name) { this->handle = imBinFileOpen(file_name); if (this->handle == NULL) @@ -158,7 +167,7 @@ int imFormatJPEG::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatJPEG::New(const char* file_name) +int imFileFormatJPEG::New(const char* file_name) { this->handle = imBinFileNew(file_name); if (this->handle == NULL) @@ -190,7 +199,7 @@ int imFormatJPEG::New(const char* file_name) return IM_ERR_NONE; } -void imFormatJPEG::Close() +void imFileFormatJPEG::Close() { if (this->is_new) jpeg_destroy_compress(&this->cinfo); @@ -200,7 +209,7 @@ void imFormatJPEG::Close() imBinFileClose(this->handle); } -void* imFormatJPEG::Handle(int index) +void* imFileFormatJPEG::Handle(int index) { if (index == 0) return this->handle; @@ -216,7 +225,7 @@ void* imFormatJPEG::Handle(int index) } #ifdef USE_EXIF -void imFormatJPEG::iReadExifAttrib(unsigned char* data, int data_length, imAttribTable* attrib_table) +void imFileFormatJPEG::iReadExifAttrib(unsigned char* data, int data_length, imAttribTable* attrib_table) { ExifData* exif = exif_data_new_from_data(data, data_length); if (!exif) @@ -377,7 +386,7 @@ static void iGetRational(float fvalue, int *num, int *den, int sign) *num = sign * imRound(fvalue); } -void imFormatJPEG::iWriteExifAttrib(imAttribTable* attrib_table) +void imFileFormatJPEG::iWriteExifAttrib(imAttribTable* attrib_table) { ExifData* exif = exif_data_new(); @@ -525,7 +534,7 @@ void imFormatJPEG::iWriteExifAttrib(imAttribTable* attrib_table) } #endif -int imFormatJPEG::ReadImageInfo(int index) +int imFileFormatJPEG::ReadImageInfo(int index) { (void)index; this->fix_adobe = 0; @@ -635,7 +644,7 @@ int imFormatJPEG::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatJPEG::WriteImageInfo() +int imFileFormatJPEG::WriteImageInfo() { this->file_color_mode = imColorModeSpace(this->user_color_mode); this->file_color_mode |= IM_TOPDOWN; @@ -737,7 +746,7 @@ static void iFixAdobe(unsigned char* line_buffer, int width) } } -int imFormatJPEG::ReadImageData(void* data) +int imFileFormatJPEG::ReadImageData(void* data) { if (setjmp(this->jerr.setjmp_buffer)) return IM_ERR_ACCESS; @@ -769,7 +778,7 @@ int imFormatJPEG::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatJPEG::WriteImageData(void* data) +int imFileFormatJPEG::WriteImageData(void* data) { if (setjmp(this->jerr.setjmp_buffer)) return IM_ERR_ACCESS; diff --git a/src/im_format_krn.cpp b/src/im_format_krn.cpp index 41c9be7..21261a8 100644 --- a/src/im_format_krn.cpp +++ b/src/im_format_krn.cpp @@ -2,7 +2,7 @@ * \brief KRN - IM Kernel File Format * * See Copyright Notice in im_lib.h - * $Id: im_format_krn.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_krn.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -124,11 +124,27 @@ static const char* iKRNCompTable[1] = "NONE" }; -class imFormatKRN: public imFormat +class imFileFormatKRN: public imFileFormatBase { imBinFile* handle; /* the binary file handle */ public: + imFileFormatKRN(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatKRN() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatKRN: public imFormat +{ +public: imFormatKRN() :imFormat("KRN", "IM Kernel File Format", @@ -139,14 +155,7 @@ public: {} ~imFormatKRN() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatKRN(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; @@ -155,7 +164,7 @@ void imFormatRegisterKRN(void) imFormatRegister(new imFormatKRN()); } -int imFormatKRN::Open(const char* file_name) +int imFileFormatKRN::Open(const char* file_name) { char sig[9]; @@ -186,7 +195,7 @@ int imFormatKRN::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatKRN::New(const char* file_name) +int imFileFormatKRN::New(const char* file_name) { /* opens the binary file for writing */ handle = imBinFileNew(file_name); @@ -203,12 +212,12 @@ int imFormatKRN::New(const char* file_name) return IM_ERR_NONE; } -void imFormatKRN::Close() +void imFileFormatKRN::Close() { imBinFileClose(handle); } -void* imFormatKRN::Handle(int index) +void* imFileFormatKRN::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -216,7 +225,7 @@ void* imFormatKRN::Handle(int index) return NULL; } -int imFormatKRN::ReadImageInfo(int index) +int imFileFormatKRN::ReadImageInfo(int index) { (void)index; this->file_color_mode = IM_GRAY|IM_TOPDOWN; @@ -248,7 +257,7 @@ int imFormatKRN::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatKRN::WriteImageInfo() +int imFileFormatKRN::WriteImageInfo() { this->file_data_type = this->user_data_type; this->file_color_mode = IM_GRAY|IM_TOPDOWN; @@ -283,7 +292,7 @@ int imFormatKRN::WriteImageInfo() return IM_ERR_NONE; } -int imFormatKRN::ReadImageData(void* data) +int imFileFormatKRN::ReadImageData(void* data) { imCounterTotal(this->counter, this->height, "Reading KRN..."); @@ -318,7 +327,7 @@ int imFormatKRN::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatKRN::WriteImageData(void* data) +int imFileFormatKRN::WriteImageData(void* data) { imCounterTotal(this->counter, this->height, "Writing KRN..."); diff --git a/src/im_format_led.cpp b/src/im_format_led.cpp index d67ee8c..eb7173c 100644 --- a/src/im_format_led.cpp +++ b/src/im_format_led.cpp @@ -2,7 +2,7 @@ * \brief LED - IUP image in LED * * See Copyright Notice in im_lib.h - * $Id: im_format_led.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_led.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -81,7 +81,7 @@ static const char* iLEDCompTable[1] = "NONE" }; -class imFormatLED: public imFormat +class imFileFormatLED: public imFileFormatBase { imBinFile* handle; /* the binary file handle */ int pal_count; @@ -90,6 +90,22 @@ class imFormatLED: public imFormat int WritePalette(); public: + imFileFormatLED(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatLED() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatLED: public imFormat +{ +public: imFormatLED() :imFormat("LED", "IUP image in LED special format", @@ -100,23 +116,17 @@ public: {} ~imFormatLED() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatLED(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; + void imFormatRegisterLED(void) { imFormatRegister(new imFormatLED()); } -int imFormatLED::Open(const char* file_name) +int imFileFormatLED::Open(const char* file_name) { char sig[4]; unsigned char byte_value; @@ -171,7 +181,7 @@ int imFormatLED::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatLED::New(const char* file_name) +int imFileFormatLED::New(const char* file_name) { /* opens the binary file for writing */ handle = imBinFileNew(file_name); @@ -190,12 +200,12 @@ int imFormatLED::New(const char* file_name) return IM_ERR_NONE; } -void imFormatLED::Close() +void imFileFormatLED::Close() { imBinFileClose(handle); } -void* imFormatLED::Handle(int index) +void* imFileFormatLED::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -203,7 +213,7 @@ void* imFormatLED::Handle(int index) return NULL; } -int imFormatLED::ReadImageInfo(int index) +int imFileFormatLED::ReadImageInfo(int index) { (void)index; @@ -225,7 +235,7 @@ int imFormatLED::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatLED::WriteImageInfo() +int imFileFormatLED::WriteImageInfo() { this->file_data_type = IM_BYTE; this->file_color_mode = imColorModeSpace(this->user_color_mode); @@ -239,7 +249,7 @@ int imFormatLED::WriteImageInfo() return IM_ERR_NONE; } -int imFormatLED::ReadPalette() +int imFileFormatLED::ReadPalette() { int c, r, g, b, i; @@ -260,7 +270,7 @@ int imFormatLED::ReadPalette() return IM_ERR_NONE; } -int imFormatLED::WritePalette() +int imFileFormatLED::WritePalette() { int c; unsigned char r, g, b; @@ -285,7 +295,7 @@ int imFormatLED::WritePalette() return IM_ERR_NONE; } -int imFormatLED::ReadImageData(void* data) +int imFileFormatLED::ReadImageData(void* data) { int value; @@ -310,7 +320,7 @@ int imFormatLED::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatLED::WriteImageData(void* data) +int imFileFormatLED::WriteImageData(void* data) { imCounterTotal(this->counter, this->height, "Writing LED..."); diff --git a/src/im_format_pcx.cpp b/src/im_format_pcx.cpp index 32487bc..fd206ae 100644 --- a/src/im_format_pcx.cpp +++ b/src/im_format_pcx.cpp @@ -2,7 +2,7 @@ * \brief PCX - ZSoft Picture * * See Copyright Notice in im_lib.h - * $Id: im_format_pcx.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_pcx.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -145,7 +145,7 @@ static const char* iPCXCompTable[2] = "RLE" }; -class imFormatPCX: public imFormat +class imFileFormatPCX: public imFileFormatBase { imBinFile* handle; /* the binary file handle */ int bpp; /* number of bits per pixel */ @@ -160,6 +160,22 @@ class imFormatPCX: public imFormat void Unpack24bpp(); public: + imFileFormatPCX(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatPCX() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatPCX: public imFormat +{ +public: imFormatPCX() :imFormat("PCX", "ZSoft Picture", @@ -170,23 +186,17 @@ public: {} ~imFormatPCX() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatPCX(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; + void imFormatRegisterPCX(void) { imFormatRegister(new imFormatPCX()); } -int imFormatPCX::Open(const char* file_name) +int imFileFormatPCX::Open(const char* file_name) { unsigned char id; @@ -226,7 +236,7 @@ int imFormatPCX::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatPCX::New(const char* file_name) +int imFileFormatPCX::New(const char* file_name) { /* opens the binary file for writing with intel byte order */ handle = imBinFileNew(file_name); @@ -238,12 +248,12 @@ int imFormatPCX::New(const char* file_name) return IM_ERR_NONE; } -void imFormatPCX::Close() +void imFileFormatPCX::Close() { imBinFileClose(handle); } -void* imFormatPCX::Handle(int index) +void* imFileFormatPCX::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -251,7 +261,7 @@ void* imFormatPCX::Handle(int index) return NULL; } -int imFormatPCX::ReadImageInfo(int index) +int imFileFormatPCX::ReadImageInfo(int index) { unsigned char bppp, planes; unsigned short xmin, xmax, ymax, ymin, word, bplp; @@ -339,7 +349,7 @@ int imFormatPCX::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatPCX::WriteImageInfo() +int imFileFormatPCX::WriteImageInfo() { unsigned short word_value, bplp; unsigned char byte_value, filler[54+3*2]; @@ -447,7 +457,7 @@ int imFormatPCX::WriteImageInfo() return IM_ERR_NONE; } -int imFormatPCX::ReadPalette() +int imFileFormatPCX::ReadPalette() { unsigned char pcx_colors[256 * 3]; @@ -498,7 +508,7 @@ int imFormatPCX::ReadPalette() return IM_ERR_NONE; } -int imFormatPCX::WritePalette() +int imFileFormatPCX::WritePalette() { unsigned char ExtPal = (unsigned char)12; unsigned char pcx_colors[256 * 3]; @@ -522,7 +532,7 @@ int imFormatPCX::WritePalette() return IM_ERR_NONE; } -void imFormatPCX::Expand4bpp() +void imFileFormatPCX::Expand4bpp() { int num_bits = 8, WidthDiv8 = (this->width + 7) / 8; @@ -559,7 +569,7 @@ void imFormatPCX::Expand4bpp() memcpy(this->line_buffer, in_data + this->line_buffer_size+2, this->width); } -void imFormatPCX::Pack24bpp() +void imFileFormatPCX::Pack24bpp() { imbyte *in_data = (unsigned char*)this->line_buffer; imbyte *out_data = in_data + this->line_buffer_size+2; @@ -580,7 +590,7 @@ void imFormatPCX::Pack24bpp() memcpy(in_data, in_data + this->line_buffer_size+2, this->line_raw_size); } -void imFormatPCX::Unpack24bpp() +void imFileFormatPCX::Unpack24bpp() { imbyte *in_data = (unsigned char*)this->line_buffer; imbyte *out_data = in_data + this->line_buffer_size+2; @@ -601,7 +611,7 @@ void imFormatPCX::Unpack24bpp() memcpy(out_data - (this->line_buffer_size+2), out_data, this->line_raw_size); } -int imFormatPCX::ReadImageData(void* data) +int imFileFormatPCX::ReadImageData(void* data) { imCounterTotal(this->counter, this->height, "Reading PCX..."); @@ -637,7 +647,7 @@ int imFormatPCX::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatPCX::WriteImageData(void* data) +int imFileFormatPCX::WriteImageData(void* data) { imCounterTotal(this->counter, this->height, "Writing PCX..."); diff --git a/src/im_format_png.cpp b/src/im_format_png.cpp index 1e7f8ba..314f07f 100644 --- a/src/im_format_png.cpp +++ b/src/im_format_png.cpp @@ -3,7 +3,7 @@ * * See Copyright Notice in im_lib.h * See libPNG Copyright Notice in png.h - * $Id: im_format_png.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_png.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -42,7 +42,7 @@ static const char* iPNGCompTable[1] = "DEFLATE" }; -class imFormatPNG: public imFormat +class imFileFormatPNG: public imFileFormatBase { png_structp png_ptr; png_infop info_ptr; @@ -54,6 +54,22 @@ class imFormatPNG: public imFormat void iWriteAttrib(imAttribTable* attrib_table); public: + imFileFormatPNG(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatPNG() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatPNG: public imFormat +{ +public: imFormatPNG() :imFormat("PNG", "Portable Network Graphic Format", @@ -64,14 +80,7 @@ public: {} ~imFormatPNG() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatPNG(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; @@ -80,7 +89,7 @@ void imFormatRegisterPNG(void) imFormatRegister(new imFormatPNG()); } -int imFormatPNG::Open(const char* file_name) +int imFileFormatPNG::Open(const char* file_name) { this->handle = imBinFileOpen(file_name); if (this->handle == NULL) @@ -115,7 +124,7 @@ int imFormatPNG::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatPNG::New(const char* file_name) +int imFileFormatPNG::New(const char* file_name) { this->handle = imBinFileNew(file_name); if (this->handle == NULL) @@ -134,7 +143,7 @@ int imFormatPNG::New(const char* file_name) return IM_ERR_NONE; } -void imFormatPNG::Close() +void imFileFormatPNG::Close() { if (this->is_new) png_destroy_write_struct(&this->png_ptr, &this->info_ptr); @@ -144,7 +153,7 @@ void imFormatPNG::Close() imBinFileClose(this->handle); } -void* imFormatPNG::Handle(int index) +void* imFileFormatPNG::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -154,7 +163,7 @@ void* imFormatPNG::Handle(int index) return 0; } -void imFormatPNG::iReadAttrib(imAttribTable* attrib_table) +void imFileFormatPNG::iReadAttrib(imAttribTable* attrib_table) { double gamma; if (png_get_gAMA(png_ptr, info_ptr, &gamma)) @@ -377,7 +386,7 @@ static int iFindAttribString(void* user_data, int index, const char* name, int d return 1; } -void imFormatPNG::iWriteAttrib(imAttribTable* attrib_table) +void imFileFormatPNG::iWriteAttrib(imAttribTable* attrib_table) { const void* attrib_data = attrib_table->Get("Gamma"); if (attrib_data) @@ -563,7 +572,7 @@ void imFormatPNG::iWriteAttrib(imAttribTable* attrib_table) } } -int imFormatPNG::ReadImageInfo(int index) +int imFileFormatPNG::ReadImageInfo(int index) { (void)index; @@ -678,7 +687,7 @@ int imFormatPNG::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatPNG::WriteImageInfo() +int imFileFormatPNG::WriteImageInfo() { this->file_color_mode = imColorModeSpace(this->user_color_mode); this->file_color_mode |= IM_TOPDOWN; @@ -805,7 +814,7 @@ static int iInterlaceRowCheck(int row_step, int pass) return 0; } -int imFormatPNG::ReadImageData(void* data) +int imFileFormatPNG::ReadImageData(void* data) { if (setjmp(this->png_ptr->jmpbuf)) return IM_ERR_ACCESS; @@ -856,7 +865,7 @@ int imFormatPNG::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatPNG::WriteImageData(void* data) +int imFileFormatPNG::WriteImageData(void* data) { if (setjmp(this->png_ptr->jmpbuf)) return IM_ERR_ACCESS; diff --git a/src/im_format_pnm.cpp b/src/im_format_pnm.cpp index 1c7832a..bd034ad 100644 --- a/src/im_format_pnm.cpp +++ b/src/im_format_pnm.cpp @@ -2,7 +2,7 @@ * \brief PNM - Netpbm Portable Image Map * * See Copyright Notice in im_lib.h - * $Id: im_format_pnm.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_pnm.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -98,7 +98,7 @@ static const char* iPNMCompTable[2] = "ASCII" }; -class imFormatPNM: public imFormat +class imFileFormatPNM: public imFileFormatBase { imBinFile* handle; /* the binary file handle */ unsigned char image_type; @@ -106,6 +106,22 @@ class imFormatPNM: public imFormat void FixBinary(); public: + imFileFormatPNM(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatPNM() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatPNM: public imFormat +{ +public: imFormatPNM() :imFormat("PNM", "Netpbm Portable Image Map", @@ -116,23 +132,17 @@ public: {} ~imFormatPNM() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatPNM(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; + void imFormatRegisterPNM(void) { imFormatRegister(new imFormatPNM()); } -int imFormatPNM::Open(const char* file_name) +int imFileFormatPNM::Open(const char* file_name) { unsigned char sig[2]; @@ -168,7 +178,7 @@ int imFormatPNM::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatPNM::New(const char* file_name) +int imFileFormatPNM::New(const char* file_name) { /* opens the binary file for writing */ handle = imBinFileNew(file_name); @@ -180,12 +190,12 @@ int imFormatPNM::New(const char* file_name) return IM_ERR_NONE; } -void imFormatPNM::Close() +void imFileFormatPNM::Close() { imBinFileClose(handle); } -void* imFormatPNM::Handle(int index) +void* imFileFormatPNM::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -193,7 +203,7 @@ void* imFormatPNM::Handle(int index) return NULL; } -int imFormatPNM::ReadImageInfo(int index) +int imFileFormatPNM::ReadImageInfo(int index) { (void)index; @@ -249,7 +259,7 @@ int imFormatPNM::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatPNM::WriteImageInfo() +int imFileFormatPNM::WriteImageInfo() { this->file_data_type = this->user_data_type; this->file_color_mode = imColorModeSpace(this->user_color_mode); @@ -328,7 +338,7 @@ int imFormatPNM::WriteImageInfo() return IM_ERR_NONE; } -void imFormatPNM::FixBinary() +void imFileFormatPNM::FixBinary() { unsigned char* buf = (unsigned char*)this->line_buffer; for (int b = 0; b < this->line_buffer_size; b++) @@ -338,7 +348,7 @@ void imFormatPNM::FixBinary() } } -int imFormatPNM::ReadImageData(void* data) +int imFileFormatPNM::ReadImageData(void* data) { imCounterTotal(this->counter, this->height, "Reading PNM..."); @@ -414,7 +424,7 @@ int imFormatPNM::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatPNM::WriteImageData(void* data) +int imFileFormatPNM::WriteImageData(void* data) { imCounterTotal(this->counter, this->height, "Writing PNM..."); diff --git a/src/im_format_ras.cpp b/src/im_format_ras.cpp index bab074a..1960c49 100644 --- a/src/im_format_ras.cpp +++ b/src/im_format_ras.cpp @@ -2,7 +2,7 @@ * \brief RAS - Sun Raster File * * See Copyright Notice in im_lib.h - * $Id: im_format_ras.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_ras.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -153,7 +153,7 @@ static const char* iRASCompTable[2] = "RLE" }; -class imFormatRAS: public imFormat +class imFileFormatRAS: public imFileFormatBase { imBinFile* handle; /* the binary file handle */ unsigned int bpp, /* number of bits per pixel */ @@ -166,6 +166,22 @@ class imFormatRAS: public imFormat void FixRGB(); public: + imFileFormatRAS(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatRAS() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatRAS: public imFormat +{ +public: imFormatRAS() :imFormat("RAS", "Sun Raster File", @@ -176,23 +192,17 @@ public: {} ~imFormatRAS() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatRAS(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; + void imFormatRegisterRAS(void) { imFormatRegister(new imFormatRAS()); } -int imFormatRAS::Open(const char* file_name) +int imFileFormatRAS::Open(const char* file_name) { unsigned int dword_value; @@ -238,7 +248,7 @@ int imFormatRAS::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatRAS::New(const char* file_name) +int imFileFormatRAS::New(const char* file_name) { /* opens the binary file for writing with motorola byte order */ handle = imBinFileNew(file_name); @@ -252,12 +262,12 @@ int imFormatRAS::New(const char* file_name) return IM_ERR_NONE; } -void imFormatRAS::Close() +void imFileFormatRAS::Close() { imBinFileClose(handle); } -void* imFormatRAS::Handle(int index) +void* imFileFormatRAS::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -265,7 +275,7 @@ void* imFormatRAS::Handle(int index) return NULL; } -int imFormatRAS::ReadImageInfo(int index) +int imFileFormatRAS::ReadImageInfo(int index) { (void)index; unsigned int dword_value; @@ -347,7 +357,7 @@ int imFormatRAS::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatRAS::WriteImageInfo() +int imFileFormatRAS::WriteImageInfo() { this->file_data_type = IM_BYTE; this->file_color_mode = imColorModeSpace(this->user_color_mode); @@ -420,7 +430,7 @@ int imFormatRAS::WriteImageInfo() return IM_ERR_NONE; } -int imFormatRAS::ReadPalette() +int imFileFormatRAS::ReadPalette() { unsigned char ras_colors[256 * 3]; @@ -451,7 +461,7 @@ int imFormatRAS::ReadPalette() return IM_ERR_NONE; } -int imFormatRAS::WritePalette() +int imFileFormatRAS::WritePalette() { int c; unsigned char ras_colors[256 * 3]; @@ -471,7 +481,7 @@ int imFormatRAS::WritePalette() return IM_ERR_NONE; } -void imFormatRAS::FixRGB() +void imFileFormatRAS::FixRGB() { int x; imbyte* byte_data = (imbyte*)this->line_buffer; @@ -509,7 +519,7 @@ void imFormatRAS::FixRGB() } } -int imFormatRAS::ReadImageData(void* data) +int imFileFormatRAS::ReadImageData(void* data) { imCounterTotal(this->counter, this->height, "Reading RAS..."); @@ -541,7 +551,7 @@ int imFormatRAS::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatRAS::WriteImageData(void* data) +int imFileFormatRAS::WriteImageData(void* data) { imCounterTotal(this->counter, this->height, "Writing RAS..."); diff --git a/src/im_format_raw.cpp b/src/im_format_raw.cpp index 83ffadb..a7b7934 100644 --- a/src/im_format_raw.cpp +++ b/src/im_format_raw.cpp @@ -2,7 +2,7 @@ * \brief RAW File Format * * See Copyright Notice in im_lib.h - * $Id: im_format_raw.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_raw.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -20,7 +20,7 @@ static const char* iRAWCompTable[1] = "NONE" }; -class imFormatRAW: public imFormat +class imFileFormatRAW: public imFileFormatBase { imBinFile* handle; int padding; @@ -28,6 +28,22 @@ class imFormatRAW: public imFormat int iRawUpdateParam(int index); public: + imFileFormatRAW(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatRAW() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatRAW: public imFormat +{ +public: imFormatRAW() :imFormat("RAW", "RAW File Format", @@ -38,23 +54,18 @@ public: {} ~imFormatRAW() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatRAW(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; -imFormat* imFormatInitRAW(void) + +imFileFormatBase* imFormatInitRAW(void) { - return new imFormatRAW(); + imFormatRAW iformat; + return iformat.Create(); } -int imFormatRAW::Open(const char* file_name) +int imFileFormatRAW::Open(const char* file_name) { this->handle = imBinFileOpen(file_name); if (this->handle == NULL) @@ -68,7 +79,7 @@ int imFormatRAW::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatRAW::New(const char* file_name) +int imFileFormatRAW::New(const char* file_name) { this->handle = imBinFileNew(file_name); if (this->handle == NULL) @@ -79,12 +90,12 @@ int imFormatRAW::New(const char* file_name) return IM_ERR_NONE; } -void imFormatRAW::Close() +void imFileFormatRAW::Close() { imBinFileClose(this->handle); } -void* imFormatRAW::Handle(int index) +void* imFileFormatRAW::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -106,7 +117,7 @@ static int iCalcPad(int padding, int line_size) } } -int imFormatRAW::iRawUpdateParam(int index) +int imFileFormatRAW::iRawUpdateParam(int index) { (void)index; @@ -156,12 +167,12 @@ int imFormatRAW::iRawUpdateParam(int index) return IM_ERR_NONE; } -int imFormatRAW::ReadImageInfo(int index) +int imFileFormatRAW::ReadImageInfo(int index) { return iRawUpdateParam(index); } -int imFormatRAW::WriteImageInfo() +int imFileFormatRAW::WriteImageInfo() { this->file_color_mode = this->user_color_mode; this->file_data_type = this->user_data_type; @@ -177,7 +188,7 @@ static int iFileDataTypeSize(int file_data_type, int switch_type) return type_size; } -int imFormatRAW::ReadImageData(void* data) +int imFileFormatRAW::ReadImageData(void* data) { int count = imFileLineBufferCount(this); int line_count = imImageLineCount(this->width, this->file_color_mode); @@ -214,7 +225,7 @@ int imFormatRAW::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatRAW::WriteImageData(void* data) +int imFileFormatRAW::WriteImageData(void* data) { int count = imFileLineBufferCount(this); int line_count = imImageLineCount(this->width, this->file_color_mode); @@ -267,4 +278,3 @@ int imFormatRAW::CanWrite(const char* compression, int color_mode, int data_type return IM_ERR_NONE; } - diff --git a/src/im_format_sgi.cpp b/src/im_format_sgi.cpp index 1b0ac0a..08bbf4d 100644 --- a/src/im_format_sgi.cpp +++ b/src/im_format_sgi.cpp @@ -2,7 +2,7 @@ * \brief SGI - Silicon Graphics Image File Format * * See Copyright Notice in im_lib.h - * $Id: im_format_sgi.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_sgi.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -133,15 +133,31 @@ static const char* iSGICompTable[2] = "RLE" }; -class imFormatSGI: public imFormat +class imFileFormatSGI: public imFileFormatBase { imBinFile* handle; /* the binary file handle */ unsigned char comp_type, /* sgi compression information */ bpc; /* bytes per channels */ - unsigned int *starttab, /* compression control buffer */ - *lengthtab; /* compression control buffer */ + unsigned int *starttab, /* compression control buffer */ + *lengthtab; /* compression control buffer */ public: + imFileFormatSGI(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatSGI() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatSGI: public imFormat +{ +public: imFormatSGI() :imFormat("SGI", "Silicon Graphics Image File Format", @@ -152,14 +168,7 @@ public: {} ~imFormatSGI() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatSGI(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; @@ -168,7 +177,7 @@ void imFormatRegisterSGI(void) imFormatRegister(new imFormatSGI()); } -int imFormatSGI::Open(const char* file_name) +int imFileFormatSGI::Open(const char* file_name) { unsigned short word_value; @@ -213,7 +222,7 @@ int imFormatSGI::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatSGI::New(const char* file_name) +int imFileFormatSGI::New(const char* file_name) { /* opens the binary file for writing with motorola byte order */ handle = imBinFileNew(file_name); @@ -230,14 +239,14 @@ int imFormatSGI::New(const char* file_name) return IM_ERR_NONE; } -void imFormatSGI::Close() +void imFileFormatSGI::Close() { if (this->starttab) free(this->starttab); if (this->lengthtab) free(this->lengthtab); imBinFileClose(handle); } -void* imFormatSGI::Handle(int index) +void* imFileFormatSGI::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -245,7 +254,7 @@ void* imFormatSGI::Handle(int index) return NULL; } -int imFormatSGI::ReadImageInfo(int index) +int imFileFormatSGI::ReadImageInfo(int index) { (void)index; unsigned short word_value, dimension, depth; @@ -378,7 +387,7 @@ int imFormatSGI::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatSGI::WriteImageInfo() +int imFileFormatSGI::WriteImageInfo() { unsigned int dword_value; unsigned short word_value; @@ -487,7 +496,7 @@ int imFormatSGI::WriteImageInfo() return IM_ERR_NONE; } -int imFormatSGI::ReadImageData(void* data) +int imFileFormatSGI::ReadImageData(void* data) { int count = imFileLineBufferCount(this); @@ -533,7 +542,7 @@ int imFormatSGI::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatSGI::WriteImageData(void* data) +int imFileFormatSGI::WriteImageData(void* data) { int count = imFileLineBufferCount(this); diff --git a/src/im_format_tga.cpp b/src/im_format_tga.cpp index 8e8e176..86e968a 100644 --- a/src/im_format_tga.cpp +++ b/src/im_format_tga.cpp @@ -2,7 +2,7 @@ * \brief TGA - Truevision Graphics Adapter File * * See Copyright Notice in im_lib.h - * $Id: im_format_tga.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_tga.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -207,7 +207,7 @@ static const char* iTGACompTable[2] = "RLE" }; -class imFormatTGA: public imFormat +class imFileFormatTGA: public imFileFormatBase { imBinFile* handle; /* the binary file handle */ unsigned char id_lenght; @@ -220,6 +220,22 @@ class imFormatTGA: public imFormat int SaveExtensionArea(); public: + imFileFormatTGA(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatTGA() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatTGA: public imFormat +{ +public: imFormatTGA() :imFormat("TGA", "Truevision Graphics Adapter File", @@ -230,14 +246,7 @@ public: {} ~imFormatTGA() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatTGA(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; @@ -246,7 +255,7 @@ void imFormatRegisterTGA(void) imFormatRegister(new imFormatTGA()); } -int imFormatTGA::Open(const char* file_name) +int imFileFormatTGA::Open(const char* file_name) { /* opens the binary file for reading with intel byte order */ handle = imBinFileOpen(file_name); @@ -294,7 +303,7 @@ int imFormatTGA::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatTGA::New(const char* file_name) +int imFileFormatTGA::New(const char* file_name) { /* opens the binary file for writing with intel byte order */ handle = imBinFileNew(file_name); @@ -306,12 +315,12 @@ int imFormatTGA::New(const char* file_name) return IM_ERR_NONE; } -void imFormatTGA::Close() +void imFileFormatTGA::Close() { imBinFileClose(handle); } -void* imFormatTGA::Handle(int index) +void* imFileFormatTGA::Handle(int index) { if (index == 0) return (void*)this->handle; @@ -319,7 +328,7 @@ void* imFormatTGA::Handle(int index) return NULL; } -int imFormatTGA::ReadImageInfo(int index) +int imFileFormatTGA::ReadImageInfo(int index) { (void)index; unsigned char byte_value; @@ -436,7 +445,7 @@ int imFormatTGA::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatTGA::WriteImageInfo() +int imFileFormatTGA::WriteImageInfo() { unsigned char byte_value; unsigned short word_value; @@ -487,7 +496,7 @@ int imFormatTGA::WriteImageInfo() int length = 0; const char* desc_attrib = (const char*)attrib_table->Get("Title", NULL, &length); - if (desc) + if (desc_attrib) { if (length > 255) this->id_lenght = 255; @@ -600,7 +609,7 @@ static long iTGARGB2Color(int c, unsigned char *colors, int map_bpp) return imColorEncode(r, g, b); } -int imFormatTGA::ReadPalette() +int imFileFormatTGA::ReadPalette() { int map_size = imFileLineSizeAligned(this->palette_count, this->map_bpp, 1); unsigned char* tga_colors = (unsigned char*) malloc(map_size); @@ -622,7 +631,7 @@ int imFormatTGA::ReadPalette() return 1; } -int imFormatTGA::WritePalette() +int imFileFormatTGA::WritePalette() { unsigned char tga_color[256*3]; @@ -642,7 +651,7 @@ int imFormatTGA::WritePalette() return 1; } -int imFormatTGA::LoadExtensionArea() +int imFileFormatTGA::LoadExtensionArea() { unsigned int dword_value; imBinFileSeekFrom(handle, -26); @@ -807,7 +816,7 @@ static void iGetRational(float fvalue, int *num, int *den) *num = imRound(fvalue); } -int imFormatTGA::SaveExtensionArea() +int imFileFormatTGA::SaveExtensionArea() { unsigned int dword_value; unsigned short word_value; @@ -971,7 +980,7 @@ int imFormatTGA::SaveExtensionArea() return 1; } -void imFormatTGA::FixRGB() +void imFileFormatTGA::FixRGB() { int x; imbyte* byte_data = (imbyte*)this->line_buffer; @@ -1010,7 +1019,7 @@ void imFormatTGA::FixRGB() } } -int imFormatTGA::ReadImageData(void* data) +int imFileFormatTGA::ReadImageData(void* data) { imCounterTotal(this->counter, this->height, "Reading TGA..."); @@ -1044,7 +1053,7 @@ int imFormatTGA::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatTGA::WriteImageData(void* data) +int imFileFormatTGA::WriteImageData(void* data) { imCounterTotal(this->counter, this->height, "Writing TGA..."); diff --git a/src/im_format_tiff.cpp b/src/im_format_tiff.cpp index 98467f9..1c55a55 100644 --- a/src/im_format_tiff.cpp +++ b/src/im_format_tiff.cpp @@ -3,7 +3,7 @@ * * See Copyright Notice in im_lib.h * See libTIFF Copyright Notice in tiff.h - * $Id: im_format_tiff.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_tiff.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -590,7 +590,7 @@ static void iTIFFWriteAttributes(TIFF* tiff, imAttribTable* attrib_table) iTIFFWriteCustomTags(tiff, attrib_table); } -class imFormatTIFF: public imFormat +class imFileFormatTIFF: public imFileFormatBase { TIFF* tiff; int invert, // must invert black and white reference @@ -606,6 +606,22 @@ class imFormatTIFF: public imFormat int ReadTileline(void* line_buffer, int row, int plane); public: + imFileFormatTIFF(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatTIFF() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatTIFF: public imFormat +{ +public: imFormatTIFF() :imFormat("TIFF", "Tagged Image File Format", @@ -616,14 +632,7 @@ public: {} ~imFormatTIFF() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatTIFF(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; @@ -639,7 +648,7 @@ void imFormatRegisterTIFF(void) imFormatRegister(new imFormatTIFF()); } -int imFormatTIFF::Open(const char* file_name) +int imFileFormatTIFF::Open(const char* file_name) { this->tiff = TIFFOpen(file_name, "r"); if (this->tiff == NULL) @@ -659,7 +668,7 @@ int imFormatTIFF::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatTIFF::New(const char* file_name) +int imFileFormatTIFF::New(const char* file_name) { this->tiff = TIFFOpen(file_name, "w"); if (this->tiff == NULL) @@ -670,7 +679,7 @@ int imFormatTIFF::New(const char* file_name) return IM_ERR_NONE; } -void imFormatTIFF::Close() +void imFileFormatTIFF::Close() { if (this->tile_buf) { @@ -682,7 +691,7 @@ void imFormatTIFF::Close() TIFFClose(this->tiff); } -void* imFormatTIFF::Handle(int index) +void* imFileFormatTIFF::Handle(int index) { if (index == 0) return (void*)this->tiff->tif_fd; @@ -692,7 +701,7 @@ void* imFormatTIFF::Handle(int index) return NULL; } -int imFormatTIFF::ReadImageInfo(int index) +int imFileFormatTIFF::ReadImageInfo(int index) { this->cpx_int = 0; this->invert = 0; @@ -1011,7 +1020,7 @@ int imFormatTIFF::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatTIFF::WriteImageInfo() +int imFileFormatTIFF::WriteImageInfo() { this->file_color_mode = this->user_color_mode; this->file_data_type = this->user_data_type; @@ -1254,7 +1263,7 @@ static void iTIFFLabFix(void* line_buffer, int width, int data_type, int is_new) // Do NOT know how it is encoded for other data types. } -int imFormatTIFF::ReadTileline(void* line_buffer, int row, int plane) +int imFileFormatTIFF::ReadTileline(void* line_buffer, int row, int plane) { int t; @@ -1295,7 +1304,7 @@ int imFormatTIFF::ReadTileline(void* line_buffer, int row, int plane) return 1; } -int imFormatTIFF::ReadImageData(void* data) +int imFileFormatTIFF::ReadImageData(void* data) { int count = imFileLineBufferCount(this); @@ -1348,7 +1357,7 @@ int imFormatTIFF::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatTIFF::WriteImageData(void* data) +int imFileFormatTIFF::WriteImageData(void* data) { int count = imFileLineBufferCount(this); diff --git a/src/im_format_wmv.cpp b/src/im_format_wmv.cpp index 3b411c3..a4733a5 100644 --- a/src/im_format_wmv.cpp +++ b/src/im_format_wmv.cpp @@ -2,7 +2,7 @@ * \brief WMV - Windows Media Video Format * * See Copyright Notice in im_lib.h - * $Id: im_format_wmv.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_format_wmv.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ */ #include "im_format.h" @@ -494,7 +494,7 @@ static GUID iWMFCompFindSubType(const char* compression) return WMMEDIASUBTYPE_Base; } -class imFormatWMV: public imFormat +class imFileFormatWMV: public imFileFormatBase { IWMSyncReader* Reader; // When reading WM_MEDIA_TYPE* MediaType; @@ -526,6 +526,22 @@ class imFormatWMV: public imFormat int SetProfile(); public: + imFileFormatWMV(const imFormat* _iformat): imFileFormatBase(_iformat) {} + ~imFileFormatWMV() {} + + int Open(const char* file_name); + int New(const char* file_name); + void Close(); + void* Handle(int index); + int ReadImageInfo(int index); + int ReadImageData(void* data); + int WriteImageInfo(); + int WriteImageData(void* data); +}; + +class imFormatWMV: public imFormat +{ +public: imFormatWMV() :imFormat("WMV", "Windows Media Video Format", @@ -536,14 +552,7 @@ public: {} ~imFormatWMV() {} - int Open(const char* file_name); - int New(const char* file_name); - void Close(); - void* Handle(int index); - int ReadImageInfo(int index); - int ReadImageData(void* data); - int WriteImageInfo(); - int WriteImageData(void* data); + imFileFormatBase* Create(void) const { return new imFileFormatWMV(this); } int CanWrite(const char* compression, int color_mode, int data_type) const; }; @@ -552,7 +561,7 @@ void imFormatRegisterWMV(void) imFormatRegister(new imFormatWMV()); } -int imFormatWMV::Open(const char* file_name) +int imFileFormatWMV::Open(const char* file_name) { /* initializes COM */ CoInitialize(NULL); @@ -675,7 +684,7 @@ int imFormatWMV::Open(const char* file_name) return IM_ERR_NONE; } -int imFormatWMV::New(const char* file_name) +int imFileFormatWMV::New(const char* file_name) { /* initializes COM */ CoInitialize(NULL); @@ -698,7 +707,7 @@ int imFormatWMV::New(const char* file_name) return IM_ERR_NONE; } -void imFormatWMV::Close() +void imFileFormatWMV::Close() { HeaderInfo->Release(); @@ -720,7 +729,7 @@ void imFormatWMV::Close() CoUninitialize(); } -void* imFormatWMV::Handle(int index) +void* imFileFormatWMV::Handle(int index) { if (index == 1) { @@ -733,7 +742,7 @@ void* imFormatWMV::Handle(int index) return NULL; } -void imFormatWMV::iReadAttrib(imAttribTable* attrib_table) +void imFileFormatWMV::iReadAttrib(imAttribTable* attrib_table) { WORD StreamNumber = 0; WORD attrib_list_count = 0; @@ -916,12 +925,12 @@ static int iAttribSet(void* user_data, int index, const char* name, int data_typ return 1; } -void imFormatWMV::iWriteAttrib(imAttribTable* attrib_table) +void imFileFormatWMV::iWriteAttrib(imAttribTable* attrib_table) { attrib_table->ForEach((void*)HeaderInfo, iAttribSet); } -void imFormatWMV::CalcFPS() +void imFileFormatWMV::CalcFPS() { LONGLONG AvgTimePerFrame = 0; @@ -970,7 +979,7 @@ void imFormatWMV::CalcFPS() } } -void imFormatWMV::SetOutputProps() +void imFileFormatWMV::SetOutputProps() { DWORD output_number; Reader->GetOutputNumberForStream(stream_number, &output_number); @@ -1002,7 +1011,7 @@ void imFormatWMV::SetOutputProps() } } -int imFormatWMV::SetInputProps() +int imFileFormatWMV::SetInputProps() { DWORD input_count; Writer->GetInputCount(&input_count); @@ -1078,7 +1087,7 @@ int imFormatWMV::SetInputProps() return 1; } -int imFormatWMV::SetProfile() +int imFileFormatWMV::SetProfile() { HRESULT hr; @@ -1144,7 +1153,7 @@ int imFormatWMV::SetProfile() return 1; } -int imFormatWMV::ReadImageInfo(int index) +int imFileFormatWMV::ReadImageInfo(int index) { if (this->seekable && this->current_frame != index) { @@ -1268,7 +1277,7 @@ int imFormatWMV::ReadImageInfo(int index) return IM_ERR_NONE; } -int imFormatWMV::WriteImageInfo() +int imFileFormatWMV::WriteImageInfo() { if (this->bmiHeader) { @@ -1357,7 +1366,7 @@ int imFormatWMV::WriteImageInfo() return IM_ERR_NONE; } -void imFormatWMV::ReadPalette(unsigned char* bmp_colors) +void imFileFormatWMV::ReadPalette(unsigned char* bmp_colors) { /* convert the color map to the IM format */ for (int c = 0; c < this->palette_count; c++) @@ -1369,7 +1378,7 @@ void imFormatWMV::ReadPalette(unsigned char* bmp_colors) } } -void imFormatWMV::WritePalette(unsigned char* bmp_colors) +void imFileFormatWMV::WritePalette(unsigned char* bmp_colors) { /* convert the color map to the IM format */ for (int c = 0; c < this->palette_count; c++) @@ -1380,7 +1389,7 @@ void imFormatWMV::WritePalette(unsigned char* bmp_colors) } } -void imFormatWMV::InitMasks(imDib* dib) +void imFileFormatWMV::InitMasks(imDib* dib) { if (dib->bmih->biCompression == BI_BITFIELDS) { @@ -1429,7 +1438,7 @@ void imFormatWMV::InitMasks(imDib* dib) } } -void imFormatWMV::FixRGB(int bpp) +void imFileFormatWMV::FixRGB(int bpp) { int x; @@ -1486,7 +1495,7 @@ void imFormatWMV::FixRGB(int bpp) } } -int imFormatWMV::ReadImageData(void* data) +int imFileFormatWMV::ReadImageData(void* data) { imCounterTotal(this->counter, this->height, "Reading WMV Frame..."); @@ -1552,7 +1561,7 @@ int imFormatWMV::ReadImageData(void* data) return IM_ERR_NONE; } -int imFormatWMV::WriteImageData(void* data) +int imFileFormatWMV::WriteImageData(void* data) { imCounterTotal(this->counter, this->height, "Writing WMV Frame..."); |