diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2004-03-26 22:01:26 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2004-03-26 22:01:26 (GMT) |
commit | 17b6a8a3a36a89a06d9efd6a6f261cbde661e95b (patch) | |
tree | da4bac5a2e7517841b69644da9810d2c6eb80eca /generic/tkImgPhoto.c | |
parent | d55ba4f2606219b20e83d36163db991d2345e326 (diff) | |
download | tk-17b6a8a3a36a89a06d9efd6a6f261cbde661e95b.zip tk-17b6a8a3a36a89a06d9efd6a6f261cbde661e95b.tar.gz tk-17b6a8a3a36a89a06d9efd6a6f261cbde661e95b.tar.bz2 |
Backport of 923555 fixes
Diffstat (limited to 'generic/tkImgPhoto.c')
-rw-r--r-- | generic/tkImgPhoto.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index edff9cf..a969082 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -17,7 +17,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPhoto.c,v 1.36.2.5 2004/02/23 10:49:30 das Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.36.2.6 2004/03/26 22:01:26 dkf Exp $ */ #include "tkInt.h" @@ -948,9 +948,25 @@ ImgPhotoCmd(clientData, interp, objc, objv) } } if (stringWriteProc == NULL) { + oldformat = 1; + for (imageFormat = tsdPtr->oldFormatList; imageFormat != NULL; + imageFormat = imageFormat->nextPtr) { + if ((strncasecmp(Tcl_GetString(options.format), + imageFormat->name, + strlen(imageFormat->name)) == 0)) { + matched = 1; + if (imageFormat->stringWriteProc != NULL) { + stringWriteProc = imageFormat->stringWriteProc; + break; + } + } + } + } + if (stringWriteProc == NULL) { Tcl_AppendResult(interp, "image string format \"", - Tcl_GetString(options.format), - "\" is not supported", (char *) NULL); + Tcl_GetString(options.format), "\" is ", + (matched ? "not supported" : "unknown"), + (char *) NULL); return TCL_ERROR; } } else { @@ -964,9 +980,25 @@ ImgPhotoCmd(clientData, interp, objc, objv) data = ImgGetPhoto(masterPtr, &block, &options); - result = ((int (*) _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *formatString, - Tk_PhotoImageBlock *blockPtr, VOID *dummy))) stringWriteProc) - (interp, options.format, &block, (VOID *) NULL); + if (oldformat) { + Tcl_DString buffer; + + Tcl_DStringInit(&buffer); + result = ((int (*) _ANSI_ARGS_((Tcl_Interp *interp, + Tcl_DString *buffer, char *formatString, + Tk_PhotoImageBlock *blockPtr))) stringWriteProc) + (interp, &buffer, Tcl_GetString(options.format), &block); + if (result == TCL_OK) { + Tcl_DStringResult(interp, &buffer); + } else { + Tcl_DStringFree(&buffer); + } + } else { + result = ((int (*) _ANSI_ARGS_((Tcl_Interp *interp, + Tcl_Obj *formatString, Tk_PhotoImageBlock *blockPtr, + VOID *dummy))) stringWriteProc) + (interp, options.format, &block, (VOID *) NULL); + } if (options.background) { Tk_FreeColor(options.background); } |