summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>1999-10-28 19:00:02 +0000
committerJonathan Blandford <jrb@src.gnome.org>1999-10-28 19:00:02 +0000
commit9a1c50c961e6313f2f3ef23807b13f8e346b0da5 (patch)
treecf9c7cb13aac316ccea58c1ba369c74d90e34470
parent0a810f950f062980a6f761e4355443ba2777bb61 (diff)
downloadgtk+-9a1c50c961e6313f2f3ef23807b13f8e346b0da5.tar.gz
turned convenience macros into convenience
1999-10-28 Jonathan Blandford <jrb@redhat.com> * src/gdk-pixbuf.h: turned convenience macros into convenience
-rw-r--r--gdk-pixbuf/ChangeLog3
-rw-r--r--gdk-pixbuf/gdk-pixbuf.c75
-rw-r--r--gdk-pixbuf/gdk-pixbuf.h19
3 files changed, 88 insertions, 9 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index a33d855380..d01c3ef443 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,5 +1,8 @@
1999-10-28 Jonathan Blandford <jrb@redhat.com>
+ * src/gdk-pixbuf.h: turned convenience macros into convenience
+ functions so some error checking could be added.
+
* src/io-tiff.c (image_load_increment): started work on the tiff
non-incremental loader.
(image_begin_load): Finished the incremental loader.
diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c
index 4aacd3b171..cc0d841291 100644
--- a/gdk-pixbuf/gdk-pixbuf.c
+++ b/gdk-pixbuf/gdk-pixbuf.c
@@ -147,3 +147,78 @@ gdk_pixbuf_new (ArtPixFormat format, gboolean has_alpha, int bits_per_sample,
return gdk_pixbuf_new_from_data (buf, format, has_alpha, width, height, rowstride,
free_buffer, NULL);
}
+
+
+/* Convenience functions */
+ArtPixFormat
+gdk_pixbuf_get_format (GdkPixbuf *pixbuf)
+{
+ /* Unfortunately, there's nothing else to return */
+ g_return_val_if_fail (pixbuf != NULL, ART_PIX_RGB);
+ g_assert (pixbuf->art_pixbuf != NULL);
+
+ return (pixbuf->art_pixbuf->format);
+}
+
+int
+gdk_pixbuf_get_n_channels (GdkPixbuf *pixbuf)
+{
+ g_return_val_if_fail (pixbuf != NULL, -1);
+ g_assert (pixbuf->art_pixbuf != NULL);
+
+ return (pixbuf->art_pixbuf->n_channels);
+}
+
+int
+gdk_pixbuf_get_has_alpha (GdkPixbuf *pixbuf)
+{
+ g_return_val_if_fail (pixbuf != NULL, -1);
+ g_assert (pixbuf->art_pixbuf != NULL);
+
+ return (pixbuf->art_pixbuf->has_alpha);
+}
+
+int
+gdk_pixbuf_get_bits_per_sample (GdkPixbuf *pixbuf)
+{
+ g_return_val_if_fail (pixbuf != NULL, -1);
+ g_assert (pixbuf->art_pixbuf != NULL);
+
+ return (pixbuf->art_pixbuf->bits_per_sample);
+}
+
+guchar *
+gdk_pixbuf_get_pixels (GdkPixbuf *pixbuf)
+{
+ g_return_val_if_fail (pixbuf != NULL, NULL);
+ g_assert (pixbuf->art_pixbuf != NULL);
+
+ return (pixbuf->art_pixbuf->pixels);
+}
+
+int
+gdk_pixbuf_get_width (GdkPixbuf *pixbuf)
+{
+ g_return_val_if_fail (pixbuf != NULL, -1);
+ g_assert (pixbuf->art_pixbuf != NULL);
+
+ return (pixbuf->art_pixbuf->width);
+}
+
+int
+gdk_pixbuf_get_height (GdkPixbuf *pixbuf)
+{
+ g_return_val_if_fail (pixbuf != NULL, -1);
+ g_assert (pixbuf->art_pixbuf != NULL);
+
+ return (pixbuf->art_pixbuf->height);
+}
+
+int
+gdk_pixbuf_get_rowstride (GdkPixbuf *pixbuf)
+{
+ g_return_val_if_fail (pixbuf != NULL, -1);
+ g_assert (pixbuf->art_pixbuf != NULL);
+
+ return (pixbuf->art_pixbuf->rowstride);
+}
diff --git a/gdk-pixbuf/gdk-pixbuf.h b/gdk-pixbuf/gdk-pixbuf.h
index e05cc1838d..5e517c070d 100644
--- a/gdk-pixbuf/gdk-pixbuf.h
+++ b/gdk-pixbuf/gdk-pixbuf.h
@@ -50,22 +50,23 @@ struct _GdkPixbuf {
-/* Convenience macros */
+/* Convenience functions */
-#define gdk_pixbuf_get_format(pixbuf) ((pixbuf)->art_pixbuf->format)
-#define gdk_pixbuf_get_n_channels(pixbuf) ((pixbuf)->art_pixbuf->n_channels)
-#define gdk_pixbuf_get_has_alpha(pixbuf) ((pixbuf)->art_pixbuf->has_alpha)
-#define gdk_pixbuf_get_bits_per_sample(pixbuf) ((pixbuf)->art_pixbuf->bits_per_sample)
-#define gdk_pixbuf_get_pixels(pixbuf) ((pixbuf)->art_pixbuf->pixels)
-#define gdk_pixbuf_get_width(pixbuf) ((pixbuf)->art_pixbuf->width)
-#define gdk_pixbuf_get_height(pixbuf) ((pixbuf)->art_pixbuf->height)
-#define gdk_pixbuf_get_rowstride(pixbuf) ((pixbuf)->art_pixbuf->rowstride)
+ArtPixFormat gdk_pixbuf_get_format (GdkPixbuf *pixbuf);
+int gdk_pixbuf_get_n_channels (GdkPixbuf *pixbuf);
+int gdk_pixbuf_get_has_alpha (GdkPixbuf *pixbuf);
+int gdk_pixbuf_get_bits_per_sample (GdkPixbuf *pixbuf);
+guchar *gdk_pixbuf_get_pixels (GdkPixbuf *pixbuf);
+int gdk_pixbuf_get_width (GdkPixbuf *pixbuf);
+int gdk_pixbuf_get_height (GdkPixbuf *pixbuf);
+int gdk_pixbuf_get_rowstride (GdkPixbuf *pixbuf);
/* Reference counting */
void gdk_pixbuf_ref (GdkPixbuf *pixbuf);
void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
+/* Constructors */
/* Wrap a libart pixbuf */
GdkPixbuf *gdk_pixbuf_new_from_art_pixbuf (ArtPixBuf *art_pixbuf);