X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4df78dc36e933fb1c3aa7c9d7ae2757a898ae05c..ecef04c293db3e3ebcdb12062fdc40b9b35c8c3e:/src/common/imagpcx.cpp?ds=sidebyside diff --git a/src/common/imagpcx.cpp b/src/common/imagpcx.cpp index 7c8c0c0c05..0ba41da2f2 100644 --- a/src/common/imagpcx.cpp +++ b/src/common/imagpcx.cpp @@ -20,16 +20,23 @@ #pragma hdrstop #endif +#ifndef WX_PRECOMP +# include "wx/defs.h" +#endif + +#if wxUSE_STREAMS && wxUSE_PCX + #include "wx/image.h" #include "wx/wfstream.h" #include "wx/module.h" #include "wx/log.h" + //----------------------------------------------------------------------------- // PCX decoding //----------------------------------------------------------------------------- -void RLEencode(unsigned char *p, unsigned int size, wxOutputStream& s) +void RLEencode(unsigned char *WXUNUSED(p), unsigned int WXUNUSED(size), wxOutputStream& WXUNUSED(s)) { } @@ -69,12 +76,12 @@ void RLEdecode(unsigned char *p, unsigned int size, wxInputStream& s) /* PCX header */ -#define HDR_VERSION 1 +#define HDR_VERSION 1 #define HDR_ENCODING 2 #define HDR_BITSPERPIXEL 3 #define HDR_XMIN 4 #define HDR_YMIN 6 -#define HDR_XMAX 8 +#define HDR_XMAX 8 #define HDR_YMAX 10 #define HDR_NPLANES 65 #define HDR_BYTESPERLINE 66 @@ -142,14 +149,17 @@ int ReadPCX(wxImage *image, wxInputStream& stream) // palette at the end of the file. Read it now before // proceeding. // - pos = stream.TellI(); - stream.SeekI(-769, wxFromEnd); + if (format == IMAGE_8BIT) + { + pos = stream.TellI(); + stream.SeekI(-769, wxFromEnd); - if (stream.GetC() != 12) - return E_FORMATO; + if (stream.GetC() != 12) + return E_FORMATO; - stream.Read(pal, 768); - stream.SeekI(pos, wxFromStart); + stream.Read(pal, 768); + stream.SeekI(pos, wxFromStart); + } // Allocate memory for a scanline and resize the image. // @@ -191,7 +201,7 @@ int ReadPCX(wxImage *image, wxInputStream& stream) { *(dst++) = p[i]; *(dst++) = p[i + bytesperline]; - *(dst++) = p[i + 2 * bytesperline]; + *(dst++) = p[i + 2 * bytesperline]; } break; } @@ -212,16 +222,14 @@ int ReadPCX(wxImage *image, wxInputStream& stream) IMPLEMENT_DYNAMIC_CLASS(wxPCXHandler,wxImageHandler) #endif -#if wxUSE_STREAMS - -bool wxPCXHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose ) +bool wxPCXHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int WXUNUSED(index) ) { int error; if (!CanRead(stream)) { if (verbose) - wxLogError(_T("wxPCXHandler: this is not a PCX file")); + wxLogError(wxT("wxPCXHandler: this is not a PCX file")); return FALSE; } @@ -234,10 +242,10 @@ bool wxPCXHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose { switch (error) { - case E_FORMATO: wxLogError(_T("wxPCXHandler: image format unsupported")); break; - case E_MEMORIA: wxLogError(_T("wxPCXHandler: couldn't allocate memory")); break; - case E_VERSION: wxLogError(_T("wxPCXHandler: version number too low")); break; - default: wxLogError(_T("wxPCXHandler: unknown error !!!")); + case E_FORMATO: wxLogError(wxT("wxPCXHandler: image format unsupported")); break; + case E_MEMORIA: wxLogError(wxT("wxPCXHandler: couldn't allocate memory")); break; + case E_VERSION: wxLogError(wxT("wxPCXHandler: version number too low")); break; + default: wxLogError(wxT("wxPCXHandler: unknown error !!!")); } } image->Destroy(); @@ -247,29 +255,24 @@ bool wxPCXHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose return TRUE; } -bool wxPCXHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbose ) +bool wxPCXHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSED(stream), bool verbose ) { if (verbose) - wxLogError(_T("wxPCXHandler::SaveFile still not implemented")); + wxLogError(wxT("wxPCXHandler::SaveFile still not implemented")); return FALSE; } -bool wxPCXHandler::CanRead( wxInputStream& stream ) +bool wxPCXHandler::DoCanRead( wxInputStream& stream ) { unsigned char c; - off_t pos; - pos = stream.TellI(); - stream.SeekI(0, wxFromStart); c = stream.GetC(); - stream.SeekI(pos, wxFromStart); + stream.SeekI(-1, wxFromCurrent); // not very safe, but this is all we can get from PCX header :-( return (c == 10); } - -#endif // wxUSE_STREAMS - +#endif // wxUSE_STREAMS && wxUSE_PCX