decodeToTexture static method
Future<Texture>
decodeToTexture(
- Uint8List data, {
- TextureFormat textureFormat = TextureFormat.RGB32F,
- PixelDataFormat pixelDataFormat = PixelDataFormat.RGB,
- PixelDataType pixelDataType = PixelDataType.FLOAT,
- int levels = 1,
- bool requireAlpha = false,
Decodes the image contained in data
and returns a texture of
the corresponding size with the image set as mip-level 0.
Implementation
static Future<Texture> decodeToTexture(Uint8List data,
{TextureFormat textureFormat = TextureFormat.RGB32F,
PixelDataFormat pixelDataFormat = PixelDataFormat.RGB,
PixelDataType pixelDataType = PixelDataType.FLOAT,
int levels = 1,
bool requireAlpha = false}) async {
final decodedImage = await FilamentApp.instance!
.decodeImage(data, requireAlpha: requireAlpha);
final texture = await FilamentApp.instance!.createTexture(
await decodedImage.getWidth(), await decodedImage.getHeight(),
textureFormat: textureFormat, levels: levels);
await texture.setLinearImage(decodedImage, pixelDataFormat, pixelDataType);
return texture;
}