Skip to content

hBitmap To Image Widget #385

Answered by jamiepiccolo
AppetiteTeam asked this question in Q&A
Discussion options

You must be logged in to vote

I used the original screenshot example and replaced the section where it saves to a file with the below.

var b = BytesBuilder();
b.add(Pointer<Uint8>.fromAddress(bitmapFileHeader.address)
    .asTypedList(sizeOf<BITMAPFILEHEADER>()));
b.add(Pointer<Uint8>.fromAddress(bitmapInfoHeader.address)
    .asTypedList(sizeOf<BITMAPINFOHEADER>()));
b.add(lpBitmap.asTypedList(dwBmpSize));
return b.toBytes();

This gives you a bitmap as an array of bytes, which you can use with Image.memory(bytes) in flutter.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by timsneath
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #381 on March 25, 2022 21:58.