I have the raw pixel data (Uint8List) of an image, the image's width and height, and the pixel format (bgra8888). How do I decode them into a JPG format image?
abstract class PdfImage {
/// Number of pixels in horizontal direction.
int get width;
/// Number of pixels in vertical direction.
int get height;
/// Pixel format in either [ui.PixelFormat.rgba8888] or [ui.PixelFormat.bgra8888].
ui.PixelFormat get format;
/// Raw pixel data. The actual format is platform dependent.
Uint8List get pixels;
/// Create [ui.Image] from the rendered image.
/// it worked
Future<ui.Image> createImage() {
final comp = Completer<ui.Image>();
ui.decodeImageFromPixels(
pixels, width, height, format, (image) => comp.complete(image));
return comp.future;
}
}
I have the raw pixel data (Uint8List) of an image, the image's width and height, and the pixel format (bgra8888). How do I decode them into a JPG format image?