Contents

조회 수 15107 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
제가 전에 했던 작업중 샘플입니다.
Web상에서 Counter를 jpeg로 만들어서 뿌려주던 것입니다. 

#include "gd.h" 
#include "gdfontl.h"
    
void outCounter(long lTotal, long lToday)
{   
    gdImagePtr im;
    FILE *pngout, *jpegout;
    int black, white, back, blue;
    int nTextColor;

    int brect[8];
    int x, y, nXTop, nYLeft;
    int nSizeX, nSizeY;
    char s[40];
    char *f = "/usr/share/fonts/user/hatten.ttf";
    double sz = 12.;
    char *err; 

    sprintf(s, "Today:%08ld / Total:%08ld", lToday, lTotal);
    err = gdImageStringTTF(NULL,&brect[0],0,f,sz,0.,0,0,s);
    
    nSizeX = 180;
    nSizeY = brect[3]-brect[7] + 6;
    
    im = gdImageCreate(nSizeX, nSizeY);

    black = gdImageColorAllocate(im, 0, 0, 0);
    white = gdImageColorAllocate(im, 255, 255, 255);
    back = gdImageColorAllocate(im, 200, 200, 200);
    blue = gdImageColorAllocate(im, 211, 212, 223);
    nTextColor = gdImageColorAllocate(im, 12, 4, 89);

    gdImageFill(im, 1, 1, blue);

    nXTop = 5-brect[6];
    nYLeft = 13; 

    err = gdImageStringTTF(im,&brect[0],nTextColor,f,sz,0.0,nXTop,nYLeft,s);
    if (err) {fprintf(stderr,err); return;}
    
    printf("Content-type: image/jpeg\n\n");
    gdImageJpeg(im, stdout, -1);
    
    gdImageDestroy(im);
}


?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
837 Develop [jsp] RSS(xml) 파싱해서 보여주기 ㅎㅎ file hooni 2013.04.23 13217
836 System/OS [linux] 아파치설치/설정 - SSI(Server Side Include) hooni 2003.04.23 13207
835 Develop [ios] App States file hooni 2013.07.22 13195
834 PPT [js] xsl 강의 자료 file hooni 2013.04.23 13186
833 System/OS [linux] 계정관리하기(내공쌓기) hooni 2003.04.23 13163
832 System/OS [linux] 한글 URL 인식할 수 있게 아파치(Apache) 설정 (mod_url.c 설치) hooni 2013.04.23 13067
831 System/OS [linux] Proftpd 설치 가이드 hooni 2003.04.23 13030
830 Develop [html] 캐쉬된 웹페이지 사용하지 않도록 하는 방법 hooni 2003.04.23 13029
829 System/OS [linux] ipfwadm를 이용한 패킷필터링(구버전) hooni 2003.04.23 13025
828 System/OS [linux] DHCP(Dynamic Host Configuration Protocol) 서버 hooni 2003.04.23 13024
827 Develop [js] AngularJS를 소개합니다. file hooni 2014.01.06 13017
826 Develop [php] 심플한 게시판 ㅋㅋ 1 file hooni 2013.04.23 12995
Board Pagination Prev 1 ... 24 25 26 27 28 29 30 31 32 33 ... 98 Next
/ 98