>> Delete Reply from No. 11917 article
No. RE: [요청]cgi로gd라이브리를 이용하여 그래프를
그릴려고 합니다..도와주세요..

등록 2000-11-19 10:37:00 By localhost     조회 2
이름 이실    

		예제 소스는 라이브러리 소스를 받으시면 그안에 같이 들어있습니다.
 아래가 그 소스입니다.
 gddemo.c
 #include <stdio.h>
#include "gd.h"
#include "gdfontg.h"
#include "gdfonts.h"
 int main(void)
{
        /* Input and output files */
        FILE *in;
        FILE *out;
         /* Input and output images */
        gdImagePtr im_in, im_out;
         /* Brush image */
        gdImagePtr brush;
         /* Color indexes */
        int white;
        int blue;
        int red;
        int green;
         /* Points for polygon */
        gdPoint points[3];
         /* Create output image, 128 by 128 pixels. */
        im_out = gdImageCreate(128, 128);
         /* First color allocated is background. */
        white = gdImageColorAllocate(im_out, 255, 255, 255);
         /* Set transparent color. */
        gdImageColorTransparent(im_out, white);
         /* Try to load demoin.gif and paste part of it into the
                output image. */
         in = fopen("demoin.gif", "rb");
        if (!in) {
                fprintf(stderr, "Can't load source image; this demo");
                fprintf(stderr, "is much more impressive if demoin.gif");
                fprintf(stderr, "is available.");
                im_in = 0;
        } else {
                im_in = gdImageCreateFromGif(in);
                fclose(in);
                /* Now copy, and magnify as we do so */
                gdImageCopyResized(im_out, im_in,
                        16, 16, 0, 0, 96, 96, 127, 127);
        }
        red = gdImageColorAllocate(im_out, 255, 0, 0);
        green = gdImageColorAllocate(im_out, 0, 255, 0);
        blue = gdImageColorAllocate(im_out, 0, 0, 255);
        /* Rectangle */
        gdImageLine(im_out, 8, 8, 120, 8, green);
        gdImageLine(im_out, 120, 8, 120, 120, green);
        gdImageLine(im_out, 120, 120, 8, 120, green);
        gdImageLine(im_out, 8, 120, 8, 8, green);
        /* Circle */
        gdImageArc(im_out, 64, 64, 30, 10, 0, 360, blue);
        /* Arc */
        gdImageArc(im_out, 64, 64, 20, 20, 45, 135, blue);
        /* Flood fill */
        gdImageFill(im_out, 4, 4, blue);
        /* Polygon */
        points[0].x = 32;
        points[0].y = 0;
        points[1].x = 0;
        points[1].y = 64;
        points[2].x = 64;
        points[2].y = 64;
        gdImageFilledPolygon(im_out, points, 3, green);
        /* Brush. A fairly wild example also involving a line style! */
        if (im_in) {
                int style[8];
                brush = gdImageCreate(8, 8);
                gdImageCopyResized(brush, im_in,
                        0, 0, 0, 0,
                        gdImageSX(brush), gdImageSY(brush),
                        gdImageSX(im_in), gdImageSY(im_in));
                gdImageSetBrush(im_out, brush);
                /* With a style, so they won't overprint each other.
                        Normally, they would, yielding a fat-brush effect. */
                style[0] = 0;
                style[1] = 0;
                style[2] = 0;
                style[3] = 0;
                style[4] = 0;
                style[5] = 0;
                style[6] = 0;
                style[7] = 1;
                gdImageSetStyle(im_out, style, 8);
                /* Draw the styled, brushed line */
                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);
        /* Make output image interlaced (allows "fade in" in some viewers,
                and in the latest web browsers) */
        gdImageInterlace(im_out, 1);
        out = fopen("demoout.gif", "wb");
        /* Write GIF */
        gdImageGif(im_out, out);
        fclose(out);
        gdImageDestroy(im_out);
        if (im_in) {
                gdImageDestroy(im_in);
        }
        return 0;
}
  : cgi로 gd라이브리를 이용하여 간단한 그래프를 그리고 싶어요..
: 고수님들...간단한 소스 좀 부탁할께요...
: 도와주세요...
:
: perl말고 c를 소스를 원합니다...
: 그럼 수거하세요...
[관리자] 패스워드를 입력 하십시오. 답장이 존재하면 함께 삭제됩니다.[ 목록 | 이전 ]
패스워드:    

Copyleft 1999-2026 by JSBoard Open Project
Theme Designed by IDOO All right reserved