Mercurial > hg > orthanc-webviewer
comparison 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 |
comparison
equal
deleted
inserted
replaced
125:145e654112d6 | 126:f99adade8b77 |
---|---|
16 * You should have received a copy of the GNU Affero General Public License | 16 * You should have received a copy of the GNU Affero General Public License |
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 **/ | 18 **/ |
19 | 19 |
20 | 20 |
21 // Set the default compression | |
21 var compression = 'jpeg95'; | 22 var compression = 'jpeg95'; |
23 //var compression = 'deflate'; | |
22 | 24 |
23 | 25 |
24 // Prevent the access to IE | 26 // Prevent the access to IE |
25 if(navigator.appVersion.indexOf("MSIE ") != -1) | 27 if(navigator.appVersion.indexOf("MSIE ") != -1) |
26 { | 28 { |
231 pixels[index++] = s[i]; | 233 pixels[index++] = s[i]; |
232 pixels[index++] = s[i + 1]; | 234 pixels[index++] = s[i + 1]; |
233 pixels[index++] = s[i + 2]; | 235 pixels[index++] = s[i + 2]; |
234 pixels[index++] = 255; // Alpha channel | 236 pixels[index++] = 255; // Alpha channel |
235 } | 237 } |
236 } else { | 238 } else{ |
237 var buf = new ArrayBuffer(s.length * 2); // int16_t | 239 var buf = new ArrayBuffer(s.length * 2); // uint16_t or int16_t |
238 pixels = new Int16Array(buf); | 240 |
241 if (image.Orthanc.IsSigned) { | |
242 pixels = new Int16Array(buf); | |
243 } else { | |
244 pixels = new Uint16Array(buf); | |
245 } | |
246 | |
239 var index = 0; | 247 var index = 0; |
240 for (var i = 0, length = s.length; i < length; i += 2) { | 248 for (var i = 0, length = s.length; i < length; i += 2) { |
241 var lower = s[i]; | 249 var lower = s[i]; |
242 var upper = s[i + 1]; | 250 var upper = s[i + 1]; |
243 pixels[index] = lower + upper * 256; | 251 pixels[index] = lower + upper * 256; |
275 pixels[index++] = s[i + 1]; | 283 pixels[index++] = s[i + 1]; |
276 pixels[index++] = s[i + 2]; | 284 pixels[index++] = s[i + 2]; |
277 pixels[index++] = 255; // Alpha channel | 285 pixels[index++] = 255; // Alpha channel |
278 } | 286 } |
279 } else { | 287 } else { |
280 var buf = new ArrayBuffer(s.length * 2); // uint8_t | 288 var buf = new ArrayBuffer(s.length * 2); // uint16_t or int16_t |
281 pixels = new Int16Array(buf); | 289 |
290 if (image.Orthanc.IsSigned) { | |
291 pixels = new Int16Array(buf); | |
292 } else { | |
293 pixels = new Uint16Array(buf); | |
294 } | |
295 | |
282 var index = 0; | 296 var index = 0; |
283 for (var i = 0, length = s.length; i < length; i++) { | 297 for (var i = 0, length = s.length; i < length; i++) { |
284 pixels[index] = s[i]; | 298 pixels[index] = s[i]; |
285 index++; | 299 index++; |
286 } | 300 } |