diff WebApplication/viewer.js @ 126:f99adade8b77

Fixed rendering of 16bpp images if values are < 0 or >= 32768
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Mar 2016 11:55:35 +0100
parents 3809121c3290
children 5dc54316d68b
line wrap: on
line diff
--- 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];