Frage

I'm converting images to a MOV file, and had an interesting thing happen to me. I logged my bits per color component, bits per pixel, and bytes per row. Here's my code:

NSLog(@"Image width: %d, Height: %d", CGImageGetWidth(image), CGImageGetHeight(image));
NSLog(@"BPC: %d \ BPP: %d \ ByPR: %d", CGImageGetBitsPerComponent(image), CGImageGetBitsPerPixel(image), CGImageGetBytesPerRow(image));

Here's my output:

Image Width: 300, Height: 300 (everything's as expected) BPC: 8 (8 bits per color...so far so good) BPP: 32 (32 = 4 components ARGB * 8 bits per color...got it) ByPR:1216 (300 px per row * 4 bytes per pixel = 1200 bytes per row)

Why am I logged 1216 bytes per row, and not 1200? By the way, this isn't just a fluke. When I create a video based on those numbers for buffer sizes, it works. When I create it with 1200 bytes per row, I get some messed up aliasing effect.

Thoughts?!

War es hilfreich?

Lösung

The system likes images to be a multiple of 64 bytes per row, presumably for better performance due to cache line alignment. 1200 is not a multiple of 64, but 1216 is.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top