1
0

upng.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. uPNG -- derived from LodePNG version 20100808
  3. Copyright (c) 2005-2010 Lode Vandevenne
  4. Copyright (c) 2010 Sean Middleditch
  5. This software is provided 'as-is', without any express or implied
  6. warranty. In no event will the authors be held liable for any damages
  7. arising from the use of this software.
  8. Permission is granted to anyone to use this software for any purpose,
  9. including commercial applications, and to alter it and redistribute it
  10. freely, subject to the following restrictions:
  11. 1. The origin of this software must not be misrepresented; you must not
  12. claim that you wrote the original software. If you use this software
  13. in a product, an acknowledgment in the product documentation would be
  14. appreciated but is not required.
  15. 2. Altered source versions must be plainly marked as such, and must not be
  16. misrepresented as being the original software.
  17. 3. This notice may not be removed or altered from any source
  18. distribution.
  19. */
  20. #if !defined(UPNG_H)
  21. #define UPNG_H
  22. typedef enum upng_error {
  23. UPNG_EOK = 0, /* success (no error) */
  24. UPNG_ENOMEM = 1, /* memory allocation failed */
  25. UPNG_ENOTFOUND = 2, /* resource not found (file missing) */
  26. UPNG_ENOTPNG = 3, /* image data does not have a PNG header */
  27. UPNG_EMALFORMED = 4, /* image data is not a valid PNG image */
  28. UPNG_EUNSUPPORTED = 5, /* critical PNG chunk type is not supported */
  29. UPNG_EUNINTERLACED = 6, /* image interlacing is not supported */
  30. UPNG_EUNFORMAT = 7, /* image color format is not supported */
  31. UPNG_EPARAM = 8 /* invalid parameter to method call */
  32. } upng_error;
  33. typedef enum upng_format {
  34. UPNG_BADFORMAT,
  35. UPNG_RGB8,
  36. UPNG_RGB16,
  37. UPNG_RGBA8,
  38. UPNG_RGBA16,
  39. UPNG_LUMINANCE1,
  40. UPNG_LUMINANCE2,
  41. UPNG_LUMINANCE4,
  42. UPNG_LUMINANCE8,
  43. UPNG_LUMINANCE_ALPHA1,
  44. UPNG_LUMINANCE_ALPHA2,
  45. UPNG_LUMINANCE_ALPHA4,
  46. UPNG_LUMINANCE_ALPHA8
  47. } upng_format;
  48. typedef struct upng_t upng_t;
  49. upng_t* upng_new_from_bytes (const unsigned char* buffer, unsigned long size);
  50. upng_t* upng_new_from_file (const char* path);
  51. void upng_free (upng_t* upng);
  52. upng_error upng_header (upng_t* upng);
  53. upng_error upng_decode (upng_t* upng);
  54. upng_error upng_get_error (const upng_t* upng);
  55. unsigned upng_get_error_line (const upng_t* upng);
  56. unsigned upng_get_width (const upng_t* upng);
  57. unsigned upng_get_height (const upng_t* upng);
  58. unsigned upng_get_bpp (const upng_t* upng);
  59. unsigned upng_get_bitdepth (const upng_t* upng);
  60. unsigned upng_get_components (const upng_t* upng);
  61. unsigned upng_get_pixelsize (const upng_t* upng);
  62. upng_format upng_get_format (const upng_t* upng);
  63. const unsigned char* upng_get_buffer (const upng_t* upng);
  64. unsigned upng_get_size (const upng_t* upng);
  65. #endif /*defined(UPNG_H)*/