Develop
2013.04.23 13:30
[c] GD라이브러리(jpeg)를 사용한 웹 카운터 샘플
조회 수 15107 댓글 0
제가 전에 했던 작업중 샘플입니다.
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);
}
-
[doc] 인공지능 관련 자료(채팅로봇도 포함..)
-
[web] 웹서비스 취약점 자료.. (논문첨부)
-
[linux] 리눅스,유닉스 /proc/stat 파일 보는 법
-
[linux] 커널 컴파일, 설정
-
[windows] 도스 사용 팁
-
[c#] 정규표현식을 이용한 문자열에서 태그 제거함수
-
[ios] Debug Extensions (from 종길 차장님 ㅋㅋ)
-
[ios] 자주 쓰는 패턴과 API
-
네트워크별 MTU(최대 전송 단위)
-
무선 인증 서버.. 김도.. ㅋㅋ
-
GSM에서 음성이 실리는 과정 요약..
-
[php] 프레임워크 발표자료 및 샘플 구현 소스