/**************************************************************************** gctr0.c 1997/09/30 Ver.0.01 1997/10/01 Ver.0.02 (C) 1997 がま e-mail addr : gama@mvg.biglobe.ne.jp ****************************************************************************/ #include "gd.h" #include <stdio.h> #include <string.h> char ctrstr[BUFSIZ] ="0123456789"; char filename[BUFSIZ] ="strip.gif"; /***************************************************************************/ int main(int argc, char * argv[]) { FILE * fpin; gdImagePtr imgout, imgin; int i, j; int outwidth; int outheight; int digitwidth; if ( argc > 1) { strcpy(ctrstr, argv[1]); } if ( argc > 2) { strcpy(filename, argv[2]); } /* file を open */ fpin = fopen(filename, "rb"); /* .gif ファイルを読み込む */ imgin = gdImageCreateFromGif(fpin); /* .gif ファイルを閉じる */ fclose(fpin); /* digitwidth: 数字の幅 入力の gif の 1/10 */ digitwidth = gdImageSX(imgin)/10; /* outwidth : イメージの幅 */ outwidth = digitwidth * strlen(ctrstr); /* outheight : イメージの高さ 入力の gif と同じ */ outheight = gdImageSY(imgin); /* 幅と高さを指定して gdImage を作成する。 */ imgout = gdImageCreate(outwidth, outheight); /* 位置を指定してコピーする gdImageCopy (コピー先, コピー元, 先の位置 x, y, 元の位置 x, y, 幅, 高さ ) */ i=0; while (ctrstr[i] != 0 ) { j=ctrstr[i]-'0'; gdImageCopy(imgout, imgin, digitwidth * i, 0, digitwidth * j, 0, digitwidth, outheight); i++; } /* お約束のヘッダー */ printf ( "Content-type: image/gif\n\n"); /* gdImage を出力する */ gdImageGif(imgout, stdout); fflush(stdout); gdImageDestroy(imgin); gdImageDestroy(imgout); return 0; }