Git commit 6f5f6ccf12ceabc0c1fc8a780bf9a87b8b344ff5 by Maks Orlovich. Committed on 06/02/2012 at 13:11. Pushed by orlovich into branch 'KDE/4.7'. Fix sign extension causing image scaling to read from wrong locations with very high ratios. M +12 -6 khtml/imload/scaledimageplane.h http://commits.kde.org/kdelibs/6f5f6ccf12ceabc0c1fc8a780bf9a87b8b344ff5 diff --git a/khtml/imload/scaledimageplane.h b/khtml/imload/scaledimageplan= e.h index 953c34c..35fec21 100644 --- a/khtml/imload/scaledimageplane.h +++ b/khtml/imload/scaledimageplane.h @@ -24,6 +24,8 @@ #ifndef SCALED_IMAGE_PLANE_H #define SCALED_IMAGE_PLANE_H = +#include + #include "array2d.h" #include "imageplane.h" #include "rawimageplane.h" @@ -48,21 +50,25 @@ private: = //### I bet this has all sorts of imprecision problems w/high rati= os unsigned int* origin =3D new unsigned int[scaled]; - = + //### FIXME: replace with something that clamps on right edge late= r? double ratio =3D double(orig)/double(scaled); - int intRatio =3D int(ratio*65536.0 + 1); - int pos =3D 0; - = + + // Should be assured by ImageManager::isAcceptableScaleSize + assert(ratio < 65536); + + unsigned intRatio =3D unsigned(ratio*65536.0 + 1); + unsigned pos =3D 0; + for (unsigned int pix =3D 0; pix < scaled; pix++) { origin[pix] =3D pos >> 16; pos +=3D intRatio; } - = + return origin; } - = + unsigned int* xScaleTable; unsigned int* yScaleTable; public: