Binary files are much more flexible, and since each "row of data"
is
You lost me there: binary files are more flexible because
they're more rigid? You're confusing the unrelated concepts
of structure and encoding.
Easier to parse. If you have a bitmap where each row of pixels will
take up 256 bytes, you just have to add 256 to your current position to
move down a pixel. If we tried writing a bmp as a text file like below
(and I mean saved as ascii):
0 0 0 0 0 0 0 0 0 0
256 256 256 256 256 256 256 256 256 256
0 0 0 0 0 0 0 0 0 0
256 256 256 256 256 256 256 256 256 256
Then you're going to have to count the number of space ' ' characters
and end of line characters '\n' (maybe "\r\n") to find the next pixel
row and desired pixel. Then you will need to convert the ascii
characters '0' or '2''5''6' into a binary representation that your
computer understands. It will be a little bit easier if you save your
text file as:
000 000 000 000 000 000 000 000 000 000
256 256 256 256 256 256 256 256 256 256
000 000 000 000 000 000 000 000 000 000
256 256 256 256 256 256 256 256 256 256
as at least then you can use simple math to calculate the position of
the start of each ascii representation of the values.
Nonsense. As a trivial counter-example, consider UUencoded
data streams: entirely textual (and from a limited character
set at that), yet capable of representing any arbitrary bit
pattern.
You can represent any pattern using only hieroglyphs, that doesn't mean
that your program can just suck it in and go without extraneous
overhead.
For instance, one can do things like:
struct pixelData {
unsigned char r;
unsigned char g;
unsigned char b;
} myData[10][4];
read(fhandle, (char*)myData, sizeof(myData));
And have all of your data filled into your multidimensional array and
ready without a single ounce of conversion.
(Note that this may not be safe dependent on the source and kind of
data.)
UUEncode will first require that the text data is unencoded.
-Chris