Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // gcc <file>.c -lpng; ./a.out < VhGrd.png > out.png
- #include <stdlib.h> // malloc, EXIT_*
- #include <string.h> // memset
- #include <png.h>
- #define EXIT_PNG(F) if (!F) { \
- fprintf(stderr, "%s\n", img.message); \
- return EXIT_FAILURE; \
- }
- int main(int argc, char **args)
- {
- png_image img;
- memset(&img, 0, sizeof(img));
- img.version = PNG_IMAGE_VERSION;
- EXIT_PNG(png_image_begin_read_from_stdio(&img, stdin))
- void *pixels = malloc(img.width * img.height * 4);
- EXIT_PNG(png_image_finish_read(&img, NULL, pixels, 0, NULL))
- EXIT_PNG(png_image_write_to_stdio(&img, stdout, 0, pixels, 0, NULL));
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement