Contents

Views 15107 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
897 Develop [ios] 아이폰에서 진동(Vibrate) 기능 추가하기 hooni 2014.04.18 3461
896 System/OS [android] 초간단 HTTP, POST 전송 샘플 1 file hooni 2017.02.16 3469
895 Develop [js] jQuery 셀 병합 1 file hooni 2014.09.23 3494
894 Etc 영어. 불규칙 동사 정리 file hooni 2017.10.04 3513
893 Develop [ios] iOS에서 디바이스 종류 알아오기 hooni 2014.05.24 3650
892 Develop [ios] 유용한 매크로 hooni 2014.03.26 3654
891 Develop [ios] UIWebView 캐쉬 삭제 hooni 2014.04.08 3668
890 Develop [ios] URL 파라미터 파싱~ hooni 2014.05.12 3676
889 Develop [ios] SQLite 사용하기(튜토리얼) + 샘플코드 file hooni 2014.03.28 3703
888 Develop [php] 3 Ways to Detect Mobile or Desktop in PHP file hooni 2020.01.28 3724
887 Develop [ios] iOS 의 인앱구매 소개 file hooni 2014.04.29 3831
886 Develop [android] 코드에서 문자열로 Resource 가져오기 hooni 2015.07.09 3943
Board Pagination Prev 1 ... 19 20 21 22 23 24 25 26 27 28 ... 98 Next
/ 98