char Peek() { return m_parent_i_stream->Peek(); }
- wxStreamError LastError() const { return m_parent_i_stream->LastError(); }
size_t GetSize() const { return m_parent_i_stream->GetSize(); }
protected:
wxFilterOutputStream(wxOutputStream& stream);
~wxFilterOutputStream();
- wxStreamError LastError() const { return m_parent_o_stream->LastError(); }
size_t GetSize() const { return m_parent_o_stream->GetSize(); }
protected:
size_t Write(const void *buffer, size_t size);
size_t Write(wxStreamBuffer *buf);
+ char Peek();
char GetChar();
void PutChar(char c);
off_t Tell() const;
wxBufferedInputStream(wxInputStream& stream);
~wxBufferedInputStream();
+ char Peek();
wxInputStream& Read(void *buffer, size_t size);
// Position functions
wxBitmap *my_horse_gif;
wxBitmap *my_horse_bmp;
wxBitmap *my_horse_pcx;
+ wxBitmap *my_horse_pnm;
wxBitmap *my_square;
wxBitmap *my_anti;
wxLogError("Can't load BMP image");
else
my_horse_bmp = new wxBitmap( image.ConvertToBitmap() );
+
+ if ( !image.LoadFile( dir + wxString("horse.pnm"), wxBITMAP_TYPE_PNM ) )
+ wxLogError("Can't load PNM image");
+ else
+ my_horse_pnm = new wxBitmap( image.ConvertToBitmap() );
image.LoadFile( dir + wxString("test.png") );
my_square = new wxBitmap( image.ConvertToBitmap() );
MyCanvas::~MyCanvas()
{
+ delete my_horse_pnm;
delete my_horse_png;
delete my_horse_jpeg;
delete my_horse_gif;
dc.DrawText( "BMP handler", 30, 1055 );
if (my_horse_bmp && my_horse_bmp->Ok()) dc.DrawBitmap( *my_horse_bmp, 30, 1070 );
+
+ dc.DrawText( "PNM handler", 30, 1285 );
+ if (my_horse_pnm && my_horse_pnm->Ok()) dc.DrawBitmap( *my_horse_pnm, 30, 1300 );
}
void MyCanvas::CreateAntiAliasedBitmap()
m_canvas = new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) );
// 500 width * 1300 height
- m_canvas->SetScrollbars( 10, 10, 50, 130 );
+ m_canvas->SetScrollbars( 10, 10, 50, 152 );
}
void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )
wxImage::AddHandler( new wxGIFHandler );
wxImage::AddHandler( new wxPCXHandler );
+ wxImage::AddHandler( new wxPNMHandler );
wxFrame *frame = new MyFrame();
frame->Show( TRUE );
* 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)
{
}
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;
return FALSE;
}
- wxBufferedInputStream buf_stream(stream);
-
if (c=='3') // Ascii RBG
{
wxUint32 value, size=3*width*height;
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;
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 {
delete m_i_streambuf;
}
+char wxBufferedInputStream::Peek()
+{
+ return m_i_streambuf->Peek();
+}
+
wxInputStream& wxBufferedInputStream::Read(void *buffer, size_t size)
{
size_t retsize;