@@ -1487,14 +1487,13 @@ impl CanvasRenderingContext2D {
14871487 _ => ColorSpace :: default ( ) ,
14881488 } ;
14891489 let arraybuffer_length = ( width * height * 4 ) as usize ;
1490- let mut data_buffer = vec ! [ 0 ; arraybuffer_length] ;
1491- let data_ptr = data_buffer. as_mut_ptr ( ) ;
1492- let data_object = Uint8ClampedSlice :: from_data ( env, data_buffer) ?;
1490+ let data_buffer = vec ! [ 0 ; arraybuffer_length] ;
1491+ let mut data_object = Uint8ClampedSlice :: from_data ( env, data_buffer) ?;
14931492 let mut instance = ImageData {
14941493 width : width as usize ,
14951494 height : height as usize ,
14961495 color_space,
1497- data : data_ptr ,
1496+ data : data_object . as_mut_ptr ( ) ,
14981497 }
14991498 . into_instance ( env) ?;
15001499 instance. set_named_property ( "data" , data_object) ?;
@@ -2020,7 +2019,7 @@ impl CanvasRenderingContext2D {
20202019 let color_space = color_space
20212020 . and_then ( |cs| cs. parse ( ) . ok ( ) )
20222021 . unwrap_or ( ColorSpace :: Srgb ) ;
2023- let mut image_data = self
2022+ let image_data = self
20242023 . context
20252024 . get_image_data ( x as f32 , y as f32 , width as f32 , height as f32 , color_space)
20262025 . ok_or_else ( || {
@@ -2029,13 +2028,12 @@ impl CanvasRenderingContext2D {
20292028 "Read pixels from canvas failed" . to_string ( ) ,
20302029 )
20312030 } ) ?;
2032- let data = image_data. as_mut_ptr ( ) ;
2033- let data_object = Uint8ClampedSlice :: from_data ( env, image_data) ?;
2031+ let mut data_object = Uint8ClampedSlice :: from_data ( env, image_data) ?;
20342032 let mut instance = ImageData {
20352033 width : width as usize ,
20362034 height : height as usize ,
20372035 color_space,
2038- data,
2036+ data : data_object . as_mut_ptr ( ) ,
20392037 }
20402038 . into_instance ( env) ?;
20412039 instance. set_named_property ( "data" , data_object) ?;
0 commit comments