@@ -706,7 +706,8 @@ ${main}
706706 width = fit ( canvas . clientWidth , canvas . width ) , height = fit ( canvas . clientHeight , canvas . height ) ,
707707 changed = canvas . width !== width || canvas . height !== height ,
708708 changed && ( canvas . width = width , canvas . height = height ) ,
709- { width, height, changed } ) ,
709+ // sz spells the width/height keys once for the whole library — reuse it here too.
710+ { ...sz ( width , height ) , changed } ) ,
710711 } : { } ) ,
711712
712713 ...( F_SHOW ? {
@@ -760,7 +761,10 @@ ${main}
760761 if ( ! / ^ ( r g b a | b g r a ) 8 u n o r m ( - s r g b ) ? $ / . test ( tex . format ) )
761762 err ( 19 , MSG && `save: needs an 8-bit RGBA texture, got '${ tex . format } '. Render it into an rgba8unorm target first.` ) ;
762763 let [ width , height ] = texWH ( tex , opts ) ;
763- let px = await S . readTexture ( tex , { x : opts . x , y : opts . y , width, height, mipLevel : opts . mipLevel , Ctor : U8 } ) ;
764+ // readTexture derives the same x/y/width/height/mipLevel defaults from `opts` itself;
765+ // save's extra keys (type, quality, download) are ignored there, and Ctor spread last
766+ // always wins, so the pixels come back as bytes whatever the caller passed.
767+ let px = await S . readTexture ( tex , { ...opts , Ctor : U8 } ) ;
764768 // ImageData is RGBA; the canvas format is BGRA on most platforms, so swap the ends.
765769 if ( tex . format . startsWith ( 'bgra' ) )
766770 for ( let i = 0 ; i < px . length ; i += 4 ) { let b = px [ i ] ; px [ i ] = px [ i + 2 ] ; px [ i + 2 ] = b ; }
0 commit comments