Commits

Anonymous committed 0b986dd

- sync to 1.7.0

Comments (0)

Files changed (24)

+990922 Thomas Boutell (TBB)
+	- autoconf/automake removed in favor of an improved Makefile.
+	  I was getting unbelievable amounts of confused email.
+	- Documentation updates.
+	- ANSI C correctness.
 990729 Thomas Boutell (TBB)
 	- It would probably be a good idea to free the 
 	  png_write_struct, wouldn't it.
 #Depending on your system, you will need to modify this makefile.
 
-#If you do not have gcc, change the setting for CC, but you must
+#If you do not have gcc, change the setting for COMPILER, but you must
 #use an ANSI standard C compiler (NOT the old SunOS 4.1.3 cc
 #compiler; get gcc if you are still using it). 
+COMPILER=gcc
 
 #If the ar command fails on your system, consult the ar manpage
 #for your system. 
-
-CC=gcc 
 AR=ar
-#CFLAGS= -ggdb
-CFLAGS= -g 
-LIBS=-L. -lgd -lz -lm -lpng
-
-all: libgd.a gdtest gddemo pngtogd pngtogd2 gdtopng gd2topng gd2copypal gdparttopng gd2time webpng
-
-gdtest:	gdtest.o libgd.a gd.h
-	$(CC) gdtest.o -o gdtest        $(LIBS)
-
-gddemo: gddemo.o libgd.a gd.h gdfonts.h gdfontl.h
-	$(CC) gddemo.o -o gddemo	$(LIBS)
-
-pngtogd: pngtogd.o libgd.a gd.h
-	$(CC) pngtogd.o -o pngtogd	$(LIBS) 
-
-pngtogd2: pngtogd2.o libgd.a gd.h
-	$(CC) pngtogd2.o -o pngtogd2      $(LIBS)
 
-gdtopng: gdtopng.o libgd.a gd.h
-	$(CC) gdtopng.o -o gdtopng      $(LIBS)
-
-gd2topng: gd2topng.o libgd.a gd.h
-	$(CC) gd2topng.o -o gd2topng      $(LIBS)
-
-gd2copypal: gd2copypal.o libgd.a gd.h
-	$(CC) gd2copypal.o -o gd2copypal      $(LIBS)
-
-gdparttopng: gdparttopng.o libgd.a gd.h
-	$(CC) gdparttopng.o -o gdparttopng      $(LIBS)
-
-gd2time: gd2time.o libgd.a gd.h
-	$(CC) gd2time.o -o gd2time      $(LIBS)
-
-libgd.a: gd.o gd_io.o gd_io_file.o gd_io_dp.o gd_io_ss.o gd_png.o gd_ss.o \
-	gd_gd.o gd_gd2.o gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o \
+#If the install command is not in your path, provide
+#an explicit path for it here, or install manually.
+INSTALL=install
+
+#If you don't have FreeType and/or Xpm installed, including the
+#header files, uncomment this (default).
+CFLAGS=-O
+#If you do have FreeType and/or Xpm fully installed, uncomment a
+#variation of this and comment out the line above. See also LIBS below.
+#CFLAGS=-O -DHAVE_XPM -DHAVE_LIBTTF
+
+#If you don't have FreeType and/or Xpm fully installed, uncomment this
+#(default).
+LIBS=-lgd -lm -lz -lpng
+#If you do have FreeType and/or Xpm fully installed, uncomment a 
+#variation of this and comment out the line above. Note that
+#Xpm requires X11. See also CFLAGS above.
+#LIBS=-lgd -lm -lttf -lpng -lXpm -lX11
+
+#Typical install locations for freetype, zlib, xpm and libpng header files.
+#If yours are somewhere else, change this. 
+INCLUDEDIRS=-I/usr/local/include -I/usr/include/X11 -I/usr/X11R6/include/X11
+
+#Typical install locations for freetype, zlib, xpm and libpng libraries.
+#If yours are somewhere else, other than a standard location
+#such as /lib or /usr/lib, then change this. Be sure to keep
+#-L. as this allows the gd library itself to be found.
+#Put -L. first so that old versions of the gd library elsewhere
+#on your system can't cause conflicts while building a new one.
+LIBDIRS=-L. -L/usr/local/lib -L/usr/lib/X11 -L/usr/X11R6/lib
+
+#Location where libgd.a should be installed by "make install".
+INSTALL_LIB=/usr/local/lib
+
+#Location where .h files should be installed by "make install".
+INSTALL_INCLUDE=/usr/local/include
+
+#Location where useful non-test programs should be installed by "make install".
+INSTALL_BIN=/usr/local/bin
+
+#
+#
+# Changes should not be required below here.
+#
+#
+
+VERSION=1.7
+
+CC=$(COMPILER) $(INCLUDEDIRS)
+LINK=$(CC) $(LIBDIRS) $(LIBS)
+
+PROGRAMS=$(BIN_PROGRAMS) $(TEST_PROGRAMS)
+
+BIN_PROGRAMS=pngtogd pngtogd2 gdtopng gd2topng gd2copypal gdparttopng webpng
+TEST_PROGRAMS=gdtest gddemo gd2time gdtestttf
+
+all: libgd.a $(PROGRAMS)
+
+install: libgd.a $(BIN_PROGRAMS)
+	$(INSTALL) -m 644 libgd.a $(INSTALL_LIB)/libgd.a
+	$(INSTALL) -m 755 pngtogd $(INSTALL_BIN)/pngtogd
+	$(INSTALL) -m 755 pngtogd2 $(INSTALL_BIN)/pngtogd2
+	$(INSTALL) -m 755 gdtopng $(INSTALL_BIN)/gdtopng
+	$(INSTALL) -m 755 gd2topng $(INSTALL_BIN)/gd2topng
+	$(INSTALL) -m 755 gd2copypal $(INSTALL_BIN)/gd2copypal
+	$(INSTALL) -m 755 gdparttopng $(INSTALL_BIN)/gdparttopng
+	$(INSTALL) -m 755 webpng $(INSTALL_BIN)/webpng
+	$(INSTALL) -m 755 bdftogd $(INSTALL_BIN)/bdftogd
+	$(INSTALL) -m 644 gd.h $(INSTALL_INCLUDE)/gd.h
+	$(INSTALL) -m 644 gdcache.h $(INSTALL_INCLUDE)/gdcache.h
+	$(INSTALL) -m 644 gd_io.h $(INSTALL_INCLUDE)/gd_io.h
+	$(INSTALL) -m 644 gdfontg.h $(INSTALL_INCLUDE)/gdfontg.h
+	$(INSTALL) -m 644 gdfontl.h $(INSTALL_INCLUDE)/gdfontl.h
+	$(INSTALL) -m 644 gdfontmb.h $(INSTALL_INCLUDE)/gdfontmb.h
+	$(INSTALL) -m 644 gdfonts.h $(INSTALL_INCLUDE)/gdfonts.h
+	$(INSTALL) -m 644 gdfontt.h $(INSTALL_INCLUDE)/gdfontt.h
+
+gddemo: gddemo.o libgd.a
+	$(CC) gddemo.o -o gddemo	$(LIBDIRS) $(LIBS)
+
+pngtogd: pngtogd.o libgd.a
+	$(CC) pngtogd.o -o pngtogd	$(LIBDIRS) $(LIBS) 
+
+webpng: webpng.o libgd.a
+	$(CC) webpng.o -o webpng	$(LIBDIRS) $(LIBS)
+
+pngtogd2: pngtogd2.o libgd.a
+	$(CC) pngtogd2.o -o pngtogd2	$(LIBDIRS) $(LIBS)
+
+gdtopng: gdtopng.o libgd.a
+	$(CC) gdtopng.o -o gdtopng	$(LIBDIRS) $(LIBS)
+
+gd2topng: gd2topng.o libgd.a
+	$(CC) gd2topng.o -o gd2topng	$(LIBDIRS) $(LIBS)
+
+gd2copypal: gd2copypal.o libgd.a
+	$(CC) gd2copypal.o -o gd2copypal	$(LIBDIRS) $(LIBS)
+
+gdparttopng: gdparttopng.o libgd.a
+	$(CC) gdparttopng.o -o gdparttopng	$(LIBDIRS) $(LIBS)
+
+gdtest: gdtest.o libgd.a
+	$(CC) gdtest.o -o gdtest	$(LIBDIRS) $(LIBS)
+
+gd2time: gd2time.o libgd.a
+	$(CC) gd2time.o -o gd2time	$(LIBDIRS) $(LIBS)
+
+gdtestttf: gdtestttf.o libgd.a
+	$(CC) gdtestttf.o -o gdtestttf	$(LIBDIRS) $(LIBS)
+
+libgd.a: gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o gd_io_file.o gd_ss.o \
+	gd_io_ss.o gd_png.o gdxpm.o gdfontt.o gdfonts.o gdfontmb.o gdfontl.o \
+	gdtables.o gdfontg.o gdkanji.o \
 	gd.h gdfontt.h gdfonts.h gdfontmb.h gdfontl.h gdfontg.h
 	rm -f libgd.a
