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);
}
-
[c++] 레지스트리 등록 예제
-
[c++] 레지스트리 편집하는 부분..ㅡㅡ;
-
[c++] 링크리스트(linked list) 클래스(스택,큐)
-
[c++] 마방진 소스코드
-
[c++] 문자열 뒤집기(문자열 거꾸로 출력)
-
[c++] 바탕화면 테두리에 자석처럼 붙는 스냅효과..
-
[c++] 소켓 프로그래밍 관련 링크.. (퍼올려고 올린거)
-
[c++] 쓰레드(Thread) 객체의 사용
-
[c++] 압축프로그램(Lite Zip) 샘플
-
[c++] 웹폼(webform)전송과 http 파일 업로드 샘플
-
[c++] 윈도우 API 정복 예제
-
[c++] 윈도우 프로세스뷰어 분석.. ㅋㅋ