[Mplayer-users] font bitmap format?

Christoph H. Lampert gruel at gmx.de
Tue Apr 10 20:13:41 CEST 2001

Am Mittwoch, 11. April 2001 02:54 schrieben Sie:
> > Actually you can write PGM-files (256 greyscales) with 2 lines of C:
> >
> > fprintf(file, "P5\n%d %d\n255\n", xsize, ysize);  // the header is easy
> > fwrite(data, xsize, ysize, file);		 // rest if plain data
> >
> > data has to be organized in usual order, like "english text is read"
> > as the man-page says. Works very well.
> Great! This is exactly what I want! Thanks a lot!
> I'll change today the font format to it. (maybe keep .raw support too?)

By the way, reading of not selfmade PGM is a little little more difficult, 
because the number of whitespaces is allowed to vary. I myself never had 
problems with simple fscanfs followed by fread of data. 
There is a manpage which says: 

> Each PGM image consists of the following:
       - A "magic number" for identifying the file type.   A  pgm
         file's magic number is the two characters "P5".

       - Whitespace (blanks, TABs, CRs, LFs).
       - A width, formatted as ASCII characters in decimal.
       - Whitespace.
       - A height, again in ASCII decimal.
       - Whitespace.
       - The maximum gray value (Maxval), again in ASCII decimal.
         Must be less than 65536.
       - Newline or other single whitespace character.
       - A raster of  Width  *  Height  gray  values,  proceeding
         through the image in normal English reading order.  Each
         gray value is a number from 0  through  Maxval,  with  0
         being  black and Maxval being white.  Each gray value is
         represented in pure binary by either 1 or 2  bytes.   If
         the  Maxval  is less than 256, it is 1 byte.  Otherwise,
         it is 2 bytes.  The most significant byte is first.
       - Characters from a "#" to the  next  end-of-line,  before
         the maxval line, are comments and are ignored.


Mplayer-users mailing list
Mplayer-users at lists.sourceforge.net

More information about the MPlayer-users mailing list