electron_sys/class/
native_image.rs1use crate::interface::{
2 AddRepresentationOptions,
3 Rectangle,
4 ResizeOptions,
5 Size,
6 ToBitmapOptions,
7 ToDataUrlOptions,
8 ToPngOptions,
9};
10use js_sys::{JsString, Object};
11use node_sys::Buffer;
12use wasm_bindgen::prelude::*;
13
14#[wasm_bindgen(module = "electron")]
15extern {
16 #[wasm_bindgen(extends = Object)]
17 #[derive(Clone, Debug, Eq, PartialEq)]
18 pub type NativeImage;
19
20 #[wasm_bindgen(method, js_name = "addRepresentation")]
25 pub fn add_representation(this: &NativeImage, options: AddRepresentationOptions);
26
27 #[wasm_bindgen(method)]
28 pub fn crop(this: &NativeImage, rectangle: Rectangle) -> NativeImage;
29
30 #[wasm_bindgen(method, js_name = "getAspectRatio")]
31 pub fn get_aspect_ratio(this: &NativeImage, rectangle: Rectangle) -> f32;
32
33 #[wasm_bindgen(method, js_name = "getBitmap")]
34 pub fn get_bitmap(this: &NativeImage, options: Option<ToBitmapOptions>) -> Buffer;
35
36 #[wasm_bindgen(method, js_name = "getNativeHandle")]
37 pub fn get_native_handle(this: &NativeImage) -> Buffer;
38
39 #[wasm_bindgen(method, js_name = "getSize")]
40 pub fn get_size(this: &NativeImage) -> Size;
41
42 #[wasm_bindgen(method, js_name = "isEmpty")]
43 pub fn is_empty(this: &NativeImage) -> bool;
44
45 #[wasm_bindgen(method)]
46 pub fn resize(this: &NativeImage, options: ResizeOptions) -> NativeImage;
47
48 #[wasm_bindgen(method, js_name = "toBitmap")]
49 pub fn to_bitmap(this: &NativeImage, options: Option<ToBitmapOptions>) -> Buffer;
50
51 #[wasm_bindgen(method, js_name = "toDataURL")]
52 pub fn to_data_url(this: &NativeImage, options: Option<ToDataUrlOptions>) -> JsString;
53
54 #[wasm_bindgen(method, js_name = "toJPEG")]
55 pub fn to_jpeg(this: &NativeImage, quality: f32) -> Buffer;
56
57 #[wasm_bindgen(method, js_name = "toPNG")]
58 pub fn to_png(this: &NativeImage, options: Option<ToPngOptions>) -> Buffer;
59
60 #[wasm_bindgen(method, getter, js_name = "isMacTemplateImage")]
65 pub fn is_mac_template_image(this: &NativeImage) -> bool;
66
67 #[wasm_bindgen(method, setter, js_name = "isMacTemplateImage")]
68 pub fn set_is_mac_template_image(this: &NativeImage, value: bool);
69}