X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..717de46036ff913de0f5c5cbb1d0fd0bb03f4c3a:/src/common/imagiff.cpp diff --git a/src/common/imagiff.cpp b/src/common/imagiff.cpp index 3f5afc5725..058d6e5cd0 100644 --- a/src/common/imagiff.cpp +++ b/src/common/imagiff.cpp @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: imagiff.h +// Name: src/common/imagiff.h // Purpose: wxImage handler for Amiga IFF images // Author: Steffen Gutmann, Thomas Meyer // RCS-ID: $Id$ // Copyright: (c) Steffen Gutmann, 2002 -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // Parts of this source are based on the iff loading algorithm found @@ -12,27 +12,22 @@ // by the author of xv, John Bradley for using the iff loading part // in wxWidgets has been gratefully given. -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "imagiff.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ -# pragma hdrstop + #pragma hdrstop #endif +#if wxUSE_IMAGE && wxUSE_IFF + #ifndef WX_PRECOMP -# include "wx/defs.h" + #include "wx/log.h" + #include "wx/intl.h" #endif -#if wxUSE_IMAGE && wxUSE_IFF - #include "wx/imagiff.h" #include "wx/wfstream.h" -#include "wx/log.h" -#include "wx/intl.h" #if wxUSE_PALETTE #include "wx/palette.h" @@ -72,7 +67,7 @@ public: unsigned int w; /* width */ unsigned int h; /* height */ int transparent; /* transparent color (-1 = none) */ - int colors; /* number of colors */ + int colors; /* number of colors */ unsigned char *p; /* bitmap */ unsigned char *pal; /* palette */ @@ -83,8 +78,8 @@ public: class WXDLLEXPORT wxIFFDecoder { private: - IFFImage *m_image; // image data - wxInputStream *m_f; // input stream + IFFImage *m_image; // image data + wxInputStream *m_f; // input stream unsigned char *databuf; unsigned char *picptr; unsigned char *decomp_mem; @@ -146,7 +141,7 @@ bool wxIFFDecoder::ConvertToImage(wxImage *image) const image->Create(GetWidth(), GetHeight()); if (!image->Ok()) - return FALSE; + return false; unsigned char *pal = GetPalette(); unsigned char *src = GetData(); @@ -175,7 +170,7 @@ bool wxIFFDecoder::ConvertToImage(wxImage *image) const image->SetMaskColour(255, 0, 255); } else - image->SetMask(FALSE); + image->SetMask(false); #if wxUSE_PALETTE if (pal && colors > 0) @@ -207,7 +202,7 @@ bool wxIFFDecoder::ConvertToImage(wxImage *image) const dst[2] = src[2]; } - return TRUE; + return true; } @@ -230,16 +225,16 @@ int wxIFFDecoder::GetTransparentColour() const { return m_image->transparent; } // // CanRead: -// Returns TRUE if the file looks like a valid IFF, FALSE otherwise. +// Returns true if the file looks like a valid IFF, false otherwise. // bool wxIFFDecoder::CanRead() { unsigned char buf[12]; if ( !m_f->Read(buf, WXSIZEOF(buf)) ) - return FALSE; + return false; - m_f->SeekI(-(off_t)WXSIZEOF(buf), wxFromCurrent); + m_f->SeekI(-(wxFileOffset)WXSIZEOF(buf), wxFromCurrent); return (memcmp(buf, "FORM", 4) == 0) && (memcmp(buf+8, "ILBM", 4) == 0); } @@ -339,7 +334,7 @@ int wxIFFDecoder::ReadIFF() } // compute file length - off_t currentPos = m_f->TellI(); + wxFileOffset currentPos = m_f->TellI(); m_f->SeekI(0, wxFromEnd); long filesize = m_f->TellI(); m_f->SeekI(currentPos, wxFromStart); @@ -384,23 +379,16 @@ int wxIFFDecoder::ReadIFF() // main decoding loop. searches IFF chunks and handles them. // terminates when BODY chunk was found or dataptr ran over end of file // - bool BMHDok = FALSE, CMAPok = FALSE, CAMGok = FALSE; + bool BMHDok = false, CAMGok = false; int bmhd_width = 0, bmhd_height = 0, bmhd_bitplanes = 0, bmhd_transcol = -1; - byte bmhd_masking = 0, bmhd_compression = 0; + byte bmhd_compression = 0; long camg_viewmode = 0; int colors = 0; while (dataptr + 8 <= dataend) { // get chunk length and make even - size_t chunkLen = (iff_getlong(dataptr + 4) + 1) & 0xfffffffe; -#ifdef __VMS - // Silence compiler warning - int chunkLen_; - chunkLen_ = chunkLen; - if (chunkLen_ < 0) { // format error? -#else - if (chunkLen < 0) { // format error? -#endif - break; + long chunkLen = (iff_getlong(dataptr + 4) + 1) & 0xfffffffe; + if (chunkLen < 0) { // format error? + break; } bool truncated = (dataptr + 8 + chunkLen > dataend); @@ -411,10 +399,10 @@ int wxIFFDecoder::ReadIFF() bmhd_width = iff_getword(dataptr + 8); // width of picture bmhd_height= iff_getword(dataptr + 8 + 2); // height of picture bmhd_bitplanes = *(dataptr + 8 + 8); // # of bitplanes - bmhd_masking = *(dataptr + 8 + 9); + // bmhd_masking = *(dataptr + 8 + 9); -- unused currently bmhd_compression = *(dataptr + 8 + 10); // get compression bmhd_transcol = iff_getword(dataptr + 8 + 12); - BMHDok = TRUE; // got BMHD + BMHDok = true; // got BMHD dataptr += 8 + chunkLen; // to next chunk } else if (strncmp((char *)dataptr, "CMAP", 4) == 0) { // CMAP ? @@ -445,14 +433,13 @@ int wxIFFDecoder::ReadIFF() wxLogTrace(_T("iff"), _T("Read %d colors from IFF file."), colors); - CMAPok = TRUE; // got CMAP dataptr += 8 + chunkLen; // to next chunk } else if (strncmp((char *)dataptr, "CAMG", 4) == 0) { // CAMG ? if (chunkLen < 4 || truncated) { break; } camg_viewmode = iff_getlong(dataptr + 8); // get viewmodes - CAMGok = TRUE; // got CAMG + CAMGok = true; // got CAMG dataptr += 8 + chunkLen; // to next chunk } else if (strncmp((char *)dataptr, "BODY", 4) == 0) { // BODY ? @@ -763,7 +750,7 @@ bool wxIFFHandler::LoadFile(wxImage *image, wxInputStream& stream, } } delete decod; - return FALSE; + return false; } if ((error == wxIFF_TRUNCATED) && verbose) @@ -784,7 +771,7 @@ bool wxIFFHandler::SaveFile(wxImage * WXUNUSED(image), if (verbose) wxLogDebug(wxT("IFF: the handler is read-only!!")); - return FALSE; + return false; } bool wxIFFHandler::DoCanRead(wxInputStream& stream)