BinomialLLC / basis_universal

Basis Universal GPU Texture Codec
Apache License 2.0
2.7k stars 263 forks source link

Support load jpg in basis encoder #352

Closed gz65555 closed 9 months ago

gz65555 commented 1 year ago

Fix #351

This pull request adds support for loading JPEG images in the WebAssembly version of the basis_universal library. Previously, only PNG images were supported in the wasm version.

To use the new feature, users can specify the type of source image by passing a number to the basis_universal library, where 1 represents a PNG image and 2 represents a JPEG image.

Here's an example code snippet that shows how to use the new setSliceSourceImage function with a JPEG image:

// 1 represent png file, 2 for jpg, 0 for raw image data
var type = 1; 
basisEncoder.setSliceSourceImage(0, new Uint8Array(data), 0, 0, type);
gz65555 commented 9 months ago

Use createImageBitmap to create ImageSource, no need to support jpg.