Drawing pixel data from an external (non-JUCE) source?


As in the title, is there any efficient way to do that with JUCE? (Basically I would have a pointer to the pixel data and width/height.)


If you don’t mind copying the data, it’s easy to create a SoftwareImageType and copy into its buffer. If you’re trying to avoid the extra copy then you’d probably need to create your own ImageType subclass that encapsulates the pointer, but then you need to worry about byte-ordering of colour data across different platforms.


Obviously the point would be to avoid copying data. :wink: OK, thanks for the info, I’ll see if I bother doing the ImageType subclass thing…


The thing is that to draw it might involve a copy anyway.

Really depends whether you’re going to use the image more than once… If so, I’d suggest creating a native image and copying your data into it, then re-using it. If you’re just repeatedly blasting new data to the screen then a new image format type might work better


Out of curiosity, what is the source of the pixel data? In many cases you would have to convert the format anyway, which means copying the data.

I use ffmpeg here, and it can convert directly into the juce image, if that is of interest: