# HG changeset patch # User Sebastien Jodogne # Date 1458903335 -3600 # Node ID f99adade8b776bb1d8da8c97d750209da730641d # Parent 145e654112d6fc89fbeafaaf6db72ace764cad13 Fixed rendering of 16bpp images if values are < 0 or >= 32768 diff -r 145e654112d6 -r f99adade8b77 NEWS --- a/NEWS Thu Jan 28 17:08:44 2016 +0100 +++ b/NEWS Fri Mar 25 11:55:35 2016 +0100 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* Fixed rendering of 16bpp images if values are < 0 or >= 32768 + Version 2.0 (2015-12-10) ======================== diff -r 145e654112d6 -r f99adade8b77 Plugin/DecodedImageAdapter.cpp --- a/Plugin/DecodedImageAdapter.cpp Thu Jan 28 17:08:44 2016 +0100 +++ b/Plugin/DecodedImageAdapter.cpp Fri Mar 25 11:55:35 2016 +0100 @@ -297,7 +297,7 @@ case Orthanc::PixelFormat_Grayscale8: case Orthanc::PixelFormat_Grayscale16: - buffer.SetFormat(Orthanc::PixelFormat_SignedGrayscale16); + buffer.SetFormat(Orthanc::PixelFormat_Grayscale16); buffer.SetWidth(accessor.GetWidth()); buffer.SetHeight(accessor.GetHeight()); converted = buffer.GetAccessor(); @@ -313,6 +313,8 @@ return false; } + result["Orthanc"]["IsSigned"] = (accessor.GetFormat() == Orthanc::PixelFormat_SignedGrayscale16); + // Sanity check: The pitch must be minimal assert(converted.GetSize() == converted.GetWidth() * converted.GetHeight() * GetBytesPerPixel(converted.GetFormat())); @@ -423,6 +425,7 @@ return false; } + result["Orthanc"]["IsSigned"] = (accessor.GetFormat() == Orthanc::PixelFormat_SignedGrayscale16); result["Orthanc"]["Compression"] = "Jpeg"; result["sizeInBytes"] = converted.GetSize(); diff -r 145e654112d6 -r f99adade8b77 WebApplication/viewer.js --- a/WebApplication/viewer.js Thu Jan 28 17:08:44 2016 +0100 +++ b/WebApplication/viewer.js Fri Mar 25 11:55:35 2016 +0100 @@ -18,7 +18,9 @@ **/ +// Set the default compression var compression = 'jpeg95'; +//var compression = 'deflate'; // Prevent the access to IE @@ -233,9 +235,15 @@ pixels[index++] = s[i + 2]; pixels[index++] = 255; // Alpha channel } - } else { - var buf = new ArrayBuffer(s.length * 2); // int16_t - pixels = new Int16Array(buf); + } else{ + var buf = new ArrayBuffer(s.length * 2); // uint16_t or int16_t + + if (image.Orthanc.IsSigned) { + pixels = new Int16Array(buf); + } else { + pixels = new Uint16Array(buf); + } + var index = 0; for (var i = 0, length = s.length; i < length; i += 2) { var lower = s[i]; @@ -277,8 +285,14 @@ pixels[index++] = 255; // Alpha channel } } else { - var buf = new ArrayBuffer(s.length * 2); // uint8_t - pixels = new Int16Array(buf); + var buf = new ArrayBuffer(s.length * 2); // uint16_t or int16_t + + if (image.Orthanc.IsSigned) { + pixels = new Int16Array(buf); + } else { + pixels = new Uint16Array(buf); + } + var index = 0; for (var i = 0, length = s.length; i < length; i++) { pixels[index] = s[i];