X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/93dfff5ae6ff29195c441e3cd3b4637656e1f76f..b70ababc146a97e9f1b2afc0193f92fa6c202dd9:/src/common/imagpnm.cpp diff --git a/src/common/imagpnm.cpp b/src/common/imagpnm.cpp index e46916c549..d220042433 100644 --- a/src/common/imagpnm.cpp +++ b/src/common/imagpnm.cpp @@ -23,6 +23,8 @@ #include "wx/log.h" #include "wx/txtstrm.h" +#if wxUSE_PNM + #ifdef __WXMSW__ #include #endif @@ -37,7 +39,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPNMHandler,wxImageHandler) #if wxUSE_STREAMS - //#include // for cout +//#include // for cout void Skip_Comment(wxInputStream &stream) { @@ -64,10 +66,11 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSE * Read the PNM header */ - wxTextInputStream text_stream(stream); + wxBufferedInputStream buf_stream(stream); + wxTextInputStream text_stream(buf_stream); - Skip_Comment(stream); - if (stream.GetC()==_T('P')) c=stream.GetC(); + Skip_Comment(buf_stream); + if (buf_stream.GetC()==_T('P')) c=buf_stream.GetC(); switch (c) { @@ -84,12 +87,12 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSE } text_stream >> line; // for the \n - Skip_Comment(stream); + Skip_Comment(buf_stream); text_stream >> width >> height ; - Skip_Comment(stream); + Skip_Comment(buf_stream); text_stream >> maxval; - //cout << width << " " << height << " " << maxval << endl; + //cout << line << " " << width << " " << height << " " << maxval << endl; image->Create( width, height ); unsigned char *ptr = image->GetData(); if (!ptr) @@ -98,7 +101,7 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSE return FALSE; } - if (c=='3') // Ascii RBG + if (c=='3') // Ascii RBG { wxUint32 value, size=3*width*height; for (wxUint32 i=0; iSetMask( FALSE ); - return (stream.LastError()==wxStream_NOERROR || stream.LastError()==wxStream_EOF); + return (buf_stream.LastError()==wxStream_NOERROR || buf_stream.LastError()==wxStream_EOF); } bool wxPNMHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool WXUNUSED(verbose) ) @@ -157,4 +160,5 @@ bool wxPNMHandler::CanRead( wxInputStream& stream ) #endif // wxUSE_STREAMS +#endif // wxUSE_PNM