我使用选择插件得到一个矩形:
selection =viewer.selection({
onSelection: function(rect) {
console.log(rect.x);
console.log(rect.y);
console.log(rect.width);
console.log(rect.height);
var elt = document.createElement("div");
elt.id = "runtime-overlay";
elt.className = "highlight";
viewer.addOverlay({
element: elt,
location: viewer.viewport.imageToViewportRectangle(rect)
});
input = "rect_x="+rect.x+"&rect_y="+rect.y+"&rect_w="+rect.width+"&rect_h="+rect.height+"&plink=<?=$plink?>&case_id=<?=$case_id?>&mode=add";
$.ajax({
url : "handlers/H_AnnotationHandler.php",
data : input,
type : "post",
dataType : "json",
success : function(response) {
if (!response.error)
alert("success");
else
alert("failed");
}
});
}
});
我通过 H_AnnotationHandler.php 将矩形存储在 mysql 中。之后,当我尝试像这样使用这些数据时:
$.ajax({
url : "handlers/H_AnnotationHandler.php",
data : "case_id=<?=$case_id?>&plink=<?=$plink?>&mode=get",
type : "post",
dataType : "json",
success : function (response) {
if (!response.error) {
for (var i = 0; i < response.annots.length; i++) {
var elt = document.createElement("div");
elt.id = "runtime-overlay" + i;
elt.className = "highlight";
viewer.addOverlay({
element: elt,
location : viewer.viewport.imageToViewportRectangle(parseInt(response.annots[i].rect_x), parseInt(response.annots[i].rect_y), parseInt(response.annots[i].rect_w), parseInt(response.annots[i].rect_h))
});
}
}
}
});
它创建了一个运行时覆盖划分,但左、上、高和宽似乎非常错误。(27094e+04 等)
注意:我确定,sql 数据是真实的。我在拍之前比较一下。