An LGPL/GPL-licensed artwork library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

art_pixbuf.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* Libart_LGPL - library of basic graphic primitives
  2. * Copyright (C) 1998 Raph Levien
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17. * Boston, MA 02111-1307, USA.
  18. */
  19. #ifndef __ART_PIXBUF_H__
  20. #define __ART_PIXBUF_H__
  21. /* A generic data structure for holding a buffer of pixels. One way
  22. to think about this module is as a virtualization over specific
  23. pixel buffer formats. */
  24. #ifdef LIBART_COMPILATION
  25. #include "art_config.h"
  26. #include "art_misc.h"
  27. #else
  28. #include <libart_lgpl/art_config.h>
  29. #include <libart_lgpl/art_misc.h>
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. typedef void (*ArtDestroyNotify) (void *func_data, void *data);
  35. typedef struct _ArtPixBuf ArtPixBuf;
  36. typedef enum {
  37. ART_PIX_RGB
  38. /* gray, cmyk, lab, ... ? */
  39. } ArtPixFormat;
  40. /* The pixel buffer consists of width * height pixels, each of which
  41. has n_channels samples. It is stored in simple packed format. */
  42. struct _ArtPixBuf {
  43. /*< public >*/
  44. ArtPixFormat format;
  45. int n_channels;
  46. int has_alpha;
  47. int bits_per_sample;
  48. art_u8 *pixels;
  49. int width;
  50. int height;
  51. int rowstride;
  52. void *destroy_data;
  53. ArtDestroyNotify destroy;
  54. };
  55. /* allocate an ArtPixBuf from art_alloc()ed pixels (automated destruction) */
  56. LIBART_EXPORT ArtPixBuf *
  57. art_pixbuf_new_rgb (art_u8 *pixels, int width, int height, int rowstride);
  58. LIBART_EXPORT ArtPixBuf *
  59. art_pixbuf_new_rgba (art_u8 *pixels, int width, int height, int rowstride);
  60. /* allocate an ArtPixBuf from constant pixels (no destruction) */
  61. LIBART_EXPORT ArtPixBuf *
  62. art_pixbuf_new_const_rgb (const art_u8 *pixels, int width, int height, int rowstride);
  63. LIBART_EXPORT ArtPixBuf *
  64. art_pixbuf_new_const_rgba (const art_u8 *pixels, int width, int height, int rowstride);
  65. /* allocate an ArtPixBuf and notify creator upon destruction */
  66. LIBART_EXPORT ArtPixBuf *
  67. art_pixbuf_new_rgb_dnotify (art_u8 *pixels, int width, int height, int rowstride,
  68. void *dfunc_data, ArtDestroyNotify dfunc);
  69. LIBART_EXPORT ArtPixBuf *
  70. art_pixbuf_new_rgba_dnotify (art_u8 *pixels, int width, int height, int rowstride,
  71. void *dfunc_data, ArtDestroyNotify dfunc);
  72. /* free an ArtPixBuf with destroy notification */
  73. LIBART_EXPORT void
  74. art_pixbuf_free (ArtPixBuf *pixbuf);
  75. /* deprecated function, use the _dnotify variants for allocation instead */
  76. LIBART_EXPORT void
  77. art_pixbuf_free_shallow (ArtPixBuf *pixbuf);
  78. LIBART_EXPORT ArtPixBuf *
  79. art_pixbuf_duplicate (const ArtPixBuf *pixbuf);
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83. #endif