[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]

details vigra/imageinfo.hxx VIGRA

00001 /************************************************************************/
00002 /*                                                                      */
00003 /*               Copyright 1998-2001 by Ullrich Koethe                  */
00004 /*               Copyright 2001-2002 by Gunnar Kedenburg                */
00005 /*       Cognitive Systems Group, University of Hamburg, Germany        */
00006 /*                                                                      */
00007 /*    This file is part of the VIGRA computer vision library.           */
00008 /*    ( Version 1.5.0, Dec 07 2006 )                                    */
00009 /*    The VIGRA Website is                                              */
00010 /*        http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/      */
00011 /*    Please direct questions, bug reports, and contributions to        */
00012 /*        koethe@informatik.uni-hamburg.de          or                  */
00013 /*        vigra@kogs1.informatik.uni-hamburg.de                         */
00014 /*                                                                      */
00015 /*    Permission is hereby granted, free of charge, to any person       */
00016 /*    obtaining a copy of this software and associated documentation    */
00017 /*    files (the "Software"), to deal in the Software without           */
00018 /*    restriction, including without limitation the rights to use,      */
00019 /*    copy, modify, merge, publish, distribute, sublicense, and/or      */
00020 /*    sell copies of the Software, and to permit persons to whom the    */
00021 /*    Software is furnished to do so, subject to the following          */
00022 /*    conditions:                                                       */
00023 /*                                                                      */
00024 /*    The above copyright notice and this permission notice shall be    */
00025 /*    included in all copies or substantial portions of the             */
00026 /*    Software.                                                         */
00027 /*                                                                      */
00028 /*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND    */
00029 /*    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES   */
00030 /*    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND          */
00031 /*    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT       */
00032 /*    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,      */
00033 /*    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      */
00034 /*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR     */
00035 /*    OTHER DEALINGS IN THE SOFTWARE.                                   */
00036 /*                                                                      */
00037 /************************************************************************/
00038 
00039 /* Modifications by Pablo d'Angelo
00040  * updated to vigra 1.4 by Douglas Wilkins
00041  * as of 18 Febuary 2006:
00042  *  - Added UINT16 and UINT32 pixel types.
00043  *  - Added support for obtaining extra bands beyond RGB.
00044  *  - Added support for a position field that indicates the start of this
00045  *    image relative to some global origin.
00046  *  - Added support for x and y resolution fields.
00047  *  - Added support for ICC profiles
00048  */
00049 
00050 #ifndef VIGRA_IMAGEINFO_HXX
00051 #define VIGRA_IMAGEINFO_HXX
00052 
00053 #include <memory>
00054 #include <string>
00055 #include "config.hxx"
00056 #include "error.hxx"
00057 #include "diff2d.hxx"
00058 #include "codec.hxx"
00059 #include "array_vector.hxx"
00060 
00061 namespace vigra
00062 {
00063 /** \addtogroup VigraImpex Image Import/Export Facilities
00064 
00065     supports GIF, TIFF, JPEG, BMP, PNM (PBM, PGM, PPM), PNG, SunRaster, KHOROS-VIFF formats
00066 **/
00067 //@{
00068 
00069     /** \brief List the image formats VIGRA can read and write.
00070 
00071         This is useful for creating error messages if VIGRA encounters an
00072         image format it doesn't recognize.
00073 
00074         <b> Usage:</b>
00075 
00076         <b>\#include</b> "<a href="imageinfo_8hxx-source.html">vigra/imageinfo.hxx</a>"<br>
00077         Namespace: vigra
00078 
00079         \code
00080         std::cout << "supported formats: " << vigra::impexListFormats() << std::endl;
00081         \endcode
00082 
00083     **/
00084 VIGRA_EXPORT std::string impexListFormats();
00085 
00086     /** \brief List the file extension VIGRA understands.
00087 
00088         This is useful for creating file dialogs that only list image files
00089         VIGRA can actually import.
00090 
00091         <b> Usage:</b>
00092 
00093         <b>\#include</b> "<a href="imageinfo_8hxx-source.html">vigra/imageinfo.hxx</a>"<br>
00094         Namespace: vigra
00095 
00096         \code
00097         std::cout << "supported extensions: " << vigra::impexListExtensions() << std::endl;
00098         \endcode
00099 
00100     **/
00101 VIGRA_EXPORT std::string impexListExtensions();
00102 
00103 /** \brief Test whether a file is an image format known to VIGRA.
00104 
00105     This checks the first few bytes of the file and compares them with the
00106     "magic strings" of each recognized image format.
00107 
00108     <b> Usage:</b>
00109 
00110     <b>\#include</b> "<a href="imageinfo_8hxx-source.html">vigra/imageinfo.hxx</a>"<br>
00111     Namespace: vigra
00112 
00113     \code
00114     std::cout << "is image: " << vigra::isImage("foo.bmp") << std::endl;
00115     \endcode
00116 
00117 **/
00118 VIGRA_EXPORT bool isImage(char const * filename);
00119 
00120 /********************************************************/
00121 /*                                                      */
00122 /*                   ImageExportInfo                    */
00123 /*                                                      */
00124 /********************************************************/
00125 
00126 /** \brief Argument object for the function exportImage().
00127     See \ref exportImage() for usage example. This object must be used
00128     to define the properties of an image to be written to disk.
00129 
00130     <b>\#include</b> "<a href="imageinfo_8hxx-source.html">vigra/imageinfo.hxx</a>"<br>
00131     Namespace: vigra
00132 **/
00133 class ImageExportInfo
00134 {
00135   public:
00136         /** Construct ImageExportInfo object.
00137 
00138             The image will be stored under the given filename.
00139             The file type will be guessed from the extension unless overridden
00140             by \ref setFileType(). Recognized extensions: '.bmp', '.gif',
00141             '.jpeg', '.jpg', '.p7', '.png', '.pbm', '.pgm', '.pnm', '.ppm', '.ras',
00142             '.tif', '.tiff', '.xv', '.hdr'.
00143             JPEG support requires libjpeg, PNG support requires libpng, and
00144             TIFF support requires libtiff.
00145          **/
00146     VIGRA_EXPORT ImageExportInfo( const char * );
00147     VIGRA_EXPORT ~ImageExportInfo();
00148 
00149     VIGRA_EXPORT const char * getFileName() const;
00150 
00151         /** Store image as given file type.
00152 
00153             This will override any type guessed
00154             from the file name's extension. Recognized file types:
00155 
00156             <DL>
00157             <DT>"BMP"<DD> Microsoft Windows bitmap image file.
00158             <DT>"GIF"<DD> CompuServe graphics interchange format; 8-bit color.
00159             <DT>"JPEG"<DD> Joint Photographic Experts Group JFIF format;
00160             compressed 24-bit color (only available if libjpeg is installed).
00161             <DT>"PNG"<DD> Portable Network Graphic
00162             (only available if libpng is installed).
00163             <DT>"PBM"<DD> Portable bitmap format (black and white).
00164             <DT>"PGM"<DD> Portable graymap format (gray scale).
00165             <DT>"PNM"<DD> Portable anymap.
00166             <DT>"PPM"<DD> Portable pixmap format (color).
00167             <DT>"SUN"<DD> SUN Rasterfile.
00168             <DT>"TIFF"<DD> Tagged Image File Format.
00169             (only available if libtiff is installed.)
00170             <DT>"VIFF"<DD> Khoros Visualization image file.
00171             </DL>
00172 
00173             With the exception of TIFF, VIFF, PNG, and PNM all file types store
00174             1 byte (gray scale and mapped RGB) or 3 bytes (RGB) per
00175             pixel.
00176 
00177             PNG can store UInt8 and UInt16 values, and supports 1 and 3 channel
00178             images. One additional alpha channel is also supported.
00179 
00180             PNM can store 1 and 3 channel images with UInt8, UInt16 and UInt32
00181             values in each channel.
00182 
00183             TIFF and VIFF are aditionally able to store short and long
00184             integers (2 or 4 bytes) and real values (32 bit float and
00185             64 bit double) without conversion. So you will need to use
00186             TIFF or VIFF if you need to store images with high
00187             accuracy (the appropriate type to write is automatically
00188             derived from the image type to be exported). However, many
00189             other programs using TIFF (e.g. ImageMagick) have not
00190             implemented support for those pixel types.  So don't be
00191             surprised if the generated TIFF is not readable in some
00192             cases.  If this happens, export the image as 'unsigned
00193             char' or 'RGBValue<root