Creating an image from arrays of floats in C/C++

Hello all,
I’m in the process of creating a little system that runs compute shaders but I need a way to save and load information in the form of images.

I’ve only managed to create flat colour images using BKE_image_add_generated from but would like to create images from float arrays for the rgba channels and read data in that way from existing images.

I’ve had a look at the ImBuf struct but i’m not sure how to get them to take my data.
Thank you!

1 Like

If you have an array of floats that are arranged RGBA you could just do something like:

ImBuf *image = IMB_allocFromBuffer(NULL, myarray, width, height, 4);

Thank you! That’s a good bit simpeler then my approach :smiley:
Case closed.

1 Like