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 [mysql] 양력, 음력 DB데이터 file hooni 2013.04.23 7802
836 Develop [c] 디피-헬만 키교환(Diffie–Hellman key exchange) 샘플 코드.. ㅋㄷ file hooni 2013.04.23 9109
835 Develop [switch] 시스코 스위치(catalyst 2950) telnet 설정 hooni 2013.04.23 11268
834 Develop [c] 맵서치인 듯(옛날 컴에서 찾은 자료) file hooni 2013.04.23 6904
833 System/OS [linux] 파일내 문자열 찾아 바꾸기 hooni 2013.04.23 12194
832 PPT [network] tcp/ip 설명 html파일 9장(ppt 포함) file hooni 2013.04.23 11648
831 Develop [js] 윈도우 시작버튼처럼 나오는 메뉴 file hooni 2013.04.23 6743
830 PPT [doc] 위탁과제 제안서와 발표자료(pdf) file hooni 2013.04.23 12532
829 Develop [js] 네이버, 다음의 플레이어 스킨 file hooni 2013.04.23 6942
828 Develop [js] 2차 잉여.. (Quadratic reciprocity) 계산.. file hooni 2013.04.23 7075
827 Develop JSON, BSON 변환 file hooni 2013.04.23 11814
» Develop [c] GD라이브러리(jpeg)를 사용한 웹 카운터 샘플 hooni 2013.04.23 15107
Board Pagination Prev 1 ... 24 25 26 27 28 29 30 31 32 33 ... 98 Next
/ 98