Commit f58d6d6
committed
Fixed image resize algorithm bug
This patch fixes a bug in the resize algorithm that "eats" some lines, both horizontal and vertical. To see the actual bug just try to resize to 800x600 this 4000x3000 test pattern image https://docs.google.com/file/d/0B9gDTEhcnnOVMzhpZDZrMWQtZDg/edit?usp=sharing
You should find the artefacts I've highlighted in testpattern_highlight.jpg
Just to know, the bug was born because the renderImageToCanvas method renders a large HTML5 canvas picture splitting it in 1Mpixels blocks, but the junction between one block and another was made in each cycle with "ceil" & "floor" functions, that introduce a non-linear behaviour in resize algorithm which sometimes would result in skipped pixel lines inside the final image.
The patch I've written tries to calculate the best scaling factor before entering the main 'while' cycle of a single 'tile' and then it uses it as an unique scaling factor for all image blocks.
This should result in perfect junctions between all blocks inside the image with just (in worst cases) a tiny part of the original image cut off from the right and lower borders.1 parent a8a96e4 commit f58d6d6
1 file changed
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
| 92 | + | |
90 | 93 | | |
91 | | - | |
92 | 94 | | |
| 95 | + | |
93 | 96 | | |
94 | | - | |
95 | 97 | | |
96 | 98 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 99 | + | |
102 | 100 | | |
| 101 | + | |
103 | 102 | | |
104 | 103 | | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
0 commit comments