// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "imagtiff.h"
#endif
IMPLEMENT_DYNAMIC_CLASS(wxTIFFHandler,wxImageHandler)
+#if wxUSE_STREAMS
+
extern "C"
{
{
}
+static void
+TIFFwxWarningHandler(const char* module, const char* fmt, va_list ap)
+{
+ if (module != NULL)
+ wxLogWarning(_("tiff module: %s"), module);
+ wxLogWarning((wxChar *) fmt, ap);
+}
+
+static void
+TIFFwxErrorHandler(const char* module, const char* fmt, va_list ap)
+{
+ if (module != NULL)
+ wxLogError(_("tiff module: %s"), module);
+ wxVLogError((wxChar *) fmt, ap);
+}
+
} // extern "C"
TIFF*
return tif;
}
+wxTIFFHandler::wxTIFFHandler()
+{
+ m_name = wxT("TIFF file");
+ m_extension = wxT("tif");
+ m_type = wxBITMAP_TYPE_TIF;
+ m_mime = wxT("image/tiff");
+ TIFFSetWarningHandler((TIFFErrorHandler) TIFFwxWarningHandler);
+ TIFFSetErrorHandler((TIFFErrorHandler) TIFFwxErrorHandler);
+}
+
bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int index )
{
if (index == -1)
{
unsigned char hdr[2];
- stream.Read(&hdr, 2);
- stream.SeekI(-2, wxFromCurrent);
+ if ( !stream.Read(&hdr, WXSIZEOF(hdr)) )
+ return FALSE;
- return ((hdr[0] == 0x49 && hdr[1] == 0x49) ||
- (hdr[0] == 0x4D && hdr[1] == 0x4D));
+ return (hdr[0] == 'I' && hdr[1] == 'I') ||
+ (hdr[0] == 'M' && hdr[1] == 'M');
}
+#endif // wxUSE_STREAMS
-#endif
- // wxUSE_LIBTIFF
-
+#endif // wxUSE_LIBTIFF