Mercurial > hg > digilib-old
changeset 773:19754e80cc9f jquery
merge
with 33b5477f8d84cc3e76f0d3dee73e8d26f4dd06dd
author | robcast |
---|---|
date | Thu, 10 Feb 2011 23:41:01 +0100 |
parents | 6d7c51e4724b (current diff) 33b5477f8d84 (diff) |
children | 4568e539abd2 34bba748004d |
files | |
diffstat | 2 files changed, 36 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery.digilib.js Thu Feb 10 22:46:17 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.js Thu Feb 10 23:41:01 2011 +0100 @@ -208,7 +208,7 @@ 'ddpix' : null, 'ddpiy' : null, // list of digilib parameters - 'digilibParamNames' : ['fn','pn','ww','wh','wx','wy','ws','mo','rot','cont','brgt','rgbm','rgba','mk','clop'], + 'digilibParamNames' : ['fn','pn','ww','wh','wx','wy','ws','mo','rot','cont','brgt','rgbm','rgba','ddpi','mk','clop'], // digilib parameter defaults 'mk' : '', 'clop' : '', @@ -604,8 +604,15 @@ }, // calibrate (only faking) - calibrate : function (data) { - loadImageInfo(data); + calibrate : function (data, res) { + var oldRes = data.settings.ddpi; + if (res == null) { + res = window.prompt("Display resolution (dpi)", oldRes); + } + if (res != null) { + data.settings.ddpi = res; + redisplay(data); + } }, // set image scale mode @@ -1173,9 +1180,10 @@ }; // create Transform from area and $img - var getImgTrafo = function ($img, area, rot, hmir, vmir, mode, imgInfo) { + var getImgTrafo = function ($img, area, rot, hmir, vmir, mode, data) { var picrect = geom.rectangle($img); if (mode != null) { + var imgInfo = data.imgInfo; if (mode === 'pixel') { // scaler mo=clip - image area size does not come from ww, wh if (imgInfo != null) { @@ -1185,6 +1193,16 @@ console.error("No image info for pixel mode!"); } } + if (mode === 'size') { + // scaler mo=osize - image area size does not come from ww, wh + if (imgInfo != null) { + var ddpi = parseFloat(data.settings.ddpi); + area.width = (picrect.width / ddpi) / (imgInfo.width / imgInfo.dpi_x); + area.height = (picrect.height / ddpi) / (imgInfo.height / imgInfo.dpi_y); + } else { + console.error("No image info for original size mode!"); + } + } } var trafo = geom.transform(); // move zoom area offset to center @@ -1223,7 +1241,7 @@ // create Transform from current zoomArea and image size data.imgTrafo = getImgTrafo($img, data.zoomArea, data.settings.rot, data.scalerFlags.hmir, data.scalerFlags.vmir, - data.scaleMode, data.imgInfo); + data.scaleMode, data); // console.debug("imgTrafo=", data.imgTrafo); } }; @@ -1284,7 +1302,7 @@ // show zoom area indicator on bird's eye view var renderBirdArea = function (data) { - if (data.$birdImg == null) return; + if (data.$birdImg == null || ! data.$birdImg.get(0).complete) return; var $birdZoom = data.$birdZoom; var zoomArea = data.zoomArea; var normalSize = isFullArea(zoomArea);
--- a/servlet/src/digilib/image/ImageJobDescription.java Thu Feb 10 22:46:17 2011 +0100 +++ b/servlet/src/digilib/image/ImageJobDescription.java Thu Feb 10 23:41:01 2011 +0100 @@ -298,12 +298,20 @@ if ((origResX == 0) || (origResY == 0)) { throw new ImageOpException("Missing image DPI information!"); } - if ((getAsFloat("ddpix") == 0) || (getAsFloat("ddpiy") == 0)) { - throw new ImageOpException("Missing display DPI information!"); + float ddpix = getAsFloat("ddpix"); + float ddpiy = getAsFloat("ddpiy"); + if (ddpix == 0 || ddpiy == 0) { + float ddpi = getAsFloat("ddpi"); + if (ddpi == 0) { + throw new ImageOpException("Missing display DPI information!"); + } else { + ddpix = ddpi; + ddpiy = ddpi; + } } // calculate absolute scale factor - float sx = getAsFloat("ddpix") / origResX; - float sy = getAsFloat("ddpiy") / origResY; + float sx = ddpix / origResX; + float sy = ddpiy / origResY; // currently only same scale -- mean value scaleXY = (sx + sy) / 2f; } else {