Inserting pixels

Hello!

What is a “fast” way of inserting a bunch of pixels at any position of an ofPixels?
read “insert” as in verctor so that pixels in front of insertion are pushed forward.

Obviously the amount of inserted pixels is the same i will loose at the end of the image.
but that is ok.
I know i could copy pixels one by one but is there anything faster?

ofPixels as well as std vector is always contiguous memory so inserting something in the middle always implies copying the source into the destination and copying the destination to the “right”. if the area in memory is not big enough it might even need a full copy of al the destination onto a new area. So anyway copying the pixels one by one or better using memcpy or memove is the fastest you can get

1 Like

Thank you Arturo!

I will try memcpy then!