How should the Uint8List for `Bitmap.fromHeadless` look
CaptainDario opened this issue · 2 comments
First of all thank you for this package.
However I am stuck while trying to convert an Uint8List to a bitmap.
What I am trying is:
final bitmap = Bitmap.fromHeadless(
this.width,
this.height,
layer
);
final headed = bitmap.buildHeaded();
final imgMem = Image.memory(headed);
return imgMem;
However the code always crashes at the buildHeaded()
.
Now I am wondering what the problem is and how the uint8list should be build.
Is it supposed to encode RGBA in separate ints like:
[255, 0, 0, 255]
for a completely red pixel?
Yes, the standard for the content is RGBA32. Is the Width/Height correct for that image?
Sorry, than this is my fault. From
This is useful when you are dealing with the
Uint8List
thatByteData
generates.
I thought I can just pass the constructor the result of Picture.toByteData().asUint8List()
.
But now setting 4 elements for R, G, B and A does work.
Edit: Turns out that this also work with Picture.toByteData(format: ImageByteFormat.rawRgba).asUint8List()