Removed LastError() from wxFilterStream
Added a better Peek() to wxBufferedInputStream Fixed wxPNMHandler (it is a lot faster on text PNM now) Image sample loads a PNM git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3525 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -64,10 +64,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,9 +85,9 @@ 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 << line << " " << width << " " << height << " " << maxval << endl;
|
||||
@@ -98,8 +99,6 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSE
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wxBufferedInputStream buf_stream(stream);
|
||||
|
||||
if (c=='3') // Ascii RBG
|
||||
{
|
||||
wxUint32 value, size=3*width*height;
|
||||
|
@@ -195,6 +195,23 @@ void wxStreamBuffer::PutChar(char c)
|
||||
m_stream->m_lastcount = 1;
|
||||
}
|
||||
|
||||
char wxStreamBuffer::Peek()
|
||||
{
|
||||
char c;
|
||||
|
||||
wxASSERT(m_stream != NULL && m_buffer_size != 0);
|
||||
|
||||
if (!GetDataLeft()) {
|
||||
CHECK_ERROR(wxStream_READ_ERR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetFromBuffer(&c, 1);
|
||||
m_buffer_pos--;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
char wxStreamBuffer::GetChar()
|
||||
{
|
||||
char c;
|
||||
@@ -248,7 +265,7 @@ size_t wxStreamBuffer::Read(void *buffer, size_t size)
|
||||
buffer = (char *)buffer + buf_left; // ANSI C++ violation.
|
||||
|
||||
if (!FillBuffer()) {
|
||||
CHECK_ERROR(wxStream_READ_ERR);
|
||||
CHECK_ERROR(wxStream_EOF);
|
||||
return (m_stream->m_lastcount = orig_size-size);
|
||||
}
|
||||
} else {
|
||||
@@ -743,6 +760,11 @@ wxBufferedInputStream::~wxBufferedInputStream()
|
||||
delete m_i_streambuf;
|
||||
}
|
||||
|
||||
char wxBufferedInputStream::Peek()
|
||||
{
|
||||
return m_i_streambuf->Peek();
|
||||
}
|
||||
|
||||
wxInputStream& wxBufferedInputStream::Read(void *buffer, size_t size)
|
||||
{
|
||||
size_t retsize;
|
||||
|
Reference in New Issue
Block a user