saveFrame to byte array

Hi,

I’m making an HTTP server using processing. This server will host an HTML file and an image. The HTML file will tell the clients browser to request and display the image periodically. The image is the last frame drew on the processing canvas. Basically I’m streaming my canvas. I’m not sure how to store this last frame into a byte array (directly to the RAM) formatted in TIFF, TARGA, JPEG or PNG. I could just use saveFrame to save the frame to the disk and loadBytes to load it from the disk to the RAM but this require unnecessary disk usage thus adding overhead. There is a function called get and one called loadPixels which can save a frame directly to the RAM without using the disk but the resulting frame is formatted as an ARGB array. Is there a way to format this ARGB array to a TIFF, TARGA, JPEG or PNG bytes array? Or is there any other way to do what I just described?

Thanks!

Maybe the saveImageIO() definition could be useful in your use case from the Processing’s source code here. This will convert it to a byte array.

Previous posts:

Kf

Thank you for your help! I took a quick look at saveImageIO() and it looked promising. I’ll keep you updated once I have time to look at it in details.