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 [js] AngularJS를 소개합니다. file hooni 2014.01.06 13017
836 Etc [용어] POC, Pilot, BMT에 대한 IT 업계에서 통용되는 의미 hooni 2014.01.02 41963
835 Develop [php] 하루 전 날짜 쉽게 구하기. hooni 2013.12.25 12219
834 Develop [php] GregorianToJD(), JDToGregorian() 함수 내용 hooni 2013.12.25 10596
833 System/OS [linux] root 전환시 패스워드 없이 su 사용하기 hooni 2013.12.22 12688
832 System/OS [linux] CentOS 터미널 언어 설정(한글/영어) hooni 2013.12.22 18517
831 Develop [js] jQuery plugin 요약 hooni 2013.12.20 10703
830 Develop [css] z-index에 설정할 수 있는 최대값? hooni 2013.12.20 14720
829 Database [oracle] SQL문 실행 방법 3가지 file hooni 2013.12.19 12126
828 System/OS CentOS 6.5 USB 설치 6 file hooni 2013.12.18 37682
827 Develop [js] 이벤트 전파 3단계 hooni 2013.12.18 9966
826 Develop [js] jQuery 치트 시트 hooni 2013.12.18 36256
Board Pagination Prev 1 ... 24 25 26 27 28 29 30 31 32 33 ... 98 Next
/ 98