How does one use Image.create_from_data(...) with the data being a float array?

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

link to the function in question

The function only accepts a PoolByteArray for data and I’m don’t see an easy way to convert from a float array/ PoolRealArray to PoolByteArray… I’m using RGBAF as the format parameter.

Sidenote:
I’ll probably use StreamPeer like this if there isn’t a better alternative for the conversion:

var stream = StreamPeerBuffer.new()
var data_in_bytes = PoolByteArray([])
for i in data_in_floats:
    stream.clear()
    stream.put_float(i)
    stream.seek(0)
    for j in range(4):
        data_in_bytes.append(stream.get_8())

(Then I’d use create_from_data() with data_in_bytes)
That feels kind of hackish though, especially since the documentation for the RGBAF format seems to imply float would be the preferred type for its data (at least in OpenGL).