35#define IMGPTR(O) (O->internalRep.otherValuePtr)
48 Tcl_Obj *
const objv[]);
49typedef int(
GdImgFunction)(Tcl_Interp *interp, gdImagePtr gdImg,
int argc,
81 {
"createTrueColor",
tclGdCreateCmd, 2, 2, 0, 0, 2,
"width height"},
101 {
"writeGD",
tclGdWriteCmd, 2, 2, 0, 1, 3,
"gdhandle filehandle"},
103 {
"writeGD2",
tclGdWriteCmd, 2, 2, 0, 1, 3,
"gdhandle filehandle"},
106 {
"writeGIF",
tclGdWriteCmd, 2, 2, 0, 1, 3,
"gdhandle filehandle"},
109 {
"writeJPEG",
tclGdWriteCmd, 2, 2, 0, 1, 3,
"gdhandle filehandle"},
112 {
"writePNG",
tclGdWriteCmd, 2, 2, 0, 1, 3,
"gdhandle filehandle"},
114 {
"writeWBMP",
tclGdWriteCmd, 2, 2, 0, 1, 3,
"gdhandle filehandle"},
116 {
"writeXBM",
tclGdWriteCmd, 2, 2, 0, 1, 3,
"gdhandle filehandle"},
123 {
"brush",
tclGdBrushCmd, 2, 2, 0, 2, 0,
"gdhandle brushhandle"},
124 {
"style",
tclGdStyleCmd, 2, 999, 0, 1, 0,
"gdhandle color..."},
125 {
"tile",
tclGdTileCmd, 2, 2, 0, 2, 0,
"gdhandle tilehandle"},
126 {
"set",
tclGdSetCmd, 4, 4, 0, 1, 0,
"gdhandle color x y"},
127 {
"line",
tclGdLineCmd, 6, 6, 0, 1, 0,
"gdhandle color x1 y1 x2 y2"},
128 {
"rectangle",
tclGdRectCmd, 6, 6, 0, 1, 0,
"gdhandle color x1 y1 x2 y2"},
130 "gdhandle color x1 y1 x2 y2"},
132 "gdhandle color cx cy width height start end"},
134 "gdhandle color cx cy width height start end"},
136 "gdhandle color cx cy width height start end"},
138 "gdhandle color cx cy width height start end"},
140 "gdhandle color cx cy width height start end"},
142 "gdhandle color cx cy width height start end"},
144 "gdhandle color cx cy width height start end"},
146 "gdhandle color cx cy width height start end"},
148 "gdhandle color cx cy width height start end"},
150 "gdhandle color x1 y1 x2 y2 x3 y3 ..."},
152 "gdhandle color x1 y1 x2 y2 x3 y3 ..."},
153 {
"fill",
tclGdFillCmd, 4, 5, 0, 1, 0,
"gdhandle color x y ?bordercolor?"},
160 "gdhandle color fontname size angle x y string"},
162 "desthandle srchandle destx desty srcx srcy destw desth ?srcw srch?"},
163 {
"get",
tclGdGetCmd, 3, 3, 0, 1, 0,
"gdhandle x y"},
180 int nlist, retval = TCL_OK;
182 char *firsttag, *secondtag;
185 if (Tcl_GetIntFromObj(interp, obj,
color) == TCL_OK)
188 Tcl_ResetResult(interp);
189 if (Tcl_ListObjGetElements(interp, obj, &nlist, &theList) != TCL_OK)
191 if (nlist < 1 || nlist > 2)
194 firsttag = Tcl_GetString(theList[0]);
195 switch (firsttag[0]) {
199 secondtag = Tcl_GetString(theList[1]);
200 if (secondtag[0] ==
's') {
201 *
color = gdStyledBrushed;
211 secondtag = Tcl_GetString(theList[1]);
212 if (secondtag[0] ==
'b') {
213 *
color = gdStyledBrushed;
229 if (retval == TCL_ERROR)
230 Tcl_SetResult(interp,
"Malformed special color value", TCL_STATIC);
350static int gdCmd(ClientData clientData, Tcl_Interp *interp,
int argc,
351 Tcl_Obj *
const objv[]) {
356 Tcl_SetResult(interp,
"wrong # args: should be \"gd option ...\"",
367 (unsigned)argc - 2 >
subcmdVec[subi].maxargs) {
377 Tcl_SetResult(interp,
"GD handle(s) not specified", TCL_STATIC);
394 const char *
fname = Tcl_GetString(objv[
subcmdVec[subi].unsafearg]);
395 if (!Tcl_IsChannelExisting(
fname)) {
396 Tcl_AppendResult(interp,
"Access to ",
fname,
397 " not allowed in safe interpreter",
NULL);
402 return (*
subcmdVec[subi].f)(interp, argc, objv);
407 Tcl_AppendResult(interp,
"bad option \"", Tcl_GetString(objv[1]),
408 "\": should be ", 0);
410 Tcl_AppendResult(interp, (subi > 0 ?
", " :
""),
subcmdVec[subi].
cmd, 0);
416 gdImagePtr im =
NULL;
421 cmd = Tcl_GetString(objv[1]);
424 if (Tcl_GetIntFromObj(interp, objv[2], &w) != TCL_OK)
426 if (Tcl_GetIntFromObj(interp, objv[3], &h) != TCL_OK)
430 Tcl_GetBooleanFromObj(interp, objv[4], &trueColor) == TCL_ERROR)
433 im = gdImageCreateTrueColor(w, h);
435 im = gdImageCreate(w, h);
438 snprintf(buf,
sizeof(buf),
"GD unable to allocate %d X %d image", w, h);
439 Tcl_SetResult(interp, buf, TCL_VOLATILE);
442 }
else if (
streq(
cmd,
"createTrueColor")) {
443 if (Tcl_GetIntFromObj(interp, objv[2], &w) != TCL_OK)
445 if (Tcl_GetIntFromObj(interp, objv[3], &h) != TCL_OK)
447 im = gdImageCreateTrueColor(w, h);
450 snprintf(buf,
sizeof(buf),
"GD unable to allocate %d X %d image", w, h);
451 Tcl_SetResult(interp, buf, TCL_VOLATILE);
455 char *arg2 = Tcl_GetString(objv[2]);
457 FILE *filePtr =
NULL;
459 ClientData clientdata;
460 if (Tcl_GetOpenFile(interp, arg2, 0, 1, &clientdata) == TCL_OK) {
461 filePtr = (FILE *)clientdata;
464 if (filePtr ==
NULL) {
468 if ((filePtr = fopen(arg2,
"rb")) ==
NULL) {
472 Tcl_ResetResult(interp);
477 im = gdImageCreateFromGd(filePtr);
479 }
else if (
streq(&
cmd[10],
"GD2")) {
480 im = gdImageCreateFromGd2(filePtr);
483 }
else if (
streq(&
cmd[10],
"GIF")) {
484 im = gdImageCreateFromGif(filePtr);
487 }
else if (
streq(&
cmd[10],
"JPEG")) {
488 im = gdImageCreateFromJpeg(filePtr);
491 }
else if (
streq(&
cmd[10],
"PNG")) {
492 im = gdImageCreateFromPng(filePtr);
494 }
else if (
streq(&
cmd[10],
"WBMP")) {
495 im = gdImageCreateFromWBMP(filePtr);
497 }
else if (
streq(&
cmd[10],
"XBM")) {
498 im = gdImageCreateFromXbm(filePtr);
501 Tcl_AppendResult(interp,
cmd + 10,
"unrecognizable format requested",
512 Tcl_AppendResult(interp,
"GD unable to read image file '", arg2,
"` as ",
518 result = Tcl_NewObj();
521 result->bytes =
NULL;
522 Tcl_SetObjResult(interp, result);
527 Tcl_Obj *
const objv[]) {
540static int tclGdWriteCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
546 cmd = Tcl_GetString(objv[1]);
547 if (
cmd[5] ==
'J' ||
cmd[5] ==
'W') {
553 Tcl_SetResult(interp,
"WBMP saving requires the foreground pixel value",
557 }
else if (Tcl_GetIntFromObj(interp, objv[4], &arg4) != TCL_OK)
560 if (
cmd[5] ==
'J' && argc > 4 && (arg4 > 100 || arg4 < 1)) {
561 Tcl_SetObjResult(interp, objv[4]);
562 Tcl_AppendResult(interp,
563 ": JPEG image quality, if specified, must be an integer "
564 "from 1 to 100, or -1 for default",
572 fname = Tcl_GetString(objv[3]);
576 FILE *filePtr =
NULL;
578 ClientData clientdata;
579 if (Tcl_GetOpenFile(interp,
fname, 1, 1, &clientdata) == TCL_OK) {
580 filePtr = (FILE *)clientdata;
583 if (filePtr ==
NULL) {
588 if ((filePtr = fopen(
fname,
"wb")) ==
NULL) {
589 Tcl_AppendResult(interp,
"could not open :",
fname,
590 "': ", strerror(errno),
NULL);
593 Tcl_ResetResult(interp);
606 gdImageGd(im, filePtr);
609#define GD2_CHUNKSIZE 128
610#define GD2_COMPRESSED 2
611 gdImageGd2(im, filePtr, GD2_CHUNKSIZE, GD2_COMPRESSED);
615 gdImageGif(im, filePtr);
618 }
else if (
streq(&
cmd[5],
"JPEG")) {
619#define JPEG_QUALITY -1
620 gdImageJpeg(im, filePtr, JPEG_QUALITY);
624 gdImagePng(im, filePtr);
626 }
else if (
streq(&
cmd[5],
"WBMP")) {
629 int foreground = gdImageColorClosest(im, 0, 0, 0);
630 gdImageWBMP(im, foreground, filePtr);
643 Tcl_Obj *
const objv[]) {
652 if (Tcl_GetBooleanFromObj(interp, objv[3], &on_off) != TCL_OK)
656 gdImageInterlace(im, on_off);
659 on_off = gdImageGetInterlaced(im);
661 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(on_off));
665static int tclGdColorCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
667 int subi, nsub, i, args[3];
672 for (subi = 0; subi < nsub; subi++) {
687 for (i = 0; i < argc - 4; i++) {
688 if (Tcl_GetIntFromObj(interp, objv[i + 4], &args[i]) != TCL_OK) {
691 if (args[i] < -255 || args[i] > 255) {
692 Tcl_SetResult(interp,
"argument out of range 0-255", TCL_STATIC);
706 Tcl_AppendResult(interp,
"bad option \"", Tcl_GetString(objv[2]),
709 Tcl_AppendResult(interp,
"wrong # args: ", 0);
711 Tcl_AppendResult(interp,
"should be ", 0);
712 for (subi = 0; subi < nsub; subi++)
713 Tcl_AppendResult(interp, subi > 0 ?
", " :
"",
colorCmdVec[subi].
cmd, 0);
724 color = gdImageColorAllocate(im, args[0], args[1], args[2]);
725 Tcl_SetObjResult(interp, Tcl_NewIntObj(
color));
735 color = gdImageColorExact(im, args[0], args[1], args[2]);
736 Tcl_SetObjResult(interp, Tcl_NewIntObj(
color));
746 color = gdImageColorClosest(im, args[0], args[1], args[2]);
747 Tcl_SetObjResult(interp, Tcl_NewIntObj(
color));
757 color = gdImageColorResolve(im, args[0], args[1], args[2]);
758 Tcl_SetObjResult(interp, Tcl_NewIntObj(
color));
767 gdImageColorDeallocate(im, args[0]);
777 gdImageColorTransparent(im,
color);
779 color = gdImageGetTransparent(im);
781 Tcl_SetObjResult(interp, Tcl_NewIntObj(
color));
788 Tcl_Obj *tuple[4], *result;
790 ncolors = gdImageColorsTotal(im);
794 if (i >= ncolors || im->open[i]) {
795 Tcl_SetResult(interp,
"No such color", TCL_STATIC);
798 tuple[0] = Tcl_NewIntObj(i);
799 tuple[1] = Tcl_NewIntObj(gdImageRed(im, i));
800 tuple[2] = Tcl_NewIntObj(gdImageGreen(im, i));
801 tuple[3] = Tcl_NewIntObj(gdImageBlue(im, i));
802 Tcl_SetObjResult(interp, Tcl_NewListObj(4, tuple));
804 result = Tcl_NewListObj(0,
NULL);
805 for (i = 0; i < ncolors; i++) {
808 tuple[0] = Tcl_NewIntObj(i);
809 tuple[1] = Tcl_NewIntObj(gdImageRed(im, i));
810 tuple[2] = Tcl_NewIntObj(gdImageGreen(im, i));
811 tuple[3] = Tcl_NewIntObj(gdImageBlue(im, i));
812 Tcl_ListObjAppendElement(
NULL, result, Tcl_NewListObj(4, tuple));
814 Tcl_SetObjResult(interp, result);
820static int tclGdBrushCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
824 gdImagePtr im, imbrush;
828 imbrush =
IMGPTR(objv[3]);
831 gdImageSetBrush(im, imbrush);
836static int tclGdTileCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
847 gdImageSetTile(im, tile);
852static int tclGdStyleCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
854 int ncolor, *colors =
NULL, i;
855 Tcl_Obj **colorObjv =
856 (Tcl_Obj **)(&objv[3]);
866 if (Tcl_ListObjGetElements(interp, objv[3], &ncolor, &colorObjv) != TCL_OK)
869 colors = (
int *)Tcl_Alloc(ncolor *
sizeof(
int));
871 for (i = 0; i < ncolor; i++)
872 if (Tcl_GetIntFromObj(interp, colorObjv[i], &colors[i]) != TCL_OK) {
878 if (retval == TCL_OK)
879 gdImageSetStyle(im, colors, ncolor);
883 Tcl_Free((
char *)colors);
888static int tclGdSetCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
900 if (Tcl_GetIntFromObj(interp, objv[4], &x) != TCL_OK)
902 if (Tcl_GetIntFromObj(interp, objv[5], &y) != TCL_OK)
906 gdImageSetPixel(im, x, y,
color);
911static int tclGdLineCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
915 int color, x1, y1, x2, y2;
923 if (Tcl_GetIntFromObj(interp, objv[4], &x1) != TCL_OK)
925 if (Tcl_GetIntFromObj(interp, objv[5], &y1) != TCL_OK)
927 if (Tcl_GetIntFromObj(interp, objv[6], &x2) != TCL_OK)
929 if (Tcl_GetIntFromObj(interp, objv[7], &y2) != TCL_OK)
933 gdImageLine(im, x1, y1, x2, y2,
color);
938static int tclGdRectCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
942 int color, x1, y1, x2, y2;
951 if (Tcl_GetIntFromObj(interp, objv[4], &x1) != TCL_OK)
953 if (Tcl_GetIntFromObj(interp, objv[5], &y1) != TCL_OK)
955 if (Tcl_GetIntFromObj(interp, objv[6], &x2) != TCL_OK)
957 if (Tcl_GetIntFromObj(interp, objv[7], &y2) != TCL_OK)
961 cmd = Tcl_GetString(objv[1]);
963 gdImageRectangle(im, x1, y1, x2, y2,
color);
965 gdImageFilledRectangle(im, x1, y1, x2, y2,
color);
970static int tclGdArcCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
974 int color, cx, cy, width, height, start, end;
983 if (Tcl_GetIntFromObj(interp, objv[4], &cx) != TCL_OK)
985 if (Tcl_GetIntFromObj(interp, objv[5], &cy) != TCL_OK)
987 if (Tcl_GetIntFromObj(interp, objv[6], &width) != TCL_OK)
989 if (Tcl_GetIntFromObj(interp, objv[7], &height) != TCL_OK)
991 if (Tcl_GetIntFromObj(interp, objv[8], &start) != TCL_OK)
993 if (Tcl_GetIntFromObj(interp, objv[9], &end) != TCL_OK)
997 cmd = Tcl_GetString(objv[1]);
999 gdImageArc(im, cx, cy, width, height, start, end,
color);
1002 else if (
cmd[0] ==
'f' &&
cmd[4] ==
'a')
1003 gdImageFilledArc(im, cx, cy, width, height, start, end,
color, gdArc);
1005 else if (
cmd[0] ==
'o' &&
cmd[4] ==
'a') {
1006 gdImageArc(im, cx, cy, width, height, start, end,
color);
1007 gdImageFilledArc(im, cx, cy, width, height, start, end,
color,
1008 gdChord | gdNoFill);
1009 }
else if (
cmd[0] ==
'c')
1010 gdImageFilledArc(im, cx, cy, width, height, start, end,
color,
1011 gdChord | gdNoFill);
1012 else if (
cmd[0] ==
'f' &&
cmd[4] ==
'c')
1013 gdImageFilledArc(im, cx, cy, width, height, start, end,
color, gdChord);
1014 else if (
cmd[0] ==
'o' &&
cmd[4] ==
'c')
1015 gdImageFilledArc(im, cx, cy, width, height, start, end,
color,
1016 gdChord | gdEdged | gdNoFill);
1017 else if (
cmd[0] ==
'p' ||
1018 (
cmd[0] ==
'f' &&
cmd[4] ==
'p'))
1019 gdImageFilledArc(im, cx, cy, width, height, start, end,
color, gdPie);
1020 else if (
cmd[0] ==
'o' &&
cmd[4] ==
'p')
1021 gdImageFilledArc(im, cx, cy, width, height, start, end,
color,
1022 gdPie | gdEdged | gdNoFill);
1028 Tcl_Obj *
const objv[]) {
1030 int color, npoints, i;
1031 Tcl_Obj **pointObjv = (Tcl_Obj **)(&objv[4]);
1033 int retval = TCL_OK;
1047 if (Tcl_ListObjGetElements(interp, objv[4], &npoints, &pointObjv) != TCL_OK)
1051 if (npoints % 2 != 0) {
1052 Tcl_SetResult(interp,
"Number of coordinates must be even", TCL_STATIC);
1060 Tcl_SetResult(interp,
"Must specify at least 3 points.", TCL_STATIC);
1065 points = (gdPointPtr)Tcl_Alloc(npoints *
sizeof(gdPoint));
1068 for (i = 0; i < npoints; i++)
1069 if (Tcl_GetIntFromObj(interp, pointObjv[i * 2], &
points[i].x) != TCL_OK ||
1070 Tcl_GetIntFromObj(interp, pointObjv[i * 2 + 1], &
points[i].y) !=
1077 cmd = Tcl_GetString(objv[1]);
1086 Tcl_Free((
char *)
points);
1092static int tclGdFillCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
1094 int color, x, y, border;
1102 if (Tcl_GetIntFromObj(interp, objv[4], &x) != TCL_OK)
1104 if (Tcl_GetIntFromObj(interp, objv[5], &y) != TCL_OK)
1108 if (argc - 2 == 5) {
1109 if (Tcl_GetIntFromObj(interp, objv[6], &border) != TCL_OK)
1111 gdImageFillToBorder(im, x, y, border,
color);
1113 gdImageFill(im, x, y,
color);
1119static int tclGdCopyCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
1120 gdImagePtr imdest, imsrc;
1121 int destx, desty, srcx, srcy, destw, desth, srcw, srch;
1124 imdest =
IMGPTR(objv[2]);
1128 if (Tcl_GetIntFromObj(interp, objv[4], &destx) != TCL_OK)
1130 if (Tcl_GetIntFromObj(interp, objv[5], &desty) != TCL_OK)
1132 if (Tcl_GetIntFromObj(interp, objv[6], &srcx) != TCL_OK)
1134 if (Tcl_GetIntFromObj(interp, objv[7], &srcy) != TCL_OK)
1136 if (Tcl_GetIntFromObj(interp, objv[8], &destw) != TCL_OK)
1138 if (Tcl_GetIntFromObj(interp, objv[9], &desth) != TCL_OK)
1142 if (argc - 2 == 10) {
1143 if (Tcl_GetIntFromObj(interp, objv[10], &srcw) != TCL_OK)
1145 if (Tcl_GetIntFromObj(interp, objv[11], &srch) != TCL_OK)
1148 gdImageCopyResized(imdest, imsrc, destx, desty, srcx, srcy, destw, desth,
1151 gdImageCopy(imdest, imsrc, destx, desty, srcx, srcy, destw, desth);
1156static int tclGdGetCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
1166 if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK)
1168 if (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)
1172 color = gdImageGetPixel(im, x, y);
1173 Tcl_SetObjResult(interp, Tcl_NewIntObj(
color));
1177static int tclGdSizeCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
1181 Tcl_Obj *answers[2];
1186 answers[0] = Tcl_NewIntObj(gdImageSX(im));
1187 answers[1] = Tcl_NewIntObj(gdImageSY(im));
1188 Tcl_SetObjResult(interp, Tcl_NewListObj(2, answers));
1192static int tclGdTextCmd(Tcl_Interp *interp,
int argc, Tcl_Obj *
const objv[]) {
1196 double ptsize, angle;
1197 char *
error, *fontname;
1198 int i, brect[8],
len;
1204 if (argc == 2 || (objv[2]->typePtr != &
GdPtrType &&
1217 if (Tcl_GetDoubleFromObj(interp, objv[5], &ptsize) != TCL_OK) {
1222 if (Tcl_GetDoubleFromObj(interp, objv[6], &angle) != TCL_OK) {
1227 if (Tcl_GetIntFromObj(interp, objv[7], &x) != TCL_OK) {
1230 if (Tcl_GetIntFromObj(interp, objv[8], &y) != TCL_OK) {
1234 str = Tcl_GetStringFromObj(objv[9], &
len);
1235 fontname = Tcl_GetString(objv[4]);
1237 gdFTUseFontConfig(1);
1238 error = gdImageStringFT(im, brect,
color, fontname, ptsize, angle, x, y,
str);
1241 Tcl_SetResult(interp,
error, TCL_VOLATILE);
1244 for (i = 0; i < 8; i++) {
1245 orect[i] = Tcl_NewIntObj(brect[i]);
1247 Tcl_SetObjResult(interp, Tcl_NewListObj(8, orect));
1256 if (Tcl_InitStubs(interp, TCL_VERSION, 0) ==
NULL) {
1260 if (Tcl_PkgRequire(interp,
"Tcl", TCL_VERSION, 0) ==
NULL) {
1266 char adjusted_version[
sizeof(PACKAGE_VERSION)] = PACKAGE_VERSION;
1267 char *tilde_dev = strstr(adjusted_version,
"~dev.");
1268 if (tilde_dev !=
NULL) {
1270 memmove(tilde_dev + 1, tilde_dev + strlen(
"~dev."),
1271 strlen(tilde_dev + strlen(
"~dev.")) + 1);
1273 if (Tcl_PkgProvide(interp,
"Gdtclft", adjusted_version) != TCL_OK) {
1276 Tcl_CreateObjCommand(interp,
"gd",
gdCmd,
NULL, (Tcl_CmdDeleteProc *)
NULL);
1283 Tcl_GetCommandInfo(interp,
"gd", &
info) != 1)
1285 info.objClientData = (
char *)
info.objClientData + 1;
1286 if (Tcl_SetCommandInfo(interp,
"gd", &
info) != 1)
1317BOOL APIENTRY DllEntryPoint(HINSTANCE hInst, DWORD reason, LPVOID reserved);
1318BOOL APIENTRY DllEntryPoint(HINSTANCE hInst, DWORD reason, LPVOID reserved) {
1325static int BufferSinkFunc(
void *context,
const char *buffer,
int len) {
1334 Tcl_Obj *
const objv[]) {
1338 gdSink buffsink = {.sink = BufferSinkFunc, .context = &buffer};
1340 gdImagePtr im =
IMGPTR(objv[2]);
1342 gdImagePngToSink(im, &buffsink);
1344 const size_t buffer_length =
agxblen(&buffer);
1345 void *
const result =
agxbuse(&buffer);
1347 assert(buffer_length <= INT_MAX);
1348 Tcl_Obj *output = Tcl_NewByteArrayObj(result, (
int)buffer_length);
1353 Tcl_IncrRefCount(output);
1355 if (Tcl_ObjSetVar2(interp, objv[3],
NULL, output, 0) ==
NULL)
1362 size_t len = strlen(
GdPtrType.name) + (
sizeof(
void *) + 1) * 2 + 1;
1363 O->bytes = Tcl_Alloc(
len);
1368 if (
O->bytes ==
NULL ||
O->bytes[0] ==
'\0' ||
1372 Tcl_AppendResult(
I,
O->bytes,
" is not a ",
GdPtrType.name,
"-handle",
static void out(agerrlevel_t level, const char *fmt, va_list args)
Report messages using a user-supplied or default write function.
static void agxbfree(agxbuf *xb)
free any malloced resources
static size_t agxbput_n(agxbuf *xb, const char *s, size_t ssz)
append string s of length ssz into xb
static WUR char * agxbuse(agxbuf *xb)
static size_t agxblen(const agxbuf *xb)
return number of characters currently stored
static GdDataFunction tclGdCopyCmd
static Tcl_ObjType GdPtrType
static GdImgFunction tclGdColorGetCmd
static GdDataFunction tclGdInterlaceCmd
static cmdDataOptions subcmdVec[]
static GdImgFunction tclGdColorTranspCmd
static GdDataFunction tclGdSetCmd
Tcl_AppInitProc Gdtclft_SafeInit
static GdDataFunction tclGdRectCmd
static GdDataFunction tclGdLineCmd
static Tcl_UpdateStringProc GdPtrTypeUpdate
static GdDataFunction tclGdStyleCmd
static GdDataFunction tclGdBrushCmd
static GdImgFunction tclGdColorResolveCmd
static GdImgFunction tclGdColorNewCmd
static GdDataFunction tclGdCreateCmd
static GdImgFunction tclGdColorFreeCmd
static GdImgFunction tclGdColorExactCmd
static GdDataFunction tclGdDestroyCmd
int() GdImgFunction(Tcl_Interp *interp, gdImagePtr gdImg, int argc, const int args[])
static GdDataFunction tclGdArcCmd
static int gdCmd(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const objv[])
static GdDataFunction tclGdPolygonCmd
static GdDataFunction tclGdSizeCmd
static GdDataFunction tclGdWriteBufCmd
Tcl_AppInitProc Gdtclft_Init
static GdDataFunction tclGdWriteCmd
static GdDataFunction tclGdGetCmd
static GdDataFunction tclGdTextCmd
static int tclGd_GetColor(Tcl_Interp *interp, Tcl_Obj *obj, int *color)
static GdImgFunction tclGdColorClosestCmd
static GdDataFunction tclGdTileCmd
static cmdImgOptions colorCmdVec[]
static Tcl_SetFromAnyProc GdPtrTypeSet
static GdDataFunction tclGdFillCmd
int() GdDataFunction(Tcl_Interp *interp, int argc, Tcl_Obj *const objv[])
static GdDataFunction tclGdColorCmd
static double len(glCompPoint p)
static void color(Agraph_t *g)
static const char * usage
textitem scanner parser str
static bool startswith(const char *s, const char *prefix)
does the string s begin with the string prefix?
static bool streq(const char *a, const char *b)
are a and b equal?