File tree 1 file changed +3
-6
lines changed
1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -111,16 +111,13 @@ function dbgEnergySum(energySum: Uint32Array) {
111
111
}
112
112
113
113
// remove seams in remove from data, returning a new array.
114
- // TODO mutate data instead of allocating a new array
115
114
function removeSeam (
116
115
data : Uint8ClampedArray ,
117
116
width : number ,
118
117
height : number ,
119
118
remove : Uint32Array ,
120
119
) : Uint8ClampedArray {
121
120
const data32 = new Uint32Array ( data . buffer ) ;
122
- const newData = new Uint8ClampedArray ( ( width - 1 ) * height * 4 ) ;
123
- const buf32 = new Uint32Array ( newData . buffer ) ;
124
121
125
122
let offset = 0 ;
126
123
for ( let y = 0 ; y < height ; y ++ ) {
@@ -130,13 +127,13 @@ function removeSeam(
130
127
// pixels been removed, skip over it
131
128
offset ++ ;
132
129
}
133
- if ( x < width ) {
134
- buf32 [ y * ( width - 1 ) + x ] = data32 [ y * ( width - 1 ) + x + offset ] ;
130
+ if ( x < width && offset > 0 ) {
131
+ data32 [ y * ( width - 1 ) + x ] = data32 [ y * ( width - 1 ) + x + offset ] ;
135
132
}
136
133
}
137
134
}
138
135
139
- return newData ;
136
+ return data ;
140
137
}
141
138
142
139
function diff ( pixel1 : number , pixel2 : number ) : number {
You can’t perform that action at this time.
0 commit comments