Anonymous user
Bitmap/Write a PPM file: Difference between revisions
added C
(New page: {{task|Raster graphics operations}} Using the data storage type defined on this page for raster images, write the image to a PPM file (binary P6 prefered). <BR> (...) |
(added C) |
||
Line 3:
Using the data storage type defined [[Basic_bitmap_storage|on this page]] for raster images, write the image to a PPM file (binary P6 prefered). <BR>
(Read [http://en.wikipedia.org/wiki/Netpbm_format the definition of PPM file] on Wikipedia.)
=={{header|C}}==
<C>#include <stdio.h>
void output_ppm(FILE *fd, image img)
{
unsigned int n;
fprintf(fd, "P6\n%d %d\n255\n", img->width, img->height);
n = img->width * img->height;
fwrite(img->buf, sizeof(pixel), n, fd);
fflush(fd);
}</C>
== {{Header|OCaml}} ==
|