dart: converting a bitmap image to png, Image.fromBytes complains about missing data

36 views Asked by At

i am trying to convert an obscure bitmap image format to png, the images are stored as hexadecimal grids of greyshades,

i created a Uint8List out of that data (and i checked values range from 0 - 255) that matches the desired size:

Uint8List uintList = Uint8List.fromList(expandedBits);
      print("prior to fromBytes  ${width}, ${height}= ${width*height} vs ${uintList.length} vs ${uintList.lengthInBytes}");
      // Create an Image from the bitmap data array
      Image image = Image.fromBytes(width: width, height: height, bytes: Uint8List.fromList(expandedBits).buffer);
      

but somehow this fails with a cryptic message:

prior to fromBytes  32, 32= 1024 vs 1024 vs 1024
Error reading the input file: RangeError (end): Invalid value: Not in inclusive range 960..1024: 1056

from my understanding i want an image of 32 x 32 pt, and i supply a list of (32 x 32 = 1024) values that represent those greyshades, where does an index of 1056 comes from?

i expected an image i could export to png

0

There are 0 answers