IM: im_file.h Source File

IM - Imaging Libray

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: 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 expand or compact to/from 8bpp */
00044   int switch_type;      /**< flag to switch the original data type: char-byte, short-ushort, uint-int, double-float */
00045 
00046   long palette[256];
00047   int palette_count;
00048 
00049   int user_color_mode,
00050       user_data_type,
00051       file_color_mode,  /* these two must be filled by te driver always. */
00052       file_data_type;
00053 
00054   /* these must be filled by the driver when reading,
00055      and given by the user when writing. */
00056 
00057   char compression[10];
00058   int image_count;
00059   int width,           
00060       height;
00061 };
00062 
00063 
00064 /* Internal Use only */
00065 
00066 /* Initializes the imFile structure.
00067  * Used by the special format RAW. */
00068 void imFileClear(imFile* ifile);
00069 
00070 /* Initializes the line buffer.
00071  * Used by "im_file.cpp" only. */
00072 void imFileLineBufferInit(imFile* ifile);
00073 
00074 /* Check if the conversion is valid.
00075  * Used by "im_file.cpp" only. */
00076 int imFileCheckConversion(imFile* ifile);
00077 
00078 
00079 
00080 /* File Format SDK */
00081 
00082 /** Number of lines to be accessed.
00083  * \ingroup filesdk */
00084 int imFileLineBufferCount(imFile* ifile);
00085 
00086 /** Increments the row and plane counters.
00087  * \ingroup filesdk */
00088 void imFileLineBufferInc(imFile* ifile, int *row, int *plane);
00089 
00090 /** Converts from FILE color mode to USER color mode.
00091  * \ingroup filesdk */
00092 void imFileLineBufferRead(imFile* ifile, void* data, int line, int plane);
00093 
00094 /** Converts from USER color mode to FILE color mode.
00095  * \ingroup filesdk */
00096 void imFileLineBufferWrite(imFile* ifile, const void* data, int line, int plane);
00097 
00098 /** Utility to calculate the line size in byte with a specified alignment. \n
00099  * "align" can be 1, 2 or 4.
00100  * \ingroup filesdk */
00101 int imFileLineSizeAligned(int width, int bpp, int align);
00102 
00103 
00104 #if defined(__cplusplus)
00105 }
00106 #endif
00107 
00108 #endif