I´m trying to send a image through tcp to a server, firts getting the buffer from the camera and then converting to grayScale the buffer, finally I send the buffer to the server.
All is working fine, but the problem is that the image that the server receive it is not 100 % okay, it looks like there is some padding that I dind´t use at the conversion, all the images are more or less than the next.
I use the next code to get the image:
VImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
uint8_t * baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer);
the image is here http://s3.subirimagenes.com:81/imagen/previo/thump_6421684image001.png
The only padding you may get is per row of pixels — you should use something like:
Rather than assuming, one way or another, that one scanline ends somewhere in memory and then the next immediately starts.
That said, the top portion of your image is clearly correct and I’ve yet to see an instance where pitch wasn’t equal to width*bytesPerPixel, so it’d be unlikely to be causing your problem in practice even if you haven’t done that correctly.
Inspecting your image, it looks like the broken region contains copies of various fragments of the working region, so I don’t think the problem is padding related — it’s some sort of more obtuse memory management or transmission error. Have you checked that side of things?