Skip to content

Instantly share code, notes, and snippets.

@expenses
Created April 22, 2022 14:08
Show Gist options
  • Save expenses/867b698d3a702969d47c20c48752c3af to your computer and use it in GitHub Desktop.
Save expenses/867b698d3a702969d47c20c48752c3af to your computer and use it in GitHub Desktop.
use wasm_bindgen::prelude::wasm_bindgen;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_name = initializeBasis, js_namespace = ["window", "basis_transcoder"])]
pub fn initialize_basis();
#[wasm_bindgen(js_namespace = ["window", "basis_transcoder"])]
pub type BasisFile;
#[wasm_bindgen(constructor, js_namespace = ["window", "basis_transcoder"])]
pub fn new(array: &js_sys::Uint8Array) -> BasisFile;
#[wasm_bindgen(js_name = getNumImages, method)]
pub fn get_num_images(this: &BasisFile) -> u32;
#[wasm_bindgen(js_name = getNumLevels, method)]
pub fn get_num_levels(this: &BasisFile, image_index: u32) -> u32;
#[wasm_bindgen(js_name = getHasAlpha, method)]
pub fn get_has_alpha(this: &BasisFile) -> bool;
#[wasm_bindgen(js_name = startTranscoding, method)]
pub fn start_transcoding(this: &BasisFile) -> u32;
#[wasm_bindgen(js_name = getImageWidth, method)]
pub fn get_image_width(this: &BasisFile, image_index: u32, level_index: u32) -> u32;
#[wasm_bindgen(js_name = getImageHeight, method)]
pub fn get_image_height(this: &BasisFile, image_index: u32, level_index: u32) -> u32;
#[wasm_bindgen(js_name = getImageTranscodedSizeInBytes, method)]
pub fn get_image_transcoded_size_in_bytes(this: &BasisFile, image_index: u32, level_index: u32, format: u32) -> u32;
#[wasm_bindgen(js_name = transcodeImage, method)]
pub fn transcode_image(this: &BasisFile, dst: &js_sys::Uint8Array, image_index: u32, level_index: u32, format: u32, unused: u32, get_alpha_for_opaque_formats: u32) -> u32;
#[wasm_bindgen(method)]
pub fn close(this: &BasisFile);
#[wasm_bindgen(method)]
pub fn delete(this: &BasisFile);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment