IM: im_file.h Source File

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.1 2005/04/02 22:07:00 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 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       image_index,
00060       width,           
00061       height;
00062 };
00063 
00064 
00065 /* Internal Use only */
00066 
00067 /* Initializes the imFile structure.
00068  * Used by the special format RAW. */
00069 void imFileClear(imFile* ifile);
00070 
00071 /* Initializes the line buffer.
00072  * Used by "im_file.cpp" only. */
00073 void imFileLineBufferInit(imFile* ifile);
00074 
00075 /* Check if the conversion is valid.
00076  * Used by "im_file.cpp" only. */
00077 int imFileCheckConversion(imFile* ifile);
00078 
00079 
00080 
00081 /* File Format SDK */
00082 
00083 /** Number of lines to be accessed.
00084  * \ingroup filesdk */
00085 int imFileLineBufferCount(imFile* ifile);
00086 
00087 /** Increments the row and plane counters.
00088  * \ingroup filesdk */
00089 void imFileLineBufferInc(imFile* ifile, int *row, int *plane);
00090 
00091 /** Converts from FILE color mode to USER color mode.
00092  * \ingroup filesdk */
00093 void imFileLineBufferRead(imFile* ifile, void* data, int line, int plane);
00094 
00095 /** Converts from USER color mode to FILE color mode.
00096  * \ingroup filesdk */
00097 void imFileLineBufferWrite(imFile* ifile, const void* data, int line, int plane);
00098 
00099 /** Utility to calculate the line size in byte with a specified alignment. \n
00100  * "align" can be 1, 2 or 4.
00101  * \ingroup filesdk */
00102 int imFileLineSizeAligned(int width, int bpp, int align);
00103 
00104 
00105 #if defined(__cplusplus)
00106 }
00107 #endif
00108 
00109 #endif