-	$(AR) rc libgd.a gd.o gd_io.o gd_io_file.o gd_io_dp.o gd_io_ss.o \
-		gd_png.o gd_ss.o gd_gd.o gd_gd2.o \
-		gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o
-
-webpng: webpng.o libgd.a gd.h
-	$(CC) webpng.o -o webpng	$(LIBS)
+	$(AR) rc libgd.a gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o gdxpm.o \
+		gd_io_file.o gd_ss.o gd_io_ss.o gd_png.o gdfontt.o gdfonts.o \
+		gdfontmb.o gdfontl.o gdfontg.o gd.o gdfontt.o gdfonts.o \
+		gdfontmb.o gdfontl.o gdfontg.o gdtables.o gdkanji.o
+	-ranlib libgd.a
 
 clean:
-	rm -f *.o *.a gddemo gdtest pngtogd pngtogd2 gdtopng gd2topng gdparttopng gd2time gd2copypal webpng 
+	rm -f *.o *.a ${PROGRAMS}
 
 #ifndef $capdef
 #define $capdef 1
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 $info
 
 #include "gd.h"
 
 extern gdFontPtr $gdname;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
 EOF
Add a comment to this file

src/demoout.png

Old
Old image
New
New image
 #include <zlib.h>
 #include "gd.h"
 
