[Mono-dev] PPM image

Miguel de Icaza miguel at ximian.com
Tue Dec 13 11:15:48 EST 2005


> - Currently I am trying to read the PPM file with "BinaryReader"
> class. But "ReadInt32()" method of this calss is not working an
> returning garbage, other methods such as "PeekChar()" or "ReadChar()"
> works fine with out problem!!! Can any one tell me whats going on
> here ???

The major issue is that BinaryReader is not a general purpose
binary-reading class, it is instead just half the implementation of a
minimalistic framework to handle binary files.

This means that BinaryReader.ReadInt32 has its endianess hardcoded by
design.  You can only read int32s from binary blobs that were produced
by BinaryWriter.

A general purpose binary reading/writing library would be a great
addition to Mono.

More information about the Mono-devel-list mailing list