Mercurial > hg > digilib-old
changeset 772:33b5477f8d84 jquery
original size mode works with zoom area now. needs error handling.
author | robcast |
---|---|
date | Thu, 10 Feb 2011 23:38:03 +0100 |
parents | 4b686a0d44f7 |
children | 19754e80cc9f |
files | client/digitallibrary/jquery/jquery.digilib.js |
diffstat | 1 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery.digilib.js Thu Feb 10 23:36:29 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.js Thu Feb 10 23:38:03 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);