Skip to content

Commit d45d00c

Browse files
committed
Update fximg.utils.ts
1 parent a75f549 commit d45d00c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fximg.utils.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,17 @@ namespace helper {
120120
const srcRow = pins.createBuffer(clipHSrc); // buffer ขนาดสูงสุดที่ copy จริง
121121
const dstRow = pins.createBuffer(clipHDst); // buffer เต็ม column ของ dst
122122

123-
let anyChange = false;
123+
let anyChange = false, rowChange = false;
124+
let curSx = -1;
124125

125-
for (let x = 0; x < clipWDst; x++) {
126+
for (let x = 0; x < clipWDst; x++, rowChange = false) {
126127
const sx_f = xSrc + x * scaleX;
127128
const sx = (sx_f + 0.5)|0; // หรือ Math.round() ก็ได้
128129

129130
if (sx < 0) continue;
130131
if (sx >= clipWSrc) break;
131132

132-
fximgGetRows(src, sx, srcRow, clipHSrc);
133+
if (sx !== curSx) fximgGetRows(src, sx, srcRow, clipHSrc), curSx = sx;
133134
fximgGetRows(dst, xDst + x, dstRow, clipHDst);
134135

135136
for (let y = 0; y < clipHDst; y++) {
@@ -147,9 +148,9 @@ namespace helper {
147148
if (old === pixel) continue;
148149

149150
dstRow[yDst] = pixel;
150-
anyChange = true;
151+
anyChange = true, rowChange = true;
151152
}
152-
fximgSetRows(dst, xDst + x, dstRow, clipHDst);
153+
if (rowChange) fximgSetRows(dst, xDst + x, dstRow, clipHDst);
153154
}
154155

155156
return check ? anyChange : true;

0 commit comments

Comments
 (0)