Open LeeCampbell opened 8 years ago
Currently the image scaling alg is broken I think. I believe that it assumes at most one dimension is too large.
This alg seems much more simple. Can we validate with a good set of tests.
function ScaleImage(srcWidth, srcHeight, targetWidth, targetHeight) { var result = { width: 0, height: 0 }; if ((srcWidth <= 0) || (srcHeight <= 0) || (targetWidth <= 0) || (targetHeight <= 0)) { return result; } var xScaling = targetWidth / srcWidth; var yScaling = targetHeight / srcHeight; if (xScaling < yScaling){ return { width: targetWidth, height: srcHeight * xScaling }; } else { return { width: srcWidth * yScaling, height: targetHeight }; } }
Currently the image scaling alg is broken I think. I believe that it assumes at most one dimension is too large.
This alg seems much more simple. Can we validate with a good set of tests.