Mercurial > hg > digilib-old
changeset 777:34bba748004d jquery
minor precisations
author | hertzhaft |
---|---|
date | Fri, 11 Feb 2011 23:19:39 +0100 |
parents | e49beded69d7 (current diff) 19754e80cc9f (diff) |
children | f8235c42f4a0 |
files | client/digitallibrary/jquery/jquery.digilib.js |
diffstat | 2 files changed, 36 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery.digilib.js Fri Feb 11 23:19:14 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.js Fri Feb 11 23:19:39 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' : '', @@ -600,8 +600,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 @@ -1168,9 +1175,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) { @@ -1180,6 +1188,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 @@ -1218,7 +1236,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); } }; @@ -1279,7 +1297,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 Fri Feb 11 23:19:14 2011 +0100 +++ b/servlet/src/digilib/image/ImageJobDescription.java Fri Feb 11 23:19:39 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 {