-#define costScale 1024
-static int cost[];
-#define sintScale 1024
-static int sint[];
+extern int gdCosT[1024];
+extern int gdSinT[1024];
 
 static void gdImageBrushApply(gdImagePtr im, int x, int y);
 static void gdImageTileApply(gdImagePtr im, int x, int y);
 {
 	int i;
 	int l;
-	l = strlen(s);
+	l = strlen((char *) s);
 	for (i=0; (i<l); i++) {
 		gdImageChar(im, f, x, y, s[i], color);
 		x += f->w;
 {
 	int i;
 	int l;
-	l = strlen(s);
+	l = strlen((char *) s);
 	for (i=0; (i<l); i++) {
 		gdImageCharUp(im, f, x, y, s[i], color);
 		y -= f->w;
 	}
 	for (i=s; (i <= e); i++) {
 		int x, y;
-		x = ((long)cost[i % 360] * (long)w2 / costScale) + cx; 
-		y = ((long)sint[i % 360] * (long)h2 / sintScale) + cy;
+		x = ((long)gdCosT[i % 360] * (long)w2 / 1024) + cx; 
+		y = ((long)gdSinT[i % 360] * (long)h2 / 1024) + cy;
 		if (i != s) {
 			gdImageLine(im, lx, ly, x, y, color);	
 		}
 	return cmpStatus;
 }
 
-int cost[] = {
-  1024,
-  1023,
-  1023,
-  1022,
-  1021,
-  1020,
-  1018,
-  1016,
-  1014,
-  1011,
-  1008,
-  1005,
-  1001,
-  997,
-  993,
-  989,
-  984,
-  979,
-  973,
-  968,
-  962,
-  955,
-  949,
-  942,
-  935,
-  928,
-  920,
-  912,
-  904,
-  895,
-  886,
-  877,
-  868,
-  858,
-  848,
-  838,
-  828,
-  817,
-  806,
-  795,
-  784,
-  772,
-  760,
-  748,
-  736,
-  724,
-  711,
-  698,
-  685,
-  671,
-  658,
-  644,
-  630,
-  616,
-  601,
-  587,
-  572,
-  557,
-  542,
-  527,
-  512,
-  496,
-  480,
-  464,
-  448,
-  432,
-  416,
-  400,
-  383,
-  366,
-  350,
-  333,
-  316,
-  299,
-  282,
-  265,
-  247,
-  230,
-  212,
-  195,
-  177,
-  160,
-  142,
-  124,
-  107,
-  89,
-  71,
-  53,
-  35,
-  17,
-  0,
-  -17,
-  -35,
-  -53,
-  -71,
-  -89,
-  -107,
-  -124,
-  -142,
-  -160,
-  -177,
-  -195,
-  -212,
-  -230,
-  -247,
-  -265,
-  -282,
-  -299,
-  -316,
-  -333,
-  -350,
-  -366,
-  -383,
-  -400,
-  -416,
-  -432,
-  -448,
-  -464,
-  -480,
-  -496,
-  -512,
-  -527,
-  -542,
-  -557,
-  -572,
-  -587,
-  -601,
-  -616,
-  -630,
-  -644,
-  -658,
-  -671,
-  -685,
-  -698,
-  -711,
-  -724,
-  -736,
-  -748,
-  -760,
-  -772,
-  -784,
-  -795,
-  -806,
-  -817,
-  -828,
-  -838,
-  -848,
-  -858,
-  -868,
-  -877,
-  -886,
-  -895,
-  -904,
-  -912,
-  -920,
-  -928,
-  -935,
-  -942,
-  -949,
-  -955,
-  -962,
-  -968,
-  -973,
-  -979,
-  -984,
-  -989,
-  -993,
-  -997,
-  -1001,
-  -1005,
-  -1008,
-  -1011,
-  -1014,
-  -1016,
-  -1018,
-  -1020,
-  -1021,
-  -1022,
-  -1023,
-  -1023,
-  -1024,
-  -1023,
-  -1023,
-  -1022,
-  -1021,
-  -1020,
-  -1018,
-  -1016,
-  -1014,
-  -1011,
-  -1008,
-  -1005,
-  -1001,
-  -997,
-  -993,
-  -989,
-  -984,
-  -979,
-  -973,
-  -968,
-  -962,
-  -955,
-  -949,
-  -942,
-  -935,
-  -928,
-  -920,
-  -912,
-  -904,
-  -895,
-  -886,
-  -877,
-  -868,
-  -858,
-  -848,
-  -838,
-  -828,
-  -817,
-  -806,
-  -795,
-  -784,
-  -772,
-  -760,
-  -748,
-  -736,
-  -724,
-  -711,
-  -698,
-  -685,
-  -671,
-  -658,
-  -644,
-  -630,
-  -616,
-  -601,
-  -587,
-  -572,
-  -557,
-  -542,
-  -527,
-  -512,
-  -496,
-  -480,
-  -464,
-  -448,
-  -432,
-  -416,
-  -400,
-  -383,
-  -366,
-  -350,
-  -333,
-  -316,
-  -299,
-  -282,
-  -265,
-  -247,
-  -230,
-  -212,
-  -195,
-  -177,
-  -160,
-  -142,
-  -124,
-  -107,
-  -89,
-  -71,
-  -53,
-  -35,
-  -17,
-  0,
-  17,
-  35,
-  53,
-  71,
-  89,
-  107,
-  124,
-  142,
-  160,
-  177,
-  195,
-  212,
-  230,
-  247,
-  265,
-  282,
-  299,
-  316,
-  333,
-  350,
-  366,
-  383,
-  400,
-  416,
-  432,
-  448,
-  464,
-  480,
-  496,
-  512,
-  527,
-  542,
-  557,
-  572,
-  587,
-  601,
-  616,
-  630,
-  644,
-  658,
-  671,
-  685,
-  698,
-  711,
-  724,
-  736,
-  748,
-  760,
-  772,
-  784,
-  795,
-  806,
-  817,
-  828,
-  838,
-  848,
-  858,
-  868,
-  877,
-  886,
-  895,
-  904,
-  912,
-  920,
-  928,
-  935,
-  942,
-  949,
-  955,
-  962,
-  968,
-  973,
-  979,
-  984,
-  989,
-  993,
-  997,
-  1001,
-  1005,
-  1008,
-  1011,
-  1014,
-  1016,
-  1018,
-  1020,
-  1021,
-  1022,
-  1023,
-  1023
-};
-
-int sint[] = {
-  0,
-  17,
-  35,
-  53,
-  71,
-  89,
-  107,
-  124,
-  142,
-  160,
-  177,
-  195,
-  212,
-  230,
-  247,
-  265,
-  282,
-  299,
-  316,
-  333,
-  350,
-  366,
-  383,
-  400,
-  416,
-  432,
-  448,
-  464,
-  480,
-  496,
-  512,
-  527,
-  542,
-  557,
-  572,
-  587,
-  601,
-  616,
-  630,
-  644,
-  658,
-  671,
-  685,
-  698,
-  711,
-  724,
-  736,
-  748,
-  760,
-  772,
-  784,
-  795,
-  806,
-  817,
-  828,
-  838,
-  848,
-  858,
-  868,
-  877,
-  886,
-  895,
-  904,
-  912,
-  920,
-  928,
-  935,
-  942,
-  949,
-  955,
-  962,
-  968,
-  973,
-  979,
-  984,
-  989,
-  993,
-  997,
-  1001,
-  1005,
-  1008,
-  1011,
-  1014,
-  1016,
-  1018,
-  1020,
-  1021,
-  1022,
-  1023,
-  1023,
-  1024,
-  1023,
-  1023,
-  1022,
-  1021,
-  1020,
-  1018,
-  1016,
-  1014,
-  1011,
-  1008,
-  1005,
-  1001,
-  997,
-  993,
-  989,
-  984,
-  979,
-  973,
-  968,
-  962,
-  955,
-  949,
-  942,
-  935,
-  928,
-  920,
-  912,
-  904,
-  895,
-  886,
-  877,
-  868,
-  858,
-  848,
-  838,
-  828,
-  817,
-  806,
-  795,
-  784,
-  772,
-  760,
-  748,
-  736,
-  724,
-  711,
-  698,
-  685,
-  671,
-  658,
-  644,
-  630,
-  616,
-  601,
-  587,
-  572,
-  557,
-  542,
-  527,
-  512,
-  496,
-  480,
-  464,
-  448,
-  432,
-  416,
-  400,
-  383,
-  366,
-  350,
-  333,
-  316,
-  299,
-  282,
-  265,
-  247,
-  230,
-  212,
-  195,
-  177,
-  160,
-  142,
-  124,
-  107,
-  89,
-  71,
-  53,
-  35,
-  17,
-  0,
-  -17,
-  -35,
-  -53,
-  -71,
-  -89,
-  -107,
-  -124,
-  -142,
-  -160,
-  -177,
-  -195,
-  -212,
-  -230,
-  -247,
-  -265,
-  -282,
-  -299,
-  -316,
-  -333,
-  -350,
-  -366,
-  -383,
-  -400,
-  -416,
-  -432,
-  -448,
-  -464,
-  -480,
-  -496,
-  -512,
-  -527,
-  -542,
-  -557,
-  -572,
-  -587,
-  -601,
-  -616,
-  -630,
-  -644,
-  -658,
-  -671,
-  -685,
-  -698,
-  -711,
-  -724,
-  -736,
-  -748,
-  -760,
-  -772,
-  -784,
-  -795,
-  -806,
-  -817,
-  -828,
-  -838,
-  -848,
-  -858,
-  -868,
-  -877,
-  -886,
-  -895,
-  -904,
-  -912,
-  -920,
-  -928,
-  -935,
-  -942,
-  -949,
-  -955,
-  -962,
-  -968,
-  -973,
-  -979,
-  -984,
-  -989,
-  -993,
-  -997,
-  -1001,
-  -1005,
-  -1008,
-  -1011,
-  -1014,
-  -1016,
-  -1018,
-  -1020,
-  -1021,
-  -1022,
-  -1023,
-  -1023,
-  -1024,
-  -1023,
-  -1023,
-  -1022,
-  -1021,
-  -1020,
-  -1018,
-  -1016,
-  -1014,
-  -1011,
-  -1008,
-  -1005,
-  -1001,
-  -997,
-  -993,
-  -989,
-  -984,
-  -979,
-  -973,
-  -968,
-  -962,
-  -955,
-  -949,
-  -942,
-  -935,
-  -928,
-  -920,
-  -912,
-  -904,
-  -895,
-  -886,
-  -877,
-  -868,
-  -858,
-  -848,
-  -838,
-  -828,
-  -817,
-  -806,
-  -795,
-  -784,
-  -772,
-  -760,
-  -748,
-  -736,
-  -724,
-  -711,
-  -698,
-  -685,
-  -671,
-  -658,
-  -644,
-  -630,
-  -616,
-  -601,
-  -587,
-  -572,
-  -557,
-  -542,
-  -527,
-  -512,
-  -496,
-  -480,
-  -464,
-  -448,
-  -432,
-  -416,
-  -400,
-  -383,
-  -366,
-  -350,
-  -333,
-  -316,
-  -299,
-  -282,
-  -265,
-  -247,
-  -230,
-  -212,
-  -195,
-  -177,
-  -160,
-  -142,
-  -124,
-  -107,
-  -89,
-  -71,
-  -53,
-  -35,
-  -17
-};
 #ifndef GD_H
 #define GD_H 1
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* gd.h: declarations file for the graphic-draw module.
  * Permission to use, copy, modify, and distribute this software and its
  * documentation for any purpose and without fee is hereby granted, provided
 #define GD_CMP_TRANSPARENT	32	/* Transparent colour */
 #define GD_CMP_BACKGROUND	64	/* Background colour */
 #define GD_CMP_INTERLACE	128	/* Interlaced setting */
+
+#ifdef __cplusplus
+}
 #endif
+
+#endif /* GD_H */
 		return FALSE;
 	};
 	GD2_DBG(printf("Got %d bytes. Uncompressing into buffer of %d bytes\n", compSize, *chunkLen));
-	zerr = uncompress(chunkBuf, chunkLen,  compBuf, compSize);
+	zerr = uncompress((unsigned char *) chunkBuf, chunkLen,  
+		(unsigned char *) compBuf, compSize);
         if (zerr != Z_OK) {
 		GD2_DBG(printf("Error %d from uncompress\n",zerr));
                 return FALSE;
         };
 	GD2_DBG(printf("Got chunk\n"));
 	return TRUE;
-};
+}
 
 gdImagePtr gdImageCreateFromGd2(FILE *inFile)
 {
                         };
 			if (fmt == GD2_FMT_COMPRESSED) {
                         	compLen = compMax;
-                        	if (compress(&compData[0], &compLen, &chunkData[0], chunkLen) != Z_OK) {
+                        	if (compress((unsigned char *) 
+					&compData[0], &compLen, 
+					(unsigned char *) &chunkData[0], 
+					chunkLen) != Z_OK) {
                                 	printf("Error from compressing\n");
                         	} else {
                                 	chunkIdx[chunkNum].offset = gdTell(out);
   ctx->ctx.free = freeDynamicCtx;
 
   return (gdIOCtx*)ctx;
-};
+}
 
 void* gdDPExtractData(struct gdIOCtx* ctx, int *size)
 {
   dp->pos = 0;
 
   return dp;
-};
+}
 
 static int 
 dynamicPutbuf( struct gdIOCtx* ctx, const void *buf, int size )
 *
 */
 
