From 061e4dfa091c7aa01b2616090488e5f3cf963b4a Mon Sep 17 00:00:00 2001 From: "Mirar (Pontus Hagland)" <pike@sort.mirar.org> Date: Sat, 23 Nov 1996 05:26:16 +0100 Subject: [PATCH] number of colors can be specified to ->togif functions Rev: src/modules/image/font.c:1.9 Rev: src/modules/image/togif.c:1.14 --- src/modules/image/font.c | 26 ++++++++++++++++++++------ src/modules/image/togif.c | 13 ++++++++++--- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/modules/image/font.c b/src/modules/image/font.c index fe28d216cc..0a6ef94774 100644 --- a/src/modules/image/font.c +++ b/src/modules/image/font.c @@ -1,4 +1,4 @@ -/* $Id: font.c,v 1.8 1996/11/22 20:28:15 law Exp $ */ +/* $Id: font.c,v 1.9 1996/11/23 04:26:13 law Exp $ */ #include "global.h" @@ -231,11 +231,25 @@ void font_load(INT32 args) for (i=0; i<THIS->chars; i++) { - ch=(struct char_head*) - ((char *)(THIS->mem)+ntohl(fh->o[i])); - THIS->charinfo[i].width = ntohl(ch->width); - THIS->charinfo[i].spacing = ntohl(ch->spacing); - THIS->charinfo[i].pixels = ch->data; + if (i*sizeof(INT32)<(unsigned long)size + && ntohl(fh->o[i])<(unsigned long)size + && ! ( ntohl(fh->o[i]) % 4) ) /* must be aligned */ + { + ch=(struct char_head*) + ((char *)(THIS->mem)+ntohl(fh->o[i])); + THIS->charinfo[i].width = ntohl(ch->width); + THIS->charinfo[i].spacing = ntohl(ch->spacing); + THIS->charinfo[i].pixels = ch->data; + } + else /* illegal <tm> offset or illegal align */ + { + free_font_struct(new); + THIS=NULL; + pop_n_elems(args); + push_int(0); + return; + } + } close(fd); diff --git a/src/modules/image/togif.c b/src/modules/image/togif.c index 1f1c1ed49b..970b880b33 100644 --- a/src/modules/image/togif.c +++ b/src/modules/image/togif.c @@ -1,4 +1,4 @@ -/* $Id: togif.c,v 1.13 1996/11/22 20:28:19 law Exp $ */ +/* $Id: togif.c,v 1.14 1996/11/23 04:26:16 law Exp $ */ /* togif @@ -460,6 +460,8 @@ void image_togif(INT32 args) if (args>0 && sp[-args].type==T_ARRAY) ct=colortable_from_array(sp[-args].u.array,"image->togif()\n"); + else if (args>0 && args!=3 && sp[-args].type==T_INT) + ct=colortable_quant(THIS,min(256,max(2,sp[-args].u.integer))); if (args>=3+!!ct) { @@ -483,6 +485,8 @@ void image_togif_fs(INT32 args) if (args>0 && sp[-args].type==T_ARRAY) ct=colortable_from_array(sp[-args].u.array,"image->togif()\n"); + else if (args>0 && args!=3 && sp[-args].type==T_INT) + ct=colortable_quant(THIS,min(256,max(2,sp[-args].u.integer))); if (args>=3+!!ct) { @@ -569,8 +573,11 @@ CHRONO("gif add init"); y=sp[1-args].u.integer; } - if (args>2 && sp[2-args].type==T_ARRAY) - ct=colortable_from_array(sp[2-args].u.array,"image->gif_add()\n"); + + if (args>0 && sp[-args].type==T_ARRAY) + ct=colortable_from_array(sp[-args].u.array,"image->gif_add()\n"); + else if (args!=3 && sp[-args].type==T_INT) + ct=colortable_quant(THIS,max(256,min(2,sp[-args].u.integer))); if (args>2+!!ct) { -- GitLab