Convert from Spread<RGBA> to Spread<Bytes>?

need to convert some pixels from a texture to a spread of bytes (or a string) to be able to send them to the SerialPort, how can i do that??

Hey,

Could you show us what you’ve tried already, where you’re stuck, some documentation about the thing you wanna send bytes to, etc?

Kinda hard to give an answer to such a broad question.

Thanks!

ReadbackTexture is generic, if you type it to MutableArray<Byte> you get all pixels as a byte blob.

I can’t specify the whole thing because it’s not part of the question.
I am taking a TEXTURE video and using PIPET (to sample the video) take out an array that i want to send byte by byte to a microcontroller through the serial port.
The question is simple: i now have a Spread (that comes out of the PIPET) and need a Spread (that is the input of the SerialPort node), how can I do that?
the flow is like that:
Spread —> RGBA array to BYTES array —> SerialPort (with Spread as input).
The rgb values (100,200,100),(0,0,200)… should be converted as some bytes to send to the serial port like this: “100 200 100 0 0 200…”
if it was plain programming it would be easy, an array is an array… but seems like vvvv is not.

Like this?

1 Like

Here are 4 options, including the optimal one that shuffles the pixels first on the GPU, and then downloads the final bytes.


TexturePixelsToBytes.vl (33.8 KB)

vvvv is plain programming. there is no difference in types from C# to vvvv. In C# there are the new memory and span types that solve these kinds of conversions in a type-safe manner. See:

3 Likes