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