Contents

Views 15128 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
193 Develop [ios] 아이폰에서 진동(Vibrate) 기능 추가하기 hooni 2014.04.18 3535
192 Develop [js] Array.splice() 설명 hooni 2014.04.24 3064
191 Develop [ios] iOS 의 인앱구매 소개 file hooni 2014.04.29 3900
190 Develop [ios] 커스텀 폰트 사용하기 (Custom Fonts) file hooni 2014.04.30 3191
189 Develop [ios] NSString URL Encode/Decode (인코딩/디코딩) hooni 2014.05.02 3493
188 Develop [ios] 애플 앱스토어 IDFA 리뷰 정책 변경 안내 file hooni 2014.05.07 4246
187 Develop [ios] 앱딜리게이트 라이프사이클 (AppDelegate Lifecycle) file hooni 2014.05.09 4516
186 Develop [ios] 앱 딜리게이트 얻어오기. (AppDelegate) hooni 2014.05.10 3406
185 Develop [ios] URL 파라미터 파싱~ hooni 2014.05.12 3738
184 Develop [ios] 언어, 지역, 국가 설정 가져오기 hooni 2014.05.12 271764
183 Develop [ios] 아이폰 GPS 사용하기 hooni 2014.05.24 4048
182 Develop [ios] iOS에서 디바이스 종류 알아오기 hooni 2014.05.24 3759
Board Pagination Prev 1 ... 50 51 52 53 54 55 56 57 58 59 ... 71 Next
/ 71