encodeNamedImage function
Identify the format of the image and encode it with the appropriate Encoder.
Implementation
List<int> encodeNamedImage(Image image, String name) {
var n = name.toLowerCase();
if (n.endsWith('.jpg') || n.endsWith('.jpeg')) {
return encodeJpg(image);
}
if (n.endsWith('.png')) {
return encodePng(image);
}
if (n.endsWith('.tga')) {
return encodeTga(image);
}
if (n.endsWith('.gif')) {
return encodeGif(image);
}
if (n.endsWith('.cur')) {
return encodeCur(image);
}
if (n.endsWith('.ico')) {
return encodeIco(image);
}
return null;
}