From: ellson <devnull@localhost>
Date: Mon, 29 Jun 2009 12:51:41 +0000 (+0000)
Subject: add support for TrueColor to gdtclft (gd commands, used by webdot)
X-Git-Tag: LAST_LIBGRAPH~32^2~1863
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c36976597eeda1df61e80f8b6246a5197da22e8;p=graphviz

add support for TrueColor to gdtclft (gd commands, used by webdot)
---

diff --git a/tclpkg/gdtclft/gdtclft.3tcl b/tclpkg/gdtclft/gdtclft.3tcl
index abd7b6557..d7c879a2e 100644
--- a/tclpkg/gdtclft/gdtclft.3tcl
+++ b/tclpkg/gdtclft/gdtclft.3tcl
@@ -69,6 +69,9 @@ Reference
    gd create <width> <height>
           Return a handle to a new gdImage that is width X height.
           
+   gd createTrueColor <width> <height>
+          Return a handle to a new trueColor gdImage that is width X height.
+          
    gd createFromGD <filehandle>
    gd createFromGD2 <filehandle>
    gd createFromGIF <filehandle>
diff --git a/tclpkg/gdtclft/gdtclft.c b/tclpkg/gdtclft/gdtclft.c
index bae525666..456d129b0 100644
--- a/tclpkg/gdtclft/gdtclft.c
+++ b/tclpkg/gdtclft/gdtclft.c
@@ -98,6 +98,8 @@ typedef struct {
 static cmdOptions subcmdVec[] = {
     {"create", tclGdCreateCmd, 2, 2, 0, 0,
      "width height"},
+    {"createTrueColor", tclGdCreateCmd, 2, 2, 0, 0,
+     "width height"},
     {"createFromGD", tclGdCreateCmd, 1, 1, 0, 0,
      "filehandle"},
 #ifdef HAVE_LIBZ
@@ -299,6 +301,8 @@ static int tclGd_GetColor(Tcl_Interp * interp, Tcl_Obj * obj, int *color)
  *
  * gd create <width> <height>
  * 		Return a handle to a new gdImage that is width X height.
+ * gd createTrueColor <width> <height>
+ * 		Return a handle to a new trueColor gdImage that is width X height.
  * gd createFromGD <filehandle>
  * gd createFromGD2 <filehandle>
  * gd createFromGIF <filehandle>
@@ -517,6 +521,17 @@ tclGdCreateCmd(Tcl_Interp * interp, GdData * gdData,
 	    Tcl_SetResult(interp, buf, TCL_VOLATILE);
 	    return TCL_ERROR;
 	}
+    } else if (strcmp(cmd, "createTrueColor") == 0) {
+	if (Tcl_GetIntFromObj(interp, objv[2], &w) != TCL_OK)
+	    return TCL_ERROR;
+	if (Tcl_GetIntFromObj(interp, objv[3], &h) != TCL_OK)
+	    return TCL_ERROR;
+	im = gdImageCreateTrueColor(w, h);
+	if (im == NULL) {
+	    sprintf(buf, "GD unable to allocate %d X %d image", w, h);
+	    Tcl_SetResult(interp, buf, TCL_VOLATILE);
+	    return TCL_ERROR;
+	}
     } else {
 	fileByName = 0;		/* first try to get file from open channel */
 	if (Tcl_GetOpenFile