summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2020-06-11 14:28:11 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2020-06-11 14:28:11 (GMT)
commit040e90faf796eff48ac41d4b595e12ecf1c9638d (patch)
tree433d1de1d5cacd88c13317cf3051fe4b81cbfbe1 /generic
parent7724cf274e81e8f3edbfe0616616b4d6dd7df01d (diff)
downloadtk-040e90faf796eff48ac41d4b595e12ecf1c9638d.zip
tk-040e90faf796eff48ac41d4b595e12ecf1c9638d.tar.gz
tk-040e90faf796eff48ac41d4b595e12ecf1c9638d.tar.bz2
TIP529 image metadata: implement image write/data with metadata property. GIF comment write correction. GIF file tests
Diffstat (limited to 'generic')
-rw-r--r--generic/tkImgGIF.c2
-rw-r--r--generic/tkImgPhoto.c29
2 files changed, 27 insertions, 4 deletions
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
index 1b9652d..02ff197 100644
--- a/generic/tkImgGIF.c
+++ b/generic/tkImgGIF.c
@@ -2109,7 +2109,7 @@ CommonWriteGIF(
comment = Tcl_GetByteArrayFromObj(itemData, &length);
if (length > 0) {
/* write comment header */
- writeProc(handle, (char *) "\x21\fe", 2);
+ writeProc(handle, (char *) "\x21\xfe", 2);
/* write comment blocks */
for (;length > 0;) {
int blockLength;
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 08a79c4..20cd036 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -756,6 +756,7 @@ ImgPhotoCmd(
case PHOTO_DATA: {
char *data = NULL;
Tcl_Obj *freeObj = NULL;
+ Tcl_Obj *metadataIn;
/*
* photo data command - first parse and check any options given.
@@ -768,6 +769,7 @@ ImgPhotoCmd(
memset(&options, 0, sizeof(options));
options.name = NULL;
options.format = NULL;
+ options.metadata = NULL;
options.fromX = 0;
options.fromY = 0;
if (ParseSubcommandOptions(&options, interp,
@@ -802,6 +804,16 @@ ImgPhotoCmd(
options.format = Tcl_NewStringObj("default", -1);
freeObj = options.format;
}
+
+ /*
+ * Use argument metadata if specified, otherwise the master metadata
+ */
+
+ if (NULL != options.metadata) {
+ metadataIn = options.metadata;
+ } else {
+ metadataIn = masterPtr->metadata;
+ }
/*
* Search for an appropriate image string format handler.
@@ -871,7 +883,7 @@ ImgPhotoCmd(
if (stringWriteProc == NULL) {
result = (stringWriteProcVersion3)(interp,
- options.format, options.metadata, &block);
+ options.format, metadataIn, &block);
} else if (oldformat) {
Tcl_DString buffer;
typedef int (*OldStringWriteProc)(Tcl_Interp *interp,
@@ -1431,7 +1443,7 @@ readCleanup:
case PHOTO_WRITE: {
char *data;
const char *fmtString;
- Tcl_Obj *format;
+ Tcl_Obj *format, *metadataIn;
int usedExt;
/*
@@ -1492,6 +1504,17 @@ readCleanup:
usedExt = 0;
}
+
+ /*
+ * Use argument metadata if specified, otherwise the master metadata
+ */
+
+ if (NULL != options.metadata) {
+ metadataIn = options.metadata;
+ } else {
+ metadataIn = masterPtr->metadata;
+ }
+
/*
* Search for an appropriate image file format handler, and give an
* error if none is found.
@@ -1585,7 +1608,7 @@ readCleanup:
Tcl_GetString(options.name), format, &block);
} else {
result = imageFormatVersion3->fileWriteProc(interp,
- Tcl_GetString(options.name), format, options.metadata,
+ Tcl_GetString(options.name), format, metadataIn,
&block);
}
if (options.background) {