00001 /* 00002 /-------------------------------------------------------------------- 00003 | 00004 | $Id: pltiffdec.h,v 1.5 2002/08/04 20:08:01 uzadow Exp $ 00005 | 00006 | Copyright (c) 1996-2002 Ulrich von Zadow 00007 | 00008 \-------------------------------------------------------------------- 00009 */ 00010 00011 #ifndef INCL_PLTIFFDEC 00012 #define INCL_PLTIFFDEC 00013 00014 #ifndef INCL_PLPICDEC 00015 #include "plpicdec.h" 00016 #endif 00017 00018 #ifndef INCL_PLPOINT 00019 #include "plpoint.h" 00020 #endif 00021 00022 extern "C" 00023 { 00024 #include "tiff.h" 00025 #include "tiffio.h" 00026 } 00027 00028 //! TIFF file decoder. Uses LIBTIFF to do the actual conversion. 00029 //! Supports 1, 8, 24 and 32 bits per pixel as output formats. 00030 class PLTIFFDecoder : public PLPicDecoder 00031 { 00032 00033 friend class _tiff_helper; 00034 friend class PLTIFFEncoder; 00035 00036 public: 00037 //! Creates a decoder 00038 PLTIFFDecoder 00039 (); 00040 00041 //! Destroys a decoder 00042 virtual ~PLTIFFDecoder 00043 (); 00044 00045 //! 00046 virtual void Open (PLDataSource * pDataSrc); 00047 00048 //! Fills the bitmap with the image. 00049 virtual void GetImage (PLBmp & Bmp); 00050 00051 //! 00052 virtual void Close (); 00053 00054 int GetField( int tag_id, ... ); 00055 //! this is this first argument to most libtiff's routines 00056 //! use at your own risk; you've been warned! 00057 TIFF* GetTIFFHandle() { return m_pTif; } 00058 00059 private: 00060 // these 2 helpers dedicated to hi/low bit-depths respectively 00061 void doHiColor 00062 ( TIFF * tif, 00063 PLBmp * pBmp, 00064 uint16 SamplePerPixel 00065 ); 00066 00067 void doLoColor 00068 ( TIFF * tif, 00069 PLBmp * pBmp 00070 ); 00071 00072 const PLPoint getResolution (TIFF* tif); 00073 00074 // Callback from the TIFF library. 00075 // Should be accessed only by the TIFF decoder and libtiff. 00076 static void Win32WarningHandler 00077 ( const char* module, 00078 const char* fmt, 00079 va_list ap 00080 ); 00081 00082 // Callback from the TIFF library. 00083 // Should be accessed only by the TIFF decoder and libtiff. 00084 static void Win32ErrorHandler 00085 ( const char* module, 00086 const char* fmt, 00087 va_list ap 00088 ); 00089 00090 private: 00091 // Temporary storage for an error message. 00092 // Used in the callbacks, so it's static. 00093 static char m_szLastErr[256]; 00094 00095 TIFF* m_pTif; 00096 }; 00097 00098 00099 #endif 00100 /* 00101 /-------------------------------------------------------------------- 00102 | 00103 | $Log: pltiffdec.h,v $ 00104 | Revision 1.5 2002/08/04 20:08:01 uzadow 00105 | Added PLBmpInfo class, ability to extract metainformation from images without loading the whole image and proper greyscale support. 00106 | 00107 | Revision 1.4 2002/03/31 13:36:42 uzadow 00108 | Updated copyright. 00109 | 00110 | Revision 1.3 2001/10/21 17:12:40 uzadow 00111 | Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel. 00112 | 00113 | Revision 1.2 2001/10/17 13:19:47 uzadow 00114 | Added support for photoshop tiff alpha channels. 00115 | 00116 | Revision 1.1 2001/09/16 19:03:22 uzadow 00117 | Added global name prefix PL, changed most filenames. 00118 | 00119 | Revision 1.7 2000/12/18 22:42:52 uzadow 00120 | Replaced RGBAPIXEL with PLPixel32. 00121 | 00122 | Revision 1.6 2000/01/16 20:43:15 anonymous 00123 | Removed MFC dependencies 00124 | 00125 | Revision 1.5 2000/01/08 15:56:12 Ulrich von Zadow 00126 | Made sure change logging works in every file. 00127 | 00128 | Revision 1.4 1999/10/03 18:50:52 Ulrich von Zadow 00129 | Added automatic logging of changes. 00130 | 00131 | 00132 -------------------------------------------------------------------- 00133 */