#11771 closed defect (duplicate)
dojox.image.Lightbox::_scaleToFit() work wrong causing invalid image resizing
Reported by: | Aleksey Rechinskiy | Owned by: | anonymous |
---|---|---|---|
Priority: | high | Milestone: | 1.5.1 |
Component: | General | Version: | 1.5 |
Keywords: | dojox.image.Lightbox | Cc: | |
Blocked By: | Blocking: |
Description
Hi All!
I had a problem displaying large panoramic images (with image.width > viewport.width ) and found a bug in a widget's rescale function ( _scaleToFit() ).
If you take a look into _scaleToFit() source code you'll see near the top of the function scaling algorithm:
// one of the dimensions is too big, go with the smaller viewport edge: if(this._vp.h > this._vp.w){ // don't actually touch the edges: ns.w = this._vp.w - 80; ns.h = ns.w * (size.h / size.w); }else{ // give a little room for the titlenode, too: ns.h = this._vp.h - 60 - this._lastTitleSize.h; ns.w = ns.h * (size.w / size.h); }
Algorithm decides how to rescale image by examining the vieport's size and, obviously, it is bad idea in case of wide panoramic image. Looks like it should do it by examining the image's size, something like this:
var w=size.w, h=size.h; if(w+100 > this._vp.w){ // don't actually touch the edges: ns.w = this._vp.w - 100; ns.h = ns.w * (h / w); h=ns.h; w=ns.w; } //its better to check [new] height here because we don't know if it fits into viewport if (h + 60 + this._lastTitleSize.h > this._vp.h ){ // give a little room for the titlenode, too: ns.h = this._vp.h - 60 - this._lastTitleSize.h; ns.w = ns.h * (w / h); }
This code works better and rescales images properly. Thanks)
Change History (2)
comment:1 Changed 10 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 Changed 10 years ago by
Oops.. Sorry, I tried to use a search to ensure I wont make a duplicate, but it didn't work. I'll try corrected version from trunk...
duplicate of #11207 which is fixed in 1.6
please reopen if the current scaleToFit in trunk displays your issue, preferably with a testcase.