diff options
author | donal.k.fellows@manchester.ac.uk <dkf> | 2011-09-27 10:38:26 (GMT) |
---|---|---|
committer | donal.k.fellows@manchester.ac.uk <dkf> | 2011-09-27 10:38:26 (GMT) |
commit | ce38c982535b4c8a02dde49badd84d5bf9c5fc9b (patch) | |
tree | 51fa23b65a2fc9f8e338bf25d399ef93c3b454c3 /generic/tkImgPNG.c | |
parent | b94a0f2d58e82b8a9df81fae6137e07443be1a06 (diff) | |
download | tk-ce38c982535b4c8a02dde49badd84d5bf9c5fc9b.zip tk-ce38c982535b4c8a02dde49badd84d5bf9c5fc9b.tar.gz tk-ce38c982535b4c8a02dde49badd84d5bf9c5fc9b.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; } |