Advertisement
Guest User

PNG I/O header

a guest
Jan 29th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. /*******************************************************************************
  2. *
  3. * png_rgba.h : PNG file I/O in (8) bits per channel RGBA format:
  4. *
  5. * Copyright (c) Brett Hale 2008, 2012. Public Domain.
  6. *
  7. *******************************************************************************/
  8.  
  9.  
  10. #ifndef _PNG_RGBA_H
  11. #define _PNG_RGBA_H
  12.  
  13. #if defined (__cplusplus) /* ISO C declaration scope: */
  14.  
  15. #define _PNG_RGBA_INIT_DECL extern "C" {
  16. #define _PNG_RGBA_FINI_DECL }
  17.  
  18. #else
  19.  
  20. #define _PNG_RGBA_INIT_DECL
  21. #define _PNG_RGBA_FINI_DECL
  22.  
  23. #endif /* defined (__cplusplus) */
  24.  
  25.  
  26. #include <stddef.h>
  27. #include <stdlib.h>
  28.  
  29. #include <stdio.h> /* ISO C : standard I/O library. */
  30.  
  31.  
  32. _PNG_RGBA_INIT_DECL
  33.  
  34.  
  35. /******************************************************************************/
  36.  
  37. /* load a PNG image using an opened file stream. return the image data
  38. * as a (malloc) allocated RGBA image buffer, with the width: (w), and
  39. * height: (h). return (0) on success: */
  40.  
  41. /* if the operation fails, then the dimensions are set to (0), and the
  42. * buffer is set to (NULL). */
  43.  
  44. /* the operation fails if the image has zero area, or if the number of
  45. * pixels exceeds PNG_RGBA_PIXEL_LIMIT. */
  46.  
  47. /* asserts that 'unsigned int' has a width of at least 32 bits. */
  48.  
  49.  
  50. #define PNG_RGBA_PIXEL_LIMIT (0x1000000)
  51.  
  52. int png_rgba_load (FILE *, unsigned *w, unsigned *h, unsigned char **);
  53.  
  54.  
  55. /******************************************************************************/
  56.  
  57. /* save an RGBA image buffer, with the width: (w), and height: (h), as
  58. * a PNG image, using an opened file stream. return (0) on success: */
  59.  
  60. /* the operation fails if the image has zero area, or if the number of
  61. * pixels exceeds PNG_RGBA_PIXEL_LIMIT. */
  62.  
  63. /* asserts that 'unsigned int' has a width of at least 32 bits. */
  64.  
  65.  
  66. int png_rgba_save (FILE *, unsigned w, unsigned h, const unsigned char *);
  67.  
  68.  
  69. /******************************************************************************/
  70.  
  71.  
  72. _PNG_RGBA_FINI_DECL
  73.  
  74.  
  75. #endif /* _PNG_RGBA_H */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement