Bitmap/Read a PPM file: Difference between revisions

→‎{{header|C}}: completed the task
(C)
(→‎{{header|C}}: completed the task)
Line 131:
return img;
}
}</c>
 
The following acts as a filter to convert a PPM file read from standard input into a PPM gray image, and it outputs the converted image to standard output (see [[Grayscale image]], [[Write ppm file]], and [[Raster graphics operations]] in general):
 
<c>#include <stdio.h>
/* #include "imglib.h" */
 
int main()
{
image source;
grayimage idest;
source = get_ppm(stdin);
idest = tograyscale(source);
free_img(source);
source = tocolor(idest);
output_ppm(stdout, source);
free_img(source); free_img((image)idest);
return 0;
}</c>