why it doesn't work? also has black backgroundColor;
final Directory? downloadsDir = await getDownloadsDirectory();
if (downloadsDir == null) {
return;
}
// // files.last.
var targetPath = '${downloadsDir.path}/testconvert.jpg';
var image = await img.decodeImageFile(files.last.path);
if (image != null) {
final p = image.getBytes();
for (var i = 0, len = p.length; i < len; i += 4) {
if (p[i + 3] != 255) {
// If the alpha is transparent
p[i] = 255; // Set the color to white
p[i + 1] = 255;
p[i + 2] = 255;
p[i + 3] = 255;
}
}
img.writeFile(targetPath, img.encodeJpg(image));
}
why it doesn't work? also has black backgroundColor;
this is my image this is the result