File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -111,16 +111,13 @@ function dbgEnergySum(energySum: Uint32Array) {
111111}
112112
113113// remove seams in remove from data, returning a new array.
114- // TODO mutate data instead of allocating a new array
115114function removeSeam (
116115 data : Uint8ClampedArray ,
117116 width : number ,
118117 height : number ,
119118 remove : Uint32Array ,
120119) : Uint8ClampedArray {
121120 const data32 = new Uint32Array ( data . buffer ) ;
122- const newData = new Uint8ClampedArray ( ( width - 1 ) * height * 4 ) ;
123- const buf32 = new Uint32Array ( newData . buffer ) ;
124121
125122 let offset = 0 ;
126123 for ( let y = 0 ; y < height ; y ++ ) {
@@ -130,13 +127,13 @@ function removeSeam(
130127 // pixels been removed, skip over it
131128 offset ++ ;
132129 }
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 ] ;
135132 }
136133 }
137134 }
138135
139- return newData ;
136+ return data ;
140137}
141138
142139function diff ( pixel1 : number , pixel2 : number ) : number {
You can’t perform that action at this time.
0 commit comments