Skip to content

Commit 6cc084b

Browse files
committed
Prevent premultiplication on image import
1 parent afa3282 commit 6cc084b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

wgpu/tests/external_texture.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,24 @@ async fn image_bitmap_import() {
1818
let blob = web_sys::Blob::new_with_u8_array_sequence(&array).unwrap();
1919

2020
// Parse the image from the blob
21-
let image_bitmap_promise = web_sys::window()
21+
let image_bitmap_function: js_sys::Function = web_sys::window()
2222
.unwrap()
23-
.create_image_bitmap_with_blob(&blob)
23+
.get("createImageBitmap")
24+
.unwrap()
25+
.dyn_into()
26+
.unwrap();
27+
28+
let options_arg = js_sys::Object::new();
29+
js_sys::Reflect::set(
30+
&options_arg,
31+
&wasm_bindgen::JsValue::from_str("premultipliedAlpha"),
32+
&wasm_bindgen::JsValue::from_str("none"),
33+
)
34+
.unwrap();
35+
let image_bitmap_promise: js_sys::Promise = image_bitmap_function
36+
.call2(&wasm_bindgen::JsValue::UNDEFINED, &blob, &options_arg)
37+
.unwrap()
38+
.dyn_into()
2439
.unwrap();
2540

2641
// Wait for the parsing to be done

0 commit comments

Comments
 (0)