diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2011-09-27 10:38:26 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2011-09-27 10:38:26 (GMT) |
commit | 9ac99f6b94c347561106bac624f9076b816b0724 (patch) | |
tree | 51fa23b65a2fc9f8e338bf25d399ef93c3b454c3 /generic/tkImgPNG.c | |
parent | c51c5fd97194eb20d201b0120505ca750a1079bc (diff) | |
download | tk-9ac99f6b94c347561106bac624f9076b816b0724.zip tk-9ac99f6b94c347561106bac624f9076b816b0724.tar.gz tk-9ac99f6b94c347561106bac624f9076b816b0724.tar.bz2 |
* generic/tkImgPNG.c (WriteExtraChunks): [Bug 3405839]: Write the sDAT
chunk with the correct length.
Diffstat (limited to 'generic/tkImgPNG.c')
-rw-r--r-- | generic/tkImgPNG.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index d5a0b98..8d6721e 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -3180,6 +3180,7 @@ WriteExtraChunks( static const unsigned char sBIT_contents[] = { 8, 8, 8, 8 }; + int sBIT_length = 4; Tcl_DString buf; /* @@ -3188,7 +3189,23 @@ WriteExtraChunks( * data model is. */ - if (WriteChunk(interp, pngPtr, CHUNK_sBIT, sBIT_contents, 4) != TCL_OK) { + switch (pngPtr->colorType) { + case PNG_COLOR_GRAY: + sBIT_length = 1; + break; + case PNG_COLOR_GRAYALPHA: + sBIT_length = 2; + break; + case PNG_COLOR_RGB: + case PNG_COLOR_PLTE: + sBIT_length = 3; + break; + case PNG_COLOR_RGBA: + sBIT_length = 4; + break; + } + if (WriteChunk(interp, pngPtr, CHUNK_sBIT, sBIT_contents, sBIT_length) + != TCL_OK) { return TCL_ERROR; } |