summaryrefslogtreecommitdiff
path: root/gdk-pixbuf/io-png.c
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1999-01-05 04:31:03 +0000
committerArturo Espinosa <unammx@src.gnome.org>1999-01-05 04:31:03 +0000
commitf876ca2681065a625a9e314e5f71732c6f7c4f5b (patch)
treeac06361733730b09f25cdf1664ea22cfc8480e07 /gdk-pixbuf/io-png.c
parentf0723b00a98c0294f1a7fbe369e63cb2fc0146e9 (diff)
downloadgtk+-f876ca2681065a625a9e314e5f71732c6f7c4f5b.tar.gz
Loading framework done, start of PNG loader
Diffstat (limited to 'gdk-pixbuf/io-png.c')
-rw-r--r--gdk-pixbuf/io-png.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c
new file mode 100644
index 0000000000..18f661ce05
--- /dev/null
+++ b/gdk-pixbuf/io-png.c
@@ -0,0 +1,62 @@
+/*
+ * io-png.c: GdkPixBuf image loader for PNG files.
+ *
+ * Author:
+ * Rasterman (raster@redhat.com).
+ * Miguel de Icaza (miguel@gnu.org)
+ *
+ */
+#include <config.h>
+#include <stdio.h>
+#include "gdk-pixbuf.h"
+#include "gdk-pixbuf-io.h"
+#include <png.h>
+
+/* Shared library entry point */
+GdkPixBuf *
+image_load (FILE *f);
+{
+ png_structp png;
+ png_infop info_ptr, end_info;
+ int width, height, depth, color_type, interlace_type;
+
+ g_return_val_if_fail (filename != NULL, NULL);
+
+ png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if (png)
+ return NULL;
+
+ info_ptr = png_create_info_struct (png);
+ if (!info_ptr){
+ png_destroy_read_struct (&png, NULL, NULL);
+ return NULL;
+ }
+
+ end_info = png_create_info_struct (png);
+ if (!end_info){
+ png_destroy_read_struct (&png, &info_ptr, NULL);
+ return NULL:
+ }
+
+ if (setjmp (png->jmpbuf)){
+ png_destroy_read_struct (&png, &info_ptr, &end_info);
+ return NULL;
+ }
+
+ png_init_io (pngptr, f);
+
+ png_read_info (png, info_ptr);
+ png_get_IHDR (png, info_ptr, &width, &height, &depth, &color_type, &interlace_type, NULL, NULL);
+
+ if (color_type == color_type == PNG_COLOR_TYPE_PALETTE)
+ png_set_expand (png);
+
+ png_set_strip_16 (png);
+ png_set_packing (png);
+ if (png_get_valid (png, info_ptr, PNG_INFO_tRNS))
+ png_set_expand (png);
+
+ png_set_filler (png, 0xff, PNG_FILLER_AFTER);
+
+ /* FIXME finish this */
+}