From 047e10fc0360ae17ee1bbfc01d561cc4b5cb6cdd Mon Sep 17 00:00:00 2001
From: "Mirar (Pontus Hagland)" <pike@sort.mirar.org>
Date: Wed, 12 Nov 1997 04:40:38 +0100
Subject: [PATCH] PNG support initiated

Rev: src/modules/Image/Makefile:1.5
Rev: src/modules/Image/encodings/Makefile.in:1.7
Rev: src/modules/Image/encodings/png.c:1.1
---
 .gitattributes                          |  1 +
 src/modules/Image/Makefile              |  2 +-
 src/modules/Image/encodings/Makefile.in | 12 ++++-
 src/modules/Image/encodings/png.c       | 60 +++++++++++++++++++++++++
 4 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 src/modules/Image/encodings/png.c

diff --git a/.gitattributes b/.gitattributes
index 2bce27d294..2b1b6e0444 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -80,6 +80,7 @@ testfont binary
 /src/modules/Image/encodings/gif.c foreign_ident
 /src/modules/Image/encodings/gif_lzw.c foreign_ident
 /src/modules/Image/encodings/gif_lzw.h foreign_ident
+/src/modules/Image/encodings/png.c foreign_ident
 /src/modules/Image/encodings/pnm.c foreign_ident
 /src/modules/Image/font.c foreign_ident
 /src/modules/Image/illustration.pike foreign_ident
diff --git a/src/modules/Image/Makefile b/src/modules/Image/Makefile
index 36c8b1d270..25602485f7 100644
--- a/src/modules/Image/Makefile
+++ b/src/modules/Image/Makefile
@@ -2,7 +2,7 @@
 DOCFILES = doc-header \
    blit.c blit_layer_include.h colortable.c colortable.h dct.c font.c \
    image.c image.h matrix.c operator.c pattern.c pnm.c \
-   polyfill.c quant.c togif.c x.c encodings/gif.c encodings/gif_lzw.c \
+   polyfill.c togif.c x.c encodings/gif.c encodings/gif_lzw.c \
    encodings/gif_lzw.h encodings/pnm.c \
    doc-footer
 
diff --git a/src/modules/Image/encodings/Makefile.in b/src/modules/Image/encodings/Makefile.in
index accd11f8d4..b703516f04 100644
--- a/src/modules/Image/encodings/Makefile.in
+++ b/src/modules/Image/encodings/Makefile.in
@@ -1,6 +1,8 @@
 SRCDIR=@srcdir@
 VPATH=@srcdir@:@srcdir@/../../..:../../..
-GIF_OBJS = gif.o gif_lzw.o
+GIF_OBJS = gif.o gif_lzw.o png.o
+JPEG_OBJS = jpeg.o
+PNG_OBJS = png.o
 PNM_OBJS = pnm.o 
 OBJS=gif.a pnm.a
 
@@ -19,6 +21,14 @@ gif.a : $(GIF_OBJS)
 	rm -f gif.a
 	$(AR) cq gif.a $(GIF_OBJS)
 
+png.a : $(PNG_OBJS)
+	rm -f png.a
+	$(AR) cq png.a $(PNG_OBJS)
+
+jpeg.a : $(JPEG_OBJS)
+	rm -f jpeg.a
+	$(AR) cq jpeg.a $(JPEG_OBJS)
+
 pnm.a : $(PNM_OBJS)
 	rm -f pnm.a
 	$(AR) cq pnm.a $(PNM_OBJS)
diff --git a/src/modules/Image/encodings/png.c b/src/modules/Image/encodings/png.c
new file mode 100644
index 0000000000..21cdafdeb7
--- /dev/null
+++ b/src/modules/Image/encodings/png.c
@@ -0,0 +1,60 @@
+/* $Id: png.c,v 1.1 1997/11/12 03:37:52 mirar Exp $ */
+
+/*
+**! module Image
+**! note
+**!	$Id: png.c,v 1.1 1997/11/12 03:37:52 mirar Exp $
+**! submodule PNG
+**!
+**!	This submodule keep the PNG encode/decode capabilities
+**!	of the <ref>Image</ref> module.
+**!
+**!	PNG is a rather new lossless image storage format, 
+**!	usable for most images.
+**!
+**!	Simple encoding:
+**!	<ref>encode</ref>
+**!
+**! see also: Image, Image.image, Image.colortable
+*/
+
+#include <math.h>
+#include <ctype.h>
+
+#include "stralloc.h"
+#include "global.h"
+RCSID("$Id: png.c,v 1.1 1997/11/12 03:37:52 mirar Exp $");
+#include "pike_macros.h"
+#include "object.h"
+#include "constants.h"
+#include "interpret.h"
+#include "svalue.h"
+#include "threads.h"
+#include "array.h"
+#include "error.h"
+#include "threads.h"
+
+void image_png__module_value(INT32 args)
+{
+   pop_n_elems(args);
+   push_text("_Image_dot_PNG");
+   SAFE_APPLY_MASTER("resolv",1);
+   if (sp[-1].type==T_INT)
+      error("Image.PNG: Can't load submodule\n");
+}
+
+void init_image_png(void)
+{
+   start_new_program();
+   
+   add_function("_module_value",image_png__module_value,
+		"function(:object)",0);
+
+   push_object(clone_object(end_program(),0));
+   add_constant(make_shared_string("PNG"),sp-1,0);
+   pop_stack();
+}
+
+void exit_image_png(void)
+{
+}
-- 
GitLab