Develop
2013.04.23 13:30
[c] GD라이브러리(jpeg)를 사용한 웹 카운터 샘플
Views 15133 Comment 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);
}
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
613 | Develop | [js] get방식, url이후 모두 그대로 읽어오기.. | hooni | 2013.04.23 | 6875 |
612 | Develop |
[js] e.stopPropagation() VS e.preventDefault ()
![]() |
hooni | 2015.04.14 | 920 |
611 | Develop | [js] Closure를 이용해 캡슐화.. | hooni | 2013.12.16 | 9625 |
610 | Develop | [js] Click button copy to clipboard | hooni | 2018.04.05 | 1309 |
609 | Develop | [js] Array.splice() 설명 | hooni | 2014.04.24 | 3072 |
608 | Develop |
[js] AngularJS를 소개합니다.
![]() |
hooni | 2014.01.06 | 13057 |
607 | Develop |
[js] AngularJS 란?
![]() |
hooni | 2015.11.26 | 1045 |
606 | Develop | [js] ajax를 이용해 외부문서 불러오기.. | hooni | 2013.04.23 | 6814 |
605 | Develop |
[js] 2차 잉여.. (Quadratic reciprocity) 계산..
![]() |
hooni | 2013.04.23 | 7100 |
604 | Develop |
[js] 2048 예쁘게 만들고 있는거.. ㅋㄷ
![]() |
hooni | 2015.01.30 | 0 |
603 | Develop |
[jsp][php] 간단한 강좌 자료..
![]() |
hooni | 2003.04.23 | 8162 |
602 | Develop |
[jsp][php] LDAP 프로그래밍..
![]() |
hooni | 2003.04.23 | 7419 |