1function ScaleImage(srcwidth, srcheight, targetwidth, targetheight, fLetterBox) { 2 3 var result = { width: 0, height: 0, fScaleToTargetWidth: true }; 4 5 if ((srcwidth <= 0) || (srcheight <= 0) || (targetwidth <= 0) || (targetheight <= 0)) { 6 return result; 7 } 8 9 // scale to the target width 10 var scaleX1 = targetwidth; 11 var scaleY1 = (srcheight * targetwidth) / srcwidth; 12 13 // scale to the target height 14 var scaleX2 = (srcwidth * targetheight) / srcheight; 15 var scaleY2 = targetheight; 16 17 // now figure out which one we should use 18 var fScaleOnWidth = (scaleX2 > targetwidth); 19 if (fScaleOnWidth) { 20 fScaleOnWidth = fLetterBox; 21 } 22 else { 23 fScaleOnWidth = !fLetterBox; 24 } 25 26 if (fScaleOnWidth) { 27 result.width = Math.floor(scaleX1); 28 result.height = Math.floor(scaleY1); 29 result.fScaleToTargetWidth = true; 30 } 31 else { 32 result.width = Math.floor(scaleX2); 33 result.height = Math.floor(scaleY2); 34 result.fScaleToTargetWidth = false; 35 } 36 result.targetleft = Math.floor((targetwidth - result.width) / 2); 37 result.targettop = Math.floor((targetheight - result.height) / 2); 38 39 return result; 40}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.