00001 /** \file 00002 * \brief File Access 00003 * 00004 * See Copyright Notice in im_lib.h 00005 */ 00006 00007 #ifndef __IM_FILE_H 00008 #define __IM_FILE_H 00009 00010 #include "im.h" 00011 00012 #if defined(__cplusplus) 00013 extern "C" { 00014 #endif 00015 00016 00017 /** \defgroup filesdk File Format SDK 00018 * \par 00019 * All the file formats are based on theses structures. Use them to create new file formats. \n 00020 * The LineBuffer functions will help transfer image from format buffer to application buffer and vice-versa. 00021 * \par 00022 * See \ref im_file.h 00023 * \ingroup file */ 00024 00025 00026 /** \brief Image File Format Base Class (SDK Use Only) 00027 * 00028 * \par 00029 * Base container to hold format independent state variables. 00030 * \ingroup filesdk */ 00031 struct _imFile 00032 { 00033 int is_new; 00034 void* attrib_table; /**< in fact is a imAttribTable, but we hide this here */ 00035 00036 void* line_buffer; /**< used for line convertion, contains all components if packed, or only one if not */ 00037 int line_buffer_size; 00038 int line_buffer_extra; /**< extra bytes to be allocated */ 00039 int line_buffer_alloc; /**< total allocated so far */ 00040 int counter; 00041 00042 int convert_bpp; /**< number of bpp to unpack/pack to/from 1 byte. 00043 When reading converts n packed bits to 1 byte (unpack). If n>1 will also expand to 0-255. 00044 When writing converts 1 byte to 1 bit (pack). 00045 If negative will only expand to 0-255 (no unpack or pack). */ 00046 int switch_type; /**< flag to switch the original data type: char-byte, short-ushort, uint-int, double-float */ 00047 00048 long palette[256]; 00049 int palette_count; 00050 00051 int user_color_mode, 00052 user_data_type, 00053 file_color_mode, /* these two must be filled by te driver always. */ 00054 file_data_type; 00055 00056 /* these must be filled by the driver when reading, 00057 and given by the user when writing. */ 00058 00059 char compression[10]; 00060 int image_count, 00061 image_index, 00062 width, 00063 height; 00064 }; 00065 00066 00067 /* Internal Use only */ 00068 00069 /* Initializes the imFile structure. 00070 * Used by the special format RAW. */ 00071 void imFileClear(imFile* ifile); 00072 00073 /* Initializes the line buffer. 00074 * Used by "im_file.cpp" only. */ 00075 void imFileLineBufferInit(imFile* ifile); 00076 00077 /* Check if the conversion is valid. 00078 * Used by "im_file.cpp" only. */ 00079 int imFileCheckConversion(imFile* ifile); 00080 00081 00082 /* File Format SDK */ 00083 00084 /** Number of lines to be accessed. 00085 * \ingroup filesdk */ 00086 int imFileLineBufferCount(imFile* ifile); 00087 00088 /** Increments the row and plane counters. 00089 * \ingroup filesdk */ 00090 void imFileLineBufferInc(imFile* ifile, int *row, int *plane); 00091 00092 /** Converts from FILE color mode to USER color mode. 00093 * \ingroup filesdk */ 00094 void imFileLineBufferRead(imFile* ifile, void* data, int line, int plane); 00095 00096 /** Converts from USER color mode to FILE color mode. 00097 * \ingroup filesdk */ 00098 void imFileLineBufferWrite(imFile* ifile, const void* data, int line, int plane); 00099 00100 /** Utility to calculate the line size in byte with a specified alignment. \n 00101 * "align" can be 1, 2 or 4. 00102 * \ingroup filesdk */ 00103 int imFileLineSizeAligned(int width, int bpp, int align); 00104 00105 /** Set the attributes FileFormat, FileCompression and FileImageCount. \n 00106 * Used in imFileOpen and imFileOpenAs, and after the attribute list cleared with RemoveAll. 00107 * \ingroup filesdk */ 00108 void imFileSetBaseAttributes(imFile* ifile); 00109 00110 00111 #if defined(__cplusplus) 00112 } 00113 #endif 00114 00115 #endif