+/* For platforms with incomplete ANSI defines. Fortunately,
+	SEEK_SET is defined to be zero by the standard. */
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif /* SEEK_SET */
+
 #include <math.h>
 #include <string.h>
 #include <stdlib.h>
   ctx->ctx.free = freeFileCtx;
 
   return (gdIOCtx*)ctx;
-};
+}
 
 static 
 void freeFileCtx(gdIOCtx *ctx)
   return getc(fctx->f);
 }
 
+
 static int fileSeek(struct gdIOCtx* ctx, const int pos)
 {
   fileIOCtx  *fctx;
   ctx->ctx.free = freeSsCtx;
 
   return (gdIOCtx*)ctx;
-};
+}
 
 static
 void freeSsCtx(gdIOCtx *ctx)
 		gdImageLine(im_out, 0, 127, 127, 0, gdStyledBrushed);
 	}
 	/* Text */
-	gdImageString(im_out, gdFontGiant, 16, 16, "hi", red);
-	gdImageStringUp(im_out, gdFontSmall, 32, 32, "hi", red);
+	gdImageString(im_out, gdFontGiant, 16, 16, 
+		(unsigned char *) "hi", red);
+	gdImageStringUp(im_out, gdFontSmall, 32, 32, 
+		(unsigned char *) "hi", red);
 	/* Make output image interlaced (allows "fade in" in some viewers,
 		and in the latest web browsers) */
 	gdImageInterlace(im_out, 1);
 #ifndef _GDFONTG_H_
 #define _GDFONTG_H_ 1
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
 	This is a header file for gd font, generated using
 	bdftogd version 0.51 by Jan Pazdziora, adelton@fi.muni.cz
 
 extern gdFontPtr gdFontGiant;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
 #ifndef _GDFONTL_H_
 #define _GDFONTL_H_ 1
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
 	This is a header file for gd font, generated using
 	bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
 
 extern gdFontPtr gdFontLarge;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
 #ifndef _GDFONTMB_H_
 #define _GDFONTMB_H_ 1
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
 	This is a header file for gd font, generated using
 	bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
 
 extern gdFontPtr gdFontMediumBold;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
 #ifndef _GDFONTS_H_
 #define _GDFONTS_H_ 1
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
 	This is a header file for gd font, generated using
 	bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
 
 extern gdFontPtr gdFontSmall;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
 #ifndef _GDFONTT_H_
 #define _GDFONTT_H_ 1
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
 	This is a header file for gd font, generated using
 	bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz
 
 extern gdFontPtr gdFontTiny;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
