X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1811af8709aa08b4d442f34b0f714cd78c5b9f26..b6a20a20d010d643e52914f51aa0700df0da925f:/src/common/imagiff.cpp diff --git a/src/common/imagiff.cpp b/src/common/imagiff.cpp index affbd43967..6ceafceab0 100644 --- a/src/common/imagiff.cpp +++ b/src/common/imagiff.cpp @@ -10,9 +10,9 @@ // Parts of this source are based on the iff loading algorithm found // in xviff.c. Permission by the original author, Thomas Meyer, and // by the author of xv, John Bradley for using the iff loading part -// in wxWindows has been gratefully given. +// in wxWidgets has been gratefully given. -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "imagiff.h" #endif @@ -34,6 +34,10 @@ #include "wx/log.h" #include "wx/intl.h" +#if wxUSE_PALETTE + #include "wx/palette.h" +#endif // wxUSE_PALETTE + #include #include @@ -230,18 +234,20 @@ int wxIFFDecoder::GetTransparentColour() const { return m_image->transparent; } // bool wxIFFDecoder::CanRead() { - unsigned char buf[12] = ""; + unsigned char buf[12]; - m_f->Read(buf, 12); - m_f->SeekI(-12, wxFromCurrent); + if ( !m_f->Read(buf, WXSIZEOF(buf)) ) + return FALSE; + + m_f->SeekI(-(off_t)WXSIZEOF(buf), wxFromCurrent); - return (memcmp(buf, "FORM", 4) == 0 && memcmp(buf+8, "ILBM", 4) == 0); + return (memcmp(buf, "FORM", 4) == 0) && (memcmp(buf+8, "ILBM", 4) == 0); } // ReadIFF: // Based on xv source code by Thomas Meyer -// Permission for use in wxWindows has been gratefully given. +// Permission for use in wxWidgets has been gratefully given. typedef unsigned char byte; #define IFFDEBUG 0 @@ -783,14 +789,9 @@ bool wxIFFHandler::SaveFile(wxImage * WXUNUSED(image), bool wxIFFHandler::DoCanRead(wxInputStream& stream) { - wxIFFDecoder *decod; - bool ok; + wxIFFDecoder decod(&stream); - decod = new wxIFFDecoder(&stream); - ok = decod->CanRead(); - delete decod; - - return ok; + return decod.CanRead(); } #endif // wxUSE_STREAMS