Commit 0adfd622 authored by Tim Janik's avatar Tim Janik

+Fri Jul 16 23:03:26 1999 Tim Janik <timj@gtk.org>

+
+       * art_pixbuf.[hc]: deprecated art_pixbuf_free_shallow(), people should
+       always free pixbufs with art_pixbuf_free() and use the _dnotify variants
+       for specific destruction behaviour.
+       added art_pixbuf_new_rgb_dnotify() and art_pixbuf_new_rgba_dnotify()
+       which allow for a destruction notification function. (this involved
+       adding two extra pointers to the ArtPixBuf structure, and removal of
+       the recently introduced int flags field).
+
+Mon Jul 12 01:13:23 1999  Tim Janik  <timj@gtk.org>
+
+       * art_affine.[hc]: added art_affine_equal(), which checks two
+       matrixes for equality within grid alignment.
+
+Fri Jul  9 17:50:19 1999  Tim Janik  <timj@gtk.org>
+
+       * art_affine.[hc]: added art_affine_flip() to flip a matrix horizontally
+       and/or vertically, or just copy it.
+       added art_affine_shear() to setup a shearing matrix.
+
parent 8d06b650
Fri Jul 16 23:03:26 1999 Tim Janik <timj@gtk.org>
* art_pixbuf.[hc]: deprecated art_pixbuf_free_shallow(), people should
always free pixbufs with art_pixbuf_free() and use the _dnotify variants
for specific destruction behaviour.
added art_pixbuf_new_rgb_dnotify() and art_pixbuf_new_rgba_dnotify()
which allow for a destruction notification function. (this involved
adding two extra pointers to the ArtPixBuf structure, and removal of
the recently introduced int flags field).
Mon Jul 12 01:13:23 1999 Tim Janik <timj@gtk.org>
* art_affine.[hc]: added art_affine_equal(), which checks two
matrixes for equality within grid alignment.
Fri Jul 9 17:50:19 1999 Tim Janik <timj@gtk.org>
* art_affine.[hc]: added art_affine_flip() to flip a matrix horizontally
and/or vertically, or just copy it.
added art_affine_shear() to setup a shearing matrix.
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
......
......@@ -59,6 +59,18 @@ art_affine_invert (double dst[6], const double src[6])
dst[5] = -src[4] * dst[1] - src[5] * dst[3];
}
/* flip the matrix, FALSE, FALSE is a simple copy operation, and
TRUE, TRUE equals a rotation by 180 degrees */
void
art_affine_flip (double dst_affine[6], const double src_affine[6], int horz, int vert)
{
dst_affine[0] = horz ? - src_affine[0] : src_affine[0];
dst_affine[1] = horz ? - src_affine[1] : src_affine[1];
dst_affine[2] = vert ? - src_affine[2] : src_affine[2];
dst_affine[3] = vert ? - src_affine[3] : src_affine[3];
dst_affine[4] = src_affine[4];
dst_affine[5] = src_affine[5];
}
#define EPSILON 1e-6
......@@ -274,6 +286,21 @@ art_affine_rotate (double dst[6], double theta)
dst[5] = 0;
}
/* set up a shearing matrix; theta is given in degrees */
void
art_affine_shear (double dst[6], double theta)
{
double t;
t = tan (theta * M_PI / 180.0);
dst[0] = 1;
dst[1] = 0;
dst[2] = t;
dst[3] = 1;
dst[4] = 0;
dst[5] = 0;
}
/* set up a translation matrix */
void
art_affine_translate (double dst[6], double tx, double ty)
......@@ -290,8 +317,6 @@ art_affine_translate (double dst[6], double tx, double ty)
double
art_affine_expansion (const double src[6])
{
double r_det;
return sqrt (src[0] * src[3] - src[1] * src[2]);
}
......@@ -304,3 +329,15 @@ art_affine_rectilinear (const double src[6])
return ((fabs (src[1]) < EPSILON && fabs (src[2]) < EPSILON) ||
(fabs (src[0]) < EPSILON && fabs (src[3]) < EPSILON));
}
/* Determine whether two affine transformations are equal within grid allignment */
int
art_affine_equal (double matrix1[6], double matrix2[6])
{
return (fabs (matrix1[0] - matrix2[0]) < EPSILON &&
fabs (matrix1[1] - matrix2[1]) < EPSILON &&
fabs (matrix1[2] - matrix2[2]) < EPSILON &&
fabs (matrix1[3] - matrix2[3]) < EPSILON &&
fabs (matrix1[4] - matrix2[4]) < EPSILON &&
fabs (matrix1[5] - matrix2[5]) < EPSILON);
}
......@@ -33,6 +33,12 @@ art_affine_point (ArtPoint *dst, const ArtPoint *src,
void
art_affine_invert (double dst_affine[6], const double src_affine[6]);
/* flip the matrix, FALSE, FALSE is a simple copy operation, and
TRUE, TRUE equals a rotation by 180 degrees */
void
art_affine_flip (double dst_affine[6], const double src_affine[6],
int horz, int vert);
void
art_affine_to_string (char str[128], const double src[6]);
......@@ -52,10 +58,15 @@ art_affine_scale (double dst[6], double sx, double sy);
void
art_affine_rotate (double dst[6], double theta);
/* set up a shearing matrix; theta is given in degrees */
void
art_affine_shear (double dst[6], double theta);
/* set up a translation matrix */
void
art_affine_translate (double dst[6], double tx, double ty);
/* find the affine's "expansion factor", i.e. the scale amount */
double
art_affine_expansion (const double src[6]);
......@@ -66,6 +77,11 @@ art_affine_expansion (const double src[6]);
int
art_affine_rectilinear (const double src[6]);
/* Determine whether two affine transformations are equal within grid allignment */
int
art_affine_equal (double matrix1[6], double matrix2[6]);
#ifdef __cplusplus
}
#endif /* __cplusplus */
......
......@@ -20,14 +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_const_rgb (const art_u8 *pixels, int width, int height, int rowstride)
art_pixbuf_new_rgb_dnotify (art_u8 *pixels, int width, int height, int rowstride,
void *dfunc_data, ArtDestroyNotify dfunc)
{
ArtPixBuf *pixbuf;
......@@ -42,13 +42,15 @@ art_pixbuf_new_const_rgb (const art_u8 *pixels, int width, int height, int rowst
pixbuf->width = width;
pixbuf->height = height;
pixbuf->rowstride = rowstride;
pixbuf->flags = 0;
pixbuf->destroy_data = dfunc_data;
pixbuf->destroy = dfunc;
return pixbuf;
}
ArtPixBuf *
art_pixbuf_new_const_rgba (const art_u8 *pixels, int width, int height, int rowstride)
art_pixbuf_new_rgba_dnotify (art_u8 *pixels, int width, int height, int rowstride,
void *dfunc_data, ArtDestroyNotify dfunc)
{
ArtPixBuf *pixbuf;
......@@ -63,43 +65,61 @@ art_pixbuf_new_const_rgba (const art_u8 *pixels, int width, int height, int rows
pixbuf->width = width;
pixbuf->height = height;
pixbuf->rowstride = rowstride;
pixbuf->flags = 0;
pixbuf->destroy_data = dfunc_data;
pixbuf->destroy = dfunc;
return pixbuf;
}
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;
return art_pixbuf_new_rgb_dnotify ((art_u8 *) pixels, width, height, rowstride, NULL, NULL);
}
pixbuf = art_pixbuf_new_const_rgb (pixels, width, height, rowstride);
pixbuf->flags |= PIXBUF_FLAG_DESTROY_PIXELS;
ArtPixBuf *
art_pixbuf_new_const_rgba (const art_u8 *pixels, int width, int height, int rowstride)
{
return art_pixbuf_new_rgba_dnotify ((art_u8 *) pixels, width, height, rowstride, NULL, NULL);
}
return pixbuf;
static void
art_pixel_destroy (void *func_data, void *data)
{
art_free (data);
}
ArtPixBuf *
art_pixbuf_new_rgba (art_u8 *pixels, int width, int height, int rowstride)
art_pixbuf_new_rgb (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 art_pixbuf_new_rgb_dnotify (pixels, width, height, rowstride, NULL, art_pixel_destroy);
}
return pixbuf;
ArtPixBuf *
art_pixbuf_new_rgba (art_u8 *pixels, int width, int height, int rowstride)
{
return art_pixbuf_new_rgba_dnotify (pixels, width, height, rowstride, NULL, art_pixel_destroy);
}
/* Warning: if you call this function, make sure the pixels were
allocated with art_alloc. */
/* free an ArtPixBuf with destroy notification */
void
art_pixbuf_free (ArtPixBuf *pixbuf)
{
if ((pixbuf->flags & PIXBUF_FLAG_DESTROY_PIXELS) && pixbuf->pixels)
art_free (pixbuf->pixels);
ArtDestroyNotify destroy = pixbuf->destroy;
void *destroy_data = pixbuf->destroy_data;
art_u8 *pixels = pixbuf->pixels;
pixbuf->pixels = NULL;
pixbuf->destroy = NULL;
pixbuf->destroy_data = NULL;
if (destroy)
destroy (destroy_data, pixels);
art_free (pixbuf);
}
/* deprecated function, use the _dnotify variants for allocation instead */
void
art_pixbuf_free_shallow (ArtPixBuf *pixbuf)
{
......
......@@ -28,6 +28,9 @@
extern "C" {
#endif
typedef void (*ArtDestroyNotify) (void *func_data, void *data);
typedef struct _ArtPixBuf ArtPixBuf;
typedef enum {
......@@ -49,24 +52,38 @@ struct _ArtPixBuf {
int width;
int height;
int rowstride;
int flags;
void *destroy_data;
ArtDestroyNotify destroy;
};
/* allocate an ArtPixBuf from art_alloc()ed pixels (automated destruction) */
ArtPixBuf *
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);
/* allocate an ArtPixBuf from constant pixels (no destruction) */
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);
/* allocate an ArtPixBuf and notify creator upon destruction */
ArtPixBuf *
art_pixbuf_new_rgb_dnotify (art_u8 *pixels, int width, int height, int rowstride,
void *dfunc_data, ArtDestroyNotify dfunc);
ArtPixBuf *
art_pixbuf_new_rgba_dnotify (art_u8 *pixels, int width, int height, int rowstride,
void *dfunc_data, ArtDestroyNotify dfunc);
/* free an ArtPixBuf with destroy notification */
void
art_pixbuf_free (ArtPixBuf *pixbuf);
/* deprecated function, use the _dnotify variants for allocation instead */
void
art_pixbuf_free_shallow (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