Commit 8d06b650 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

added an int flags; member to the end of the structure, it currently only

Tue Jul  6 19:03:39 1999  Tim Janik  <timj@gtk.org>

        * art_pixbuf.h: added an int flags; member to the end of the
        structure, it currently only holds information about whether the
        pixels member should be freed. (raph: i think flags is more generic
        than free_pixels, so we can reuse that field if further demands popup
        in the future).

        * art_pixbuf.c:
        (art_pixbuf_new_const_rgba):
        (art_pixbuf_new_const_rgb): new functions that prevent the pixels
        member from being freed upon art_pixbuf_free ().
        (art_pixbuf_free): only free the pixels member if it is non-NULL and
        the PIXBUF_FLAG_DESTROY_PIXELS is set.
parent a73d640b
Tue Jul 6 19:03:39 1999 Tim Janik <timj@gtk.org>
* art_pixbuf.h: added an int flags; member to the end of the
structure, it currently only holds information about whether the
pixels member should be freed. (raph: i think flags is more generic
than free_pixels, so we can reuse that field if further demands popup
in the future).
* art_pixbuf.c:
(art_pixbuf_new_const_rgba):
(art_pixbuf_new_const_rgb): new functions that prevent the pixels
member from being freed upon art_pixbuf_free ().
(art_pixbuf_free): only free the pixels member if it is non-NULL and
the PIXBUF_FLAG_DESTROY_PIXELS is set.
1999-07-02 Raph Levien <raph@gimp.org>
* art_vpath_bpath.c (art_vpath_render_bez): Bad bad uninitialized
......
......@@ -20,12 +20,14 @@
#include "art_misc.h"
#include "art_pixbuf.h"
#define PIXBUF_FLAG_DESTROY_PIXELS 1
/* A generic data structure for holding a buffer of pixels. One way
to think about this module is as a virtualization over specific
pixel buffer formats. */
ArtPixBuf *
art_pixbuf_new_rgb (art_u8 *pixels, int width, int height, int rowstride)
art_pixbuf_new_const_rgb (const art_u8 *pixels, int width, int height, int rowstride)
{
ArtPixBuf *pixbuf;
......@@ -36,16 +38,17 @@ art_pixbuf_new_rgb (art_u8 *pixels, int width, int height, int rowstride)
pixbuf->has_alpha = 0;
pixbuf->bits_per_sample = 8;
pixbuf->pixels = pixels;
pixbuf->pixels = (art_u8 *) pixels;
pixbuf->width = width;
pixbuf->height = height;
pixbuf->rowstride = rowstride;
pixbuf->flags = 0;
return pixbuf;
}
ArtPixBuf *
art_pixbuf_new_rgba (art_u8 *pixels, int width, int height, int rowstride)
art_pixbuf_new_const_rgba (const art_u8 *pixels, int width, int height, int rowstride)
{
ArtPixBuf *pixbuf;
......@@ -56,10 +59,33 @@ art_pixbuf_new_rgba (art_u8 *pixels, int width, int height, int rowstride)
pixbuf->has_alpha = 1;
pixbuf->bits_per_sample = 8;
pixbuf->pixels = pixels;
pixbuf->pixels = (art_u8 *) pixels;
pixbuf->width = width;
pixbuf->height = height;
pixbuf->rowstride = rowstride;
pixbuf->flags = 0;
return pixbuf;
}
ArtPixBuf *
art_pixbuf_new_rgb (art_u8 *pixels, int width, int height, int rowstride)
{
ArtPixBuf *pixbuf;
pixbuf = art_pixbuf_new_const_rgb (pixels, width, height, rowstride);
pixbuf->flags |= PIXBUF_FLAG_DESTROY_PIXELS;
return pixbuf;
}
ArtPixBuf *
art_pixbuf_new_rgba (art_u8 *pixels, int width, int height, int rowstride)
{
ArtPixBuf *pixbuf;
pixbuf = art_pixbuf_new_const_rgba (pixels, width, height, rowstride);
pixbuf->flags |= PIXBUF_FLAG_DESTROY_PIXELS;
return pixbuf;
}
......@@ -69,7 +95,8 @@ art_pixbuf_new_rgba (art_u8 *pixels, int width, int height, int rowstride)
void
art_pixbuf_free (ArtPixBuf *pixbuf)
{
art_free (pixbuf->pixels);
if ((pixbuf->flags & PIXBUF_FLAG_DESTROY_PIXELS) && pixbuf->pixels)
art_free (pixbuf->pixels);
art_free (pixbuf);
}
......
......@@ -49,6 +49,7 @@ struct _ArtPixBuf {
int width;
int height;
int rowstride;
int flags;
};
ArtPixBuf *
......@@ -57,6 +58,12 @@ art_pixbuf_new_rgb (art_u8 *pixels, int width, int height, int rowstride);
ArtPixBuf *
art_pixbuf_new_rgba (art_u8 *pixels, int width, int height, int rowstride);
ArtPixBuf *
art_pixbuf_new_const_rgb (const art_u8 *pixels, int width, int height, int rowstride);
ArtPixBuf *
art_pixbuf_new_const_rgba (const art_u8 *pixels, int width, int height, int rowstride);
void
art_pixbuf_free (ArtPixBuf *pixbuf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment