# HG changeset patch # User robcast # Date 1297338679 -3600 # Node ID 31664707999e6f7a1e9c7129958b13376c7429e8 # Parent 16778bd2de7cd04390ad7b8f5b828ce42320bbd7 pixel-by-pixel scale mode works with zoom area. (not in all cases) we do not wait for server data. diff -r 16778bd2de7c -r 31664707999e client/digitallibrary/jquery/jquery.digilib.js --- a/client/digitallibrary/jquery/jquery.digilib.js Wed Feb 09 10:22:29 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.js Thu Feb 10 12:51:19 2011 +0100 @@ -342,6 +342,10 @@ } } } + // get image info from server if needed + if (data.scaleMode === 'pixel' || data.scaleMode === 'size') { + getImageInfo(data); // TODO: onload callback + } // create HTML structure for scaler setupScalerDiv(data); // add buttons @@ -385,7 +389,6 @@ settings.isBirdDivVisible = showDiv(settings.isBirdDivVisible, data.$birdDiv, show); updateBirdDiv(data); storeOptions(data); - // data.$birdImg.triggerHandler('load'); // TODO: we shouldn't do that }, // goto given page nr (+/-: relative) @@ -599,10 +602,12 @@ } if (mode != null) { setScaleMode(data, mode); + data.scaleMode = mode; redisplay(data); } } - + + // end of actions }; // returns parameters from page url @@ -745,6 +750,7 @@ } } data.scalerFlags = flags; + data.scaleMode = getScaleMode(data); retrieveOptions(data); }; @@ -1097,8 +1103,19 @@ }; // create Transform from area and $img - var getImgTrafo = function ($img, area, rot, hmir, vmir) { + var getImgTrafo = function ($img, area, rot, hmir, vmir, mode, imgInfo) { var picrect = geom.rectangle($img); + if (mode != null) { + if (mode === 'pixel') { + // scaler mo=clip - image area size does not come from ww, wh + if (imgInfo != null) { + area.width = picrect.width / imgInfo.width; + area.height = picrect.height / imgInfo.height; + } else { + console.error("No image info for pixel mode!"); + } + } + } var trafo = geom.transform(); // move zoom area offset to center trafo.concat(trafo.getTranslation(geom.position(-area.x, -area.y))); @@ -1136,7 +1153,8 @@ var $scaler = data.$scaler; // create Transform from current zoomArea and image size data.imgTrafo = getImgTrafo($img, data.zoomArea, - data.settings.rot, data.scalerFlags.hmir, data.scalerFlags.vmir); + data.settings.rot, data.scalerFlags.hmir, data.scalerFlags.vmir, + data.scaleMode, data.imgInfo); // console.debug("imgTrafo=", data.imgTrafo); var imgRect = geom.rectangle($img); // console.debug("imgrect=", imgRect);