findDecoderForNamedImage function
Return the Decoder that can decode image with the given name
,
by looking at the file extension.
Implementation
Decoder? findDecoderForNamedImage(String name) {
final n = name.toLowerCase();
if (n.endsWith('.jpg') || n.endsWith('.jpeg')) {
return JpegDecoder();
}
if (n.endsWith('.png')) {
return PngDecoder();
}
if (n.endsWith('.tga')) {
return TgaDecoder();
}
if (n.endsWith('.webp')) {
return WebPDecoder();
}
if (n.endsWith('.gif')) {
return GifDecoder();
}
if (n.endsWith('.tif') || n.endsWith('.tiff')) {
return TiffDecoder();
}
if (n.endsWith('.psd')) {
return PsdDecoder();
}
if (n.endsWith('.exr')) {
return ExrDecoder();
}
if (n.endsWith('.bmp')) {
return BmpDecoder();
}
if (n.endsWith('.ico')) {
return IcoDecoder();
}
if (n.endsWith('.pvr')) {
return PvrDecoder();
}
return null;
}