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
번호 분류 제목 글쓴이 날짜 조회 수
357 Develop [html] HTML5 튜토리얼 링크 ㅋㅋ hooni 2013.04.23 12809
356 System/OS [linux] 콘솔 기본언어 설정 방법 hooni 2013.04.23 12824
355 System/OS [sql] 내 방명록 답글 찾는 쿼리문.. (JOIN 구문) hooni 2003.04.23 12845
354 System/OS [linux] ProFTPD 타임아웃 설정 hooni 2003.04.23 12851
353 Develop [doc] UI개발시 유용한 소프트웨어 (개발 및 디버깅 툴) hooni 2013.04.23 12905
352 Develop [c] 다중연결 서버 만들기 #1 - fork() 사용 file hooni 2013.04.23 12917
351 System/OS [router] 시스코 라우터 명령어 모드.. hooni 2013.04.23 12944
350 System/OS [linux] 아파치 설치/설정(proxy) hooni 2003.04.23 12965
349 Develop [js] 자바스크립트의 클로저 (JavaScript's Closure) hooni 2013.05.15 12975
348 Develop [php] 심플한 게시판 ㅋㅋ 1 file hooni 2013.04.23 12980
347 Develop [js] AngularJS를 소개합니다. file hooni 2014.01.06 13010
346 System/OS [linux] ipfwadm를 이용한 패킷필터링(구버전) hooni 2003.04.23 13011
Board Pagination Prev 1 ... 64 65 66 67 68 69 70 71 72 73 ... 98 Next
/ 98