+/* gdkanji.c (Kanji code converter)                            */
+/*       written by Masahito Yamaga (yamaga@ipc.chiba-u.ac.jp) */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+#if defined(HAVE_ICONV_H) || defined(HAVE_ICONV)
+#include <iconv.h>
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#endif
+
+#if defined(HAVE_ICONV_H) && !defined(HAVE_ICONV)
+#define HAVE_ICONV 1
+#endif
+
+#define LIBNAME "any2eucjp()"
+
+#if defined(__MSC__) || defined(__BORLANDC__) || defined(__TURBOC__) || defined(_Windows) || defined(MSDOS)
+#ifndef SJISPRE
+#define SJISPRE 1
+#endif
+#endif
+
+#ifdef TRUE
+#undef TRUE
+#endif
+#ifdef FALSE
+#undef FALSE
+#endif
+
+#define TRUE  1
+#define FALSE 0
+
+#define NEW 1
+#define OLD 2
+#define ESCI 3
+#define NEC 4
+#define EUC 5
+#define SJIS 6
+#define EUCORSJIS 7
+#define ASCII 8
+
+#define NEWJISSTR "JIS7"
+#define OLDJISSTR "jis"
+#define EUCSTR    "eucJP"
+#define SJISSTR   "SJIS"
+
+#define ESC 27
+#define SS2 142
+
+#ifdef __STDC__
+static void debug(const char *format, ...)
+#else
+static debug(format, ...)
+char *format;
+#endif
+{
+#ifdef DEBUG
+#ifdef HAVE_STDARG_H
+	va_list args;
+
+	va_start(args, format);
+	fprintf(stdout, "%s: ", LIBNAME);
+	vfprintf(stdout, format, args);
+	fprintf(stdout, "\n");
+	va_end(args);
+#endif
+#endif
+}
+
+#ifdef __STDC__
+static void error(const char *format, ...)
+#else
+static error(format, ...)
+char *format;
+#endif
+{
+#ifdef HAVE_STDARG_H
+	va_list args;
+
+	va_start(args, format);
+	fprintf(stderr, "%s: ", LIBNAME);
+	vfprintf(stderr, format, args);
+	fprintf(stderr, "\n");
+	va_end(args);
+#endif
+}
+
+/* DetectKanjiCode() derived from DetectCodeType() by Ken Lunde. */
+
+#ifdef __STDC__
+static int DetectKanjiCode(unsigned char *str)
+#else
+static int DetectKanjiCode(str)
+unsigned char *str;
+#endif
+{
+	static int whatcode;
+	int c, i;
+	char *lang = NULL;
+
+	c = '\1';
+	i = 0;
+
+	if (whatcode == 0) whatcode = ASCII;
+	
+	while ((whatcode == EUCORSJIS || whatcode == ASCII) && c != '\0') {
+		if ((c = str[i++]) != '\0') {
+			if (c == ESC){
+				c = str[i++];
+				if (c == '$') {
+					c = str[i++];
+					if (c == 'B') whatcode = NEW;
+					else
+					if (c == '@') whatcode = OLD;
+				} else
+				if (c == '(') {
+					c = str[i++];
+					if (c == 'I') whatcode = ESCI;
+				} else
+				if (c == 'K') whatcode = NEC;
+			} else
+			if ((c >= 129 && c <= 141) || (c >= 143 && c <= 159))
+				whatcode = SJIS;
+			else
+			if (c == SS2) {
+				c = str[i++];
+				if ((c >= 64 && c <= 126) || (c >= 128 && c <= 160) || (c >= 224 && c <= 252))
+					whatcode = SJIS;
+				else
+				if (c >= 161 && c <= 223)
+					whatcode = EUCORSJIS;
+			} else
+			if (c >= 161 && c <= 223) {
+				c = str[i++];
+				if (c >= 240 && c <= 254) whatcode = EUC;
+				else
+				if (c >= 161 && c <= 223) whatcode = EUCORSJIS;
+				else
+				if (c >= 224 && c <= 239) {
+					whatcode = EUCORSJIS;
+					while (c >= 64 && c != '\0' && whatcode == EUCORSJIS) {
+						if (c >= 129) {
+							if (c <= 141 || (c >= 143 && c <= 159))
+								whatcode = SJIS;
+							else
+							if (c >= 253 && c <= 254)
+								whatcode = EUC;
+						}
+						c = str[i++];
+					}
+				} else
+				if (c <= 159) whatcode = SJIS;
+			} else
+			if (c >= 240 && c <= 254) whatcode = EUC;
+			else
+			if (c >= 224 && c <= 239) {
+				c = str[i++];
+				if ((c >= 64 && c <= 126) || (c >= 128 && c <= 160))
+					whatcode = SJIS;
+				else
+				if (c >= 253 && c >= 254) whatcode = EUC;
+				else
+				if (c >= 161 && c <= 252) whatcode = EUCORSJIS;
+			}
+		}
+	}
+
+#ifdef DEBUG
+	if (whatcode == ASCII)
+		debug("Kanji code not included.");
+	else
+	if (whatcode == EUCORSJIS)
+		debug("Kanji code not detected.");
+	else
+		debug("Kanji code detected at %d byte.", i);
+#endif
+
+	if (whatcode == EUCORSJIS) {
+		if (getenv ("LC_ALL")) lang = getenv ("LC_ALL");
+		else
+		if (getenv ("LC_CTYPE")) lang = getenv ("LC_CTYPE");
+		else
+		if (getenv ("LANG")) lang = getenv ("LANG");
+
+		if (lang) {
+			if (strcmp (lang, "ja_JP.SJIS") == 0 ||
+#ifdef hpux
+				strcmp (lang, "japanese") == 0 ||
+#endif
+					strcmp (lang, "ja_JP.mscode") == 0 ||
+						strcmp (lang, "ja_JP.PCK") == 0)
+				whatcode = SJIS;
+			else
+			if (strncmp (lang, "ja", 2) == 0)
+#ifdef SJISPRE
+				whatcode = SJIS;
+#else
+				whatcode = EUC;
+#endif
+		}
+	}
+
+	if (whatcode == EUCORSJIS)
+#ifdef SJISPRE
+		whatcode = SJIS;
+#else
+		whatcode = EUC;
+#endif
+
+	return whatcode;
+}
+
+/* SJIStoJIS() is sjis2jis() by Ken Lunde. */
+
+#ifdef __STDC__
+static void SJIStoJIS(int *p1, int *p2)
+#else
+static SJIStoJIS(p1, p2)
+int *p1, *p2;
+#endif
+{
+	register unsigned char c1 = *p1;
+	register unsigned char c2 = *p2;
+	register int adjust = c2 < 159;
+	register int rowOffset = c1 < 160 ? 112 : 176;
+	register int cellOffset = adjust ? (31 + (c2 > 127)) : 126;
+
+	*p1 = ((c1 - rowOffset) << 1) - adjust;
+	*p2 -= cellOffset;
+}
+
+/* han2zen() was derived from han2zen() written by Ken Lunde. */
+
+#define IS_DAKU(c) ((c >= 182 && c <= 196) || (c >= 202 && c <= 206) || (c == 179))
+#define IS_HANDAKU(c) (c >= 202 && c <= 206)
+
+#ifdef __STDC__
+static void han2zen(int *p1, int *p2)
+#else
+static han2zen(p1, p2)
+int *p1, *p2;
+#endif
+{
+	int c = *p1;
+	int daku = FALSE;
+	int handaku = FALSE;
+	int mtable[][2] = {
+		{129,66},{129,117},{129,118},{129,65},{129,69},
+		{131,146},
+		{131,64},{131,66},{131,68},{131,70},{131,72},
+		{131,131},{131,133},{131,135},
+		{131,98},{129,91},
+		{131,65},{131,67},{131,69},{131,71},{131,73},
+		{131,74},{131,76},{131,78},{131,80},{131,82},
+		{131,84},{131,86},{131,88},{131,90},{131,92},
+		{131,94},{131,96},{131,99},{131,101},{131,103},
+		{131,105},{131,106},{131,107},{131,108},{131,109},
+		{131,110},{131,113},{131,116},{131,119},{131,122},
+		{131,125},{131,126},{131,128},{131,129},{131,130},
+		{131,132},{131,134},{131,136},
+		{131,137},{131,138},{131,139},{131,140},{131,141},
+		{131,143},{131,147},
+		{129,74},{129,75}
+	};
+
+	if (*p2 == 222 && IS_DAKU(*p1)) daku = TRUE; /* Daku-ten */
+	else
+	if (*p2 == 223 && IS_HANDAKU(*p1)) handaku = TRUE; /* Han-daku-ten */
+
+	*p1 = mtable[c - 161][0];
+	*p2 = mtable[c - 161][1];
+
+	if (daku) {
+		if ((*p2 >= 74 && *p2 <= 103) || (*p2 >= 110 && *p2 <= 122))
+			(*p2)++;
+		else
+		if (*p2 == 131 && *p2 == 69) *p2 = 148;
+	} else
+	if (handaku && *p2 >= 110 && *p2 <= 122) (*p2) += 2;
+}
+
+#ifdef __STDC__
+static void do_convert(unsigned char *to, unsigned char *from, const char *code)
+#else
+static do_convert(to, from, code)
+unsigned char *to, *from;
+char *code;
+#endif
+{
+#ifdef HAVE_ICONV
+	iconv_t cd;
+	size_t from_len, to_len;
+
+	if ((cd = iconv_open(EUCSTR, code)) == (iconv_t)-1) {
+		error("iconv_open() error");
+#ifdef HAVE_ERRNO_H
+		if (errno == EINVAL)
+			error("invalid code specification: \"%s\" or \"%s\"",
+								EUCSTR, code);
+#endif
+		strcpy(to, from);
+		return;
+	}
+
+	from_len = strlen((const char *)from) +1;
+	to_len = BUFSIZ;
+
+	if (iconv(cd, (const char **)&from, &from_len,
+					(char **)&to, &to_len) == -1) {
+#ifdef HAVE_ERRNO_H
+		if (errno == EINVAL) error("invalid end of input string");
+		else
+		if (errno == EILSEQ) error("invalid code in input string");
+		else
+		if (errno == E2BIG)  error("output buffer overflow at do_convert()");
+		else
+#endif
+			error("something happen");
+		strcpy(to, from);
+		return;
+	}
+
+	if (iconv_close(cd) != 0) {
+		error("iconv_close() error");
+	}
+#else
+	int p1, p2, i, j;
+	int jisx0208 = FALSE;
+	int hankaku  = FALSE;
+
+	j = 0;
+	if (strcmp(code, NEWJISSTR) == 0 || strcmp(code, OLDJISSTR) == 0){
+		for(i=0; from[i] != '\0' && j < BUFSIZ; i++){
+			if (from[i] == ESC) {
+				i++;
+				if (from[i] == '$') {
+					jisx0208 = TRUE;
+					hankaku  = FALSE;
+					i++;
+				}else
+				if (from[i] == '(') {
+					jisx0208 = FALSE;
+					i++;
+					if (from[i] == 'I') /* Hankaku Kana */
+						hankaku = TRUE;
+					else
+						hankaku = FALSE;
+				}
+			} else {
+				if (jisx0208)
+					to[j++] = from[i] + 128;
+				else
+				if (hankaku) {
+					to[j++] = SS2;
+					to[j++] = from[i] + 128;
+				}
+				else
+					to[j++] = from[i];
+			}
+		}
+	} else
+	if (strcmp(code, SJISSTR) == 0) {
+		for(i=0; from[i] != '\0' && j < BUFSIZ; i++){
+			p1 = from[i];
+			if (p1 < 127) to[j++] = p1;
+			else
+			if ((p1 >= 161) && (p1 <= 223)) { /* Hankaku Kana */
+				to[j++] = SS2;
+				to[j++] = p1;
+			} else {
+				p2 = from[++i];
+				SJIStoJIS(&p1, &p2);
+				to[j++] = p1 + 128;
+				to[j++] = p2 + 128;
+			}
+		}
+	} else {
+		error("invalid code specification: \"%s\"", code);
+		return;
+	}
+
+	if (j >= BUFSIZ) {
+		error("output buffer overflow at do_convert()");
+		strcpy(to, from);
+	} else
+		to[j] = '\0';
+#endif /* HAVE_ICONV */
+}
+
+#ifdef __STDC__
+static int do_check_and_conv(unsigned char *to, unsigned char *from)
+#else
+static int do_check_and_conv(to, from)
+unsigned char *to, *from;
+#endif
+{
+	static unsigned char tmp[BUFSIZ];
+	int p1, p2, i, j;
+	int kanji = TRUE;
+
+	switch (DetectKanjiCode(from)){
+		case NEW:
+			debug("Kanji code is New JIS.");
+			do_convert(tmp, from, NEWJISSTR);
+			break;
+		case OLD:
+			debug("Kanji code is Old JIS.");
+			do_convert(tmp, from, OLDJISSTR);
+			break;
+		case ESCI:
+			debug("This string includes Hankaku-Kana (jisx0201) escape sequence [ESC] + ( + I.");
+			do_convert(tmp, from, NEWJISSTR);
+			break;
+		case NEC:
+			debug("Kanji code is NEC Kanji.");
+			error("cannot convert NEC Kanji.");
+			strcpy(tmp, from);
+			kanji = FALSE;
+			break;
+		case EUC:
+			debug("Kanji code is EUC.");
+			strcpy(tmp, from);
+			break;
+		case SJIS:
+			debug("Kanji code is SJIS.");
+			do_convert(tmp, from, SJISSTR);
+			break;
+		case EUCORSJIS:
+			debug("Kanji code is EUC or SJIS.");
+			strcpy(tmp, from);
+			kanji = FALSE;
+			break;
+		case ASCII:
+			debug("This is ASCII string.");
+			strcpy(tmp, from);
+			kanji = FALSE;
+			break;
+		default:
+			debug("This string includes unknown code.");
+			strcpy(tmp, from);
+			kanji = FALSE;
+			break;
+	}
+
+	/* Hankaku Kana ---> Zenkaku Kana */
+	if (kanji) {
+		j = 0;
+		for(i = 0; tmp[i] != '\0'&& j < BUFSIZ; i++) {
+			if (tmp[i] == SS2) {
+				p1 = tmp[++i];
+				if (tmp[i+1] == SS2) {
+					p2 = tmp[i+2]; 
+					if (p2 == 222 || p2 == 223) i += 2;
+					else p2 = 0;
+				} else p2 = 0;
+				han2zen(&p1, &p2);
+				SJIStoJIS(&p1, &p2);
+				to[j++] = p1 + 128;
+				to[j++] = p2 + 128;
+			} else
+				to[j++] = tmp[i];
+		}
+
+		if (j >= BUFSIZ) {
+			error("output buffer overflow at Hankaku --> Zenkaku");
+			strcpy(to, tmp);
+		} else
+			to[j] = '\0';
+	} else
+		strcpy(to, tmp);
+
+	return kanji;
+}
+
+#ifdef __STDC__
+int any2eucjp(unsigned char *dest, unsigned char *src, unsigned int dest_max)
+#else
+int any2eucjp(dest, src, dest_max)
+unsigned char *dest, *src;
+unsigned int dest_max;
+#endif
+{
+	static unsigned char tmp_dest[BUFSIZ];
+	int ret;
+
+	if (strlen((const char *)src) >= BUFSIZ) {
+		error("input string too large");
+		return -1;
+	}
+	if (dest_max > BUFSIZ) {
+		error("invalid maximum size of destination\nit should be less than %d.", BUFSIZ);
+		return -1;
+	}
+	ret = do_check_and_conv(tmp_dest, src);
+	if (strlen((const char *)tmp_dest) >= dest_max) {
+		error("output buffer overflow");
+		strcpy(dest, src);
+		return -1;
+	}
+	strcpy(dest, tmp_dest);
+	return ret;
+}
+
+#if 0
+#ifdef __STDC__
+unsigned int strwidth(unsigned char *s)
+#else
+unsigned int strwidth(s)
+unsigned char *s;
+#endif
+{
+	unsigned char *t;
+	unsigned int i;
+
+	t = (unsigned char *)malloc(BUFSIZ);
+	any2eucjp(t, s, BUFSIZ);
+	i = strlen(t);
+	free(t);
+	return i;
+}
+#endif
+
+#ifdef DEBUG
+int main()
+{
+	unsigned char input[BUFSIZ];
+	unsigned char *output;
+	unsigned char *str;
+	int c, i = 0;
+
+	while ( (c = fgetc(stdin)) != '\n' && i < BUFSIZ ) input[i++] = c;
+	input[i] = '\0';
+
+	printf("input : %d bytes\n", strlen(input));
+	printf("output: %d bytes\n", strwidth(input));
+
+	output = (unsigned char *)malloc(BUFSIZ);
+	any2eucjp(output, input, BUFSIZ);
+	str = output;
+	while(*str != '\0') putchar(*(str++));
+	putchar('\n');
+	free(output);
+
+	return 0;
+}
+#endif
+int gdCosT[] = {
+  1024,
+  1023,
+  1023,
+  1022,
+  1021,
+  1020,
+  1018,
+  1016,
+  1014,
+  1011,
+  1008,
+  1005,
+  1001,
+  997,
+  993,
+  989,
+  984,
+  979,
+  973,
+  968,
+  962,
+  955,
+  949,
+  942,
+  935,
+  928,
+  920,
+  912,
+  904,
+  895,
+  886,
+  877,
+  868,
+  858,
+  848,
+  838,
+  828,
+  817,
+  806,
+  795,
+  784,
+  772,
+  760,
+  748,
+  736,
+  724,
+  711,
+  698,
+  685,
+  671,
+  658,
+  644,
+  630,
+  616,
+  601,
+  587,
+  572,
+  557,
+  542,
+  527,
+  512,
+  496,
+  480,
+  464,
+  448,
+  432,
+  416,
+  400,
+  383,
+  366,
+  350,
+  333,
+  316,
+  299,
+  282,
+  265,
+  247,
+  230,
+  212,
+  195,
+  177,
+  160,
+  142,
+  124,
+  107,
+  89,
+  71,
+  53,
+  35,
+  17,
+  0,
+  -17,
+  -35,
+  -53,
+  -71,
+  -89,
+  -107,
+  -124,
+  -142,
+  -160,
+  -177,
+  -195,
+  -212,
+  -230,
+  -247,
+  -265,
+  -282,
+  -299,
+  -316,
+  -333,
+  -350,
+  -366,
+  -383,
+  -400,
+  -416,
+  -432,
+  -448,
+  -464,
+  -480,
+  -496,
+  -512,
+  -527,
+  -542,
+  -557,
+  -572,
+  -587,
+  -601,
+  -616,
+  -630,
+  -644,
+  -658,
+  -671,
+  -685,
+  -698,
+  -711,
+  -724,
+  -736,
+  -748,
+  -760,
+  -772,
+  -784,
+  -795,
+  -806,
+  -817,
+  -828,
+  -838,
+  -848,
+  -858,
+  -868,
+  -877,
+  -886,
+  -895,
+  -904,
+  -912,
+  -920,
+  -928,
+  -935,
+  -942,
+  -949,
+  -955,
+  -962,
+  -968,
+  -973,
+  -979,
+  -984,
+  -989,
+  -993,
+  -997,
+  -1001,
+  -1005,
+  -1008,
+  -1011,
+  -1014,
+  -1016,
+  -1018,
+  -1020,
+  -1021,
+  -1022,
+  -1023,
+  -1023,
+  -1024,
+  -1023,
+  -1023,
+  -1022,
+  -1021,
+  -1020,
+  -1018,
+  -1016,
+  -1014,
+  -1011,
+  -1008,
+  -1005,
+  -1001,
+  -997,
+  -993,
+  -989,
+  -984,
+  -979,
+  -973,
+  -968,
+  -962,
+  -955,
+  -949,
+  -942,
+  -935,
+  -928,
+  -920,
+  -912,
+  -904,
+  -895,
+  -886,
+  -877,
+  -868,
+  -858,
+  -848,
+  -838,
+  -828,
+  -817,
+  -806,
+  -795,
+  -784,
+  -772,
+  -760,
+  -748,
+  -736,
+  -724,
+  -711,
+  -698,
+  -685,
+  -671,
+  -658,
+  -644,
+  -630,
+  -616,
+  -601,
+  -587,
+  -572,
+  -557,
+  -542,
+  -527,
+  -512,
+  -496,
+  -480,
+  -464,
+  -448,
+  -432,
+  -416,
+  -400,
+  -383,
+  -366,
+  -350,
+  -333,
+  -316,
+  -299,
+  -282,
+  -265,
+  -247,
+  -230,
+  -212,
+  -195,
+  -177,
+  -160,
+  -142,
+  -124,
+  -107,
+  -89,
+  -71,
+  -53,
+  -35,
+  -17,
+  0,
+  17,
+  35,
+  53,
+  71,
+  89,
+  107,
+  124,
+  142,
+  160,
+  177,
+  195,
+  212,
+  230,
+  247,
+  265,
+  282,
+  299,
+  316,
+  333,
+  350,
+  366,
+  383,
+  400,
+  416,
+  432,
+  448,
+  464,
+  480,
+  496,
+  512,
+  527,
+  542,
+  557,
+  572,
+  587,
+  601,
+  616,
+  630,
+  644,
+  658,
+  671,
+  685,
+  698,
+  711,
+  724,
+  736,
+  748,
+  760,
+  772,
+  784,
+  795,
+  806,
+  817,
+  828,
+  838,
+  848,
+  858,
+  868,
+  877,
+  886,
+  895,
+  904,
+  912,
+  920,
+  928,
+  935,
+  942,
+  949,
+  955,
+  962,
+  968,
+  973,
+  979,
+  984,
+  989,
+  993,
+  997,
+  1001,
+  1005,
+  1008,
+  1011,
+  1014,
+  1016,
+  1018,
+  1020,
+  1021,
+  1022,
+  1023,
+  1023
+};
+
+int gdSinT[] = {
+  0,
+  17,
+  35,
+  53,
+  71,
+  89,
+  107,
+  124,
+  142,
+  160,
+  177,
+  195,
+  212,
+  230,
+  247,
+  265,
+  282,
+  299,
+  316,
+  333,
+  350,
+  366,
+  383,
+  400,
+  416,
+  432,
+  448,
+  464,
+  480,
+  496,
+  512,
+  527,
+  542,
+  557,
+  572,
+  587,
+  601,
+  616,
+  630,
+  644,
+  658,
+  671,
+  685,
+  698,
+  711,
+  724,
+  736,
+  748,
+  760,
+  772,
+  784,
+  795,
+  806,
+  817,
+  828,
+  838,
+  848,
+  858,
+  868,
+  877,
+  886,
+  895,
+  904,
+  912,
+  920,
+  928,
+  935,
+  942,
+  949,
+  955,
+  962,
+  968,
+  973,
+  979,
+  984,
+  989,
+  993,
+  997,
+  1001,
+  1005,
+  1008,
+  1011,
+  1014,
+  1016,
+  1018,
+  1020,
+  1021,
+  1022,
+  1023,
+  1023,
+  1024,
+  1023,
+  1023,
+  1022,
+  1021,
+  1020,
+  1018,
+  1016,
+  1014,
+  1011,
+  1008,
+  1005,
+  1001,
+  997,
+  993,
+  989,
+  984,
+  979,
+  973,
+  968,
+  962,
+  955,
+  949,
+  942,
+  935,
+  928,
+  920,
+  912,
+  904,
+  895,
+  886,
+  877,
+  868,
+  858,
+  848,
+  838,
+  828,
+  817,
+  806,
+  795,
+  784,
+  772,
+  760,
+  748,
+  736,
+  724,
+  711,
+  698,
+  685,
+  671,
+  658,
+  644,
+  630,
+  616,
+  601,
+  587,
+  572,
+  557,
+  542,
+  527,
+  512,
+  496,
+  480,
+  464,
+  448,
+  432,
+  416,
+  400,
+  383,
+  366,
+  350,
+  333,
+  316,
+  299,
+  282,
+  265,
+  247,
+  230,
+  212,
+  195,
+  177,
+  160,
+  142,
+  124,
+  107,
+  89,
+  71,
+  53,
+  35,
+  17,
+  0,
+  -17,
+  -35,
+  -53,
+  -71,
+  -89,
+  -107,
+  -124,
+  -142,
+  -160,
+  -177,
+  -195,
+  -212,
+  -230,
+  -247,
+  -265,
+  -282,
+  -299,
+  -316,
+  -333,
+  -350,
+  -366,
+  -383,
+  -400,
+  -416,
+  -432,
+  -448,
+  -464,
+  -480,
+  -496,
+  -512,
+  -527,
+  -542,
+  -557,
+  -572,
+  -587,
+  -601,
+  -616,
+  -630,
+  -644,
+  -658,
+  -671,
+  -685,
+  -698,
+  -711,
+  -724,
+  -736,
+  -748,
+  -760,
+  -772,
+  -784,
+  -795,
+  -806,
+  -817,
+  -828,
+  -838,
+  -848,
+  -858,
+  -868,
+  -877,
+  -886,
+  -895,