Image.create_from_data error

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By OrlanJRod

I get this error when i use create_from_data

"0:00:00:0816 - Expected data size of 5120 in Image::create()

Type:Error
Description: Expected data size of 5120 in Image::create()
Time: 0:00:00:0816
C Error: Condition ’ p_data.size() != size ’ is true.
C Source: core/image.cpp:1196
C Function: create"

here is the code. I’m using the bytearray i get from the httprequest body.

	var img = Image.new()
img.create_from_data(32,40,false,Image.FORMAT_RGBA8,body)
:bust_in_silhouette: Reply From: supagu

That error seems to indicate that the data you are passing in does not match the size and/or bit depth.

you have 32x40x4=5120 bytes.
Check that body has 5120 bytes of data.