| 1 | {{{ |
| 2 | /******************************************************************** |
| 3 | gmap: image structure, greyscale pixels. |
| 4 | The width field contains the width of the image, |
| 5 | - The height field contains the height of the image, |
| 6 | - The raster pointer points to a memory area containing |
| 7 | the image pixel, 8 bits per pixel, 0 is black, 255 is white. |
| 8 | The (0,0) coordinate is the upper left corner of the image, and |
| 9 | its address is raster. The (1,0) coordinate is at address raster + 1. |
| 10 | The (0,1) coordinate is at address raster + width. |
| 11 | **********************************************************************/ |
| 12 | typedef struct gmap { |
| 13 | short width; |
| 14 | short height; |
| 15 | unsigned char *raster; |
| 16 | } gmap; |
| 17 | |
| 18 | /********************************************************************* |
| 19 | readpgm() |
| 20 | This function reads the pgmfile whose name is given as argument |
| 21 | and creates a gmap structure filled with the image. |
| 22 | This function allocate the memory requested to store the image. |
| 23 | If either the file cannot be opened or not enough memory |
| 24 | remains readpgm returns NULL |
| 25 | **********************************************************************/ |
| 26 | extern gmap *readpgm(char *name); |
| 27 | |
| 28 | /********************************************************************* |
| 29 | writepgm: |
| 30 | This function writes the gmap map into the file whose name is |
| 31 | given as argument. |
| 32 | If the file cannot be opened, writepgm returns NULL. |
| 33 | **********************************************************************/ |
| 34 | extern int writepgm(gmap *map, char *name); |
| 35 | }}} |