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 */
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 (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
00083 /* File Format SDK */
00084
00085 /** Number of lines to be accessed.
00086 * \ingroup filesdk */
00087 int imFileLineBufferCount(imFile* ifile);
00088
00089 /** Increments the row and plane counters.
00090 * \ingroup filesdk */
00091 void imFileLineBufferInc(imFile* ifile, int *row, int *plane);
00092
00093 /** Converts from FILE color mode to USER color mode.
00094 * \ingroup filesdk */
00095 void imFileLineBufferRead(imFile* ifile, void* data, int line, int plane);
00096
00097 /** Converts from USER color mode to FILE color mode.
00098 * \ingroup filesdk */
00099 void imFileLineBufferWrite(imFile* ifile, const void* data, int line, int plane);
00100
00101 /** Utility to calculate the line size in byte with a specified alignment. \n
00102 * "align" can be 1, 2 or 4.
00103 * \ingroup filesdk */
00104 int imFileLineSizeAligned(int width, int bpp, int align);
00105
00106
00107 #if defined(__cplusplus)
00108 }
00109 #endif
00110
00111 #endif