Contents

Views 16372 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
제가 전에 했던 작업중 샘플입니다.
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
No. Category Subject Author Date Views
241 Develop 프로그래밍 소스 관련 사이트.. hooni 2013.04.23 17900
240 Develop [ios] PHP로 APNS 프로바이더~ file hooni 2013.06.27 17940
239 Develop [winmobile] 윈도우 모바일 간단한 테스트 코드 ㅋㅋ file hooni 2013.04.23 17954
238 PPT [ppt] 웜프레임워크 발표 양식(국보연) file hooni 2013.04.23 17960
237 Develop [unix] 쉘 스크립트 예제 모음 hooni 2003.04.23 17975
236 System/OS [switch] 시스코 스위치 관리자 암호 초기화 방법 hooni 2013.04.23 18026
235 PPT [doc] 논문.. VoIP 관련.. ㅋㅋ file hooni 2013.04.23 18042
234 Algorithm [security] RSA 암호화 설명과 예.. hooni 2013.04.23 18061
233 Develop [c++] 문자열 뒤집기(문자열 거꾸로 출력) hooni 2013.04.23 18079
232 Develop [c] ICMP 패킷을 이용한 장난감 hooni 2003.04.23 18126
231 Develop [java] 입출력 스트림 1부 (문자) file hooni 2013.04.23 18154
230 Develop [c] 팩토리얼 서버/클라이언트.. file hooni 2003.04.23 18265
Board Pagination Prev 1 ... 74 75 76 77 78 79 80 81 82 83 ... 99 Next
/ 99