home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kimageio.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  4.6 KB  |  171 lines

  1. /*
  2. * kimageio.h -- Declaration of interface to the KDE Image IO library.
  3. * Sirtaj Singh Kang <taj@kde.org>, 23 Sep 1998.
  4. *
  5. * This library is distributed under the conditions of the GNU LGPL.
  6. */
  7.  
  8. #ifndef SSK_KIMGIO_H
  9. #define SSK_KIMGIO_H
  10.  
  11. #include <qstringlist.h>
  12.  
  13. #include <kdelibs_export.h>
  14.  
  15. /**
  16.  * Interface to the KDE Image IO plugin architecture.
  17.  *
  18.  * This library allows KDE applications to read and write images in a
  19.  * variety of formats, transparently via the QImage and QPixmap load
  20.  * and save methods.
  21.  *
  22.  * The image processing backends are written as image handlers compatible
  23.  * with the QImageIO handler format. The backends are loaded on demand
  24.  * when a particular format is requested. Each format can be identified
  25.  * by a unique type id string.
  26.  *
  27.  * \b Formats:
  28.  *
  29.  * Currently supported formats include:
  30.  * @li BMP     \<read\> \<write\>
  31.  * @li EPS     \<read\> \<write\>
  32.  * @li EXR     \<read\>
  33.  * @li G3      \<read\>
  34.  * @li GIF     \<read\>
  35.  * @li ICO     \<read\>
  36.  * @li JP2     \<read\> \<write\>
  37.  * @li JPEG    \<read\> \<write\>
  38.  * @li NETPBM  \<read\> \<write\>
  39.  * @li PCX     \<read\> \<write\>
  40.  * @li PNG     \<read\> \<write, only with newer libraries\>
  41.  * @li TGA     \<read\> \<write\>
  42.  * @li TIFF    \<read\>
  43.  * @li XBM     \<read\> \<write\>
  44.  * @li XPM     \<read\> \<write\>
  45.  * @li XV      \<read\> \<write\>
  46.  *
  47.  * \b Usage:
  48.  *
  49.  * Simply call the KImageIO::registerFormats() static method declared
  50.  * in kimageio.h.
  51.  *
  52.  * \b Example:
  53.  *
  54.  * \code
  55.  * #include<qpixmap.h>
  56.  * #include<kimageio.h>
  57.  *
  58.  * int main( int argc, char **argv )
  59.  *  {
  60.  *   ....
  61.  *   KImageIO::registerFormats();
  62.  *   ...   // start main program
  63.  * }
  64.  * \endcode
  65.  *
  66.  * @see KImageIO, QPixmap, QImage, QImageIO
  67.  * @author Sirtaj Singh Kang
  68.  */
  69. class KIO_EXPORT KImageIO
  70. {
  71. public:
  72.   /**
  73.    * Possible image file access modes.
  74.    *
  75.    * Used in various KImageIO static function.
  76.    **/
  77.   enum Mode { Reading, Writing };
  78.  
  79.   /**
  80.    *  Registers all KImageIO supported formats.
  81.    */
  82.   static void registerFormats();
  83.  
  84.   /**
  85.    * Checks if a special type is supported for writing.
  86.    * @param type the type id of the image type
  87.    * @return true if the image format can be written
  88.    */
  89.   static bool canWrite(const QString& type);
  90.  
  91.   /**
  92.    * Checks if a special type is supported for reading.
  93.    * @param type the type id of the image type
  94.    * @return true if the image format can be read
  95.    */
  96.   static bool canRead(const QString& type);
  97.  
  98.   /**
  99.    * Returns a list of all KImageIO supported formats.
  100.    *
  101.    * @param mode Tells whether to retrieve modes that can be read or written.
  102.    * @return a list of the type ids
  103.    */
  104.   static QStringList types(Mode mode = Writing);
  105.  
  106.  
  107.   /**
  108.    * Returns a list of patterns of all KImageIO supported formats.
  109.    *
  110.    * These patterns can be passed to KFileDialog::getOpenFileName()
  111.    * or KFileDialog::getSaveFileName(), for example.
  112.    *
  113.    * @param mode Tells whether to retrieve modes that can be read or written.
  114.    * @return a space-separated list of file globs that describe the
  115.    * supported formats
  116.    */
  117.   static QString pattern(Mode mode = Reading);
  118.  
  119.   /**
  120.    * Returns the suffix of an image type.
  121.    * @param type the type id of the file format
  122.    * @return the suffix of the file format or QString::null if it does not
  123.    *         exist
  124.    */
  125.   static QString suffix(const QString& type);
  126.  
  127.   /**
  128.    * Returns the type of a MIME type.
  129.    * @param mimeType the MIME type to search
  130.    * @return type id of the MIME type or QString::null if the MIME type
  131.    *         is not supported
  132.    * @since 3.1
  133.    */
  134.   static QString typeForMime(const QString& mimeType);
  135.  
  136.   /**
  137.    * Returns the type of given filename.
  138.    * @param filename the filename to check
  139.    * @return if the file name's suffix is known the type id of the
  140.    *         file type, otherwise QString::null
  141.    */
  142.   static QString type(const QString& filename);
  143.  
  144.   /**
  145.    *  Returns a list of MIME types for all KImageIO supported formats.
  146.    *
  147.    * @param mode Tells whether to retrieve modes that can be read or written.
  148.    * @return a list if MIME types of the supported formats
  149.    */
  150.   static QStringList mimeTypes( Mode mode = Writing );
  151.  
  152.   /**
  153.    * Test to see whether a MIME type is supported to reading/writing.
  154.    * @param _mimeType the MIME type to check
  155.    * @param _mode Tells whether to check for reading or writing capabilities
  156.    * @return true if the type is supported
  157.    **/
  158.   static bool isSupported( const QString& _mimeType, Mode _mode = Writing );
  159.  
  160.   /**
  161.    * Returns the MIME type of @p _filename.
  162.    * @param _filename the filename to check
  163.    * @return the MIME type of the file, or QString::null
  164.    **/
  165.   static QString mimeType( const QString& _filename );
  166. };
  167.  
  168.  
  169. #endif
  170.  
  171.