This commit is contained in:
Ross
2021-11-11 22:37:32 +00:00
parent 9451aedbc9
commit 588741ba24
2 changed files with 30 additions and 31 deletions
+3 -3
View File
@@ -479,14 +479,14 @@
if (el.files[0].type.startsWith("image")) {
base = await blobToBase64(el.files[0]);
imageId = "base64://" + base.split(",")[1];
imageId2 = base;
//imageId2 = base;
} else {
let url = URL.createObjectURL(el.files[0])
imageId = `wadouri:${url}`;
imageId2 = url
//imageId2 = url
}
console.log(imageId)
const element = $(`<div class='temp-thumb' src=${imageId2}></div>`).get(0)
const element = $(`<div class='temp-thumb' src=${imageId}></div>`).get(0)
$(el).parent().parent().prepend(element);
cornerstone.enable(element);
cornerstone.loadAndCacheImage(imageId).then(function (image) {
+27 -28
View File
@@ -541,6 +541,10 @@ export function loadCornerstone(main_element, db, images, annotations_to_load, l
loadAnnotation(imageId, annotation);
imageIds.push(imageId);
} else if (data_url.startsWith("base64://") || data_url.startsWith("wadouri:")) {
loadAnnotation(data_url, annotation);
imageIds.push(data_url);
// Treat application/octet-stream as if they are dicoms
} else if (data_url.startsWith("data:application/dicom") || data_url.startsWith("data:application/octet-stream")) {
@@ -602,6 +606,22 @@ export function loadCornerstone(main_element, db, images, annotations_to_load, l
});
}
function loadCornerstoneThumb(image) {
img = $("<div></div>").get(0);
img.id = "thumb-image-" + id;
img.class = "thumbnail";
img.title =
"Click on the thumbnail to view and manipulate the image.";
img.draggable = "false";
img.style = "height: 100px; width: 100px";
$("#thumb-" + id).append(img);
const element = document.getElementById("thumb-image-" + id);
cornerstone.enable(element);
cornerstone.displayImage(element, image);
cornerstone.resize(element);
}
if (images.length > 1 && load_as_stack == false) {
$(".canvas-panel").append("<div id='image-thumbs'></div>");
for (let id = 0; id < images.length; id++) {
@@ -647,24 +667,12 @@ export function loadCornerstone(main_element, db, images, annotations_to_load, l
dfile
);
cornerstone.loadAndCacheImage(imageId).then(function (image) {
img = $("<div></div>").get(0);
img.id = "thumb-image-" + id;
img.class = "thumbnail";
img.title =
"Click on the thumbnail to view and manipulate the image.";
img.draggable = "false";
img.style = "height: 100px; width: 100px";
$("#thumb-" + id).append(img);
const element = document.getElementById("thumb-image-" + id);
cornerstone.enable(element);
cornerstone.displayImage(element, image);
cornerstone.resize(element);
loadCornerstoneThumb();
}); //.catch( function(error) {
});
}
} else {
if (!image_url.endsWith("dicom") && !image_url.endsWith("dcm")) {
if ((!image_url.endsWith("dicom") && !image_url.endsWith("dcm")) || image_url.startsWith("base64")) {
img = $("<img />", {
src: image_url,
id: "thumb-image-" + id,
@@ -677,24 +685,15 @@ export function loadCornerstone(main_element, db, images, annotations_to_load, l
$("#thumb-" + id).append(img);
// otherwise try to load it as a dicom
} else if (!image_url.startsWith("wadouri")) {
cornerstone.loadAndCacheImage(url).then(function (image) {
loadCornerstoneThumb();
});
} else {
let url = "wadouri:" + image_url;
console.log(url)
cornerstone.loadAndCacheImage(url).then(function (image) {
img = $("<div></div>").get(0);
img.id = "thumb-image-" + id;
img.class = "thumbnail";
img.title =
"Click on the thumbnail to view and manipulate the image.";
img.draggable = "false";
img.style = "height: 100px; width: 100px";
$("#thumb-" + id).append(img);
const element = document.getElementById("thumb-image-" + id);
cornerstone.enable(element);
cornerstone.displayImage(element, image);
cornerstone.resize(element);
loadCornerstoneThumb();
});
}
}