zbar_pipeline: Skip padding bytes when creating grayscale image (MR 13)

This commit is contained in:
Yassine Oudjana
2022-02-24 16:41:00 +04:00
committed by Martijn Braam
parent cf0f02228a
commit eb05dc56b4

View File

@@ -188,7 +188,9 @@ process_image(MPPipeline *pipeline, MPZBarImage **_image)
uint8_t *data = malloc(width * height * sizeof(uint8_t)); uint8_t *data = malloc(width * height * sizeof(uint8_t));
size_t row_length = size_t row_length =
mp_pixel_format_width_to_bytes(image->pixel_format, image->width); mp_pixel_format_width_to_bytes(image->pixel_format, image->width);
size_t i = 0; int padding_bytes =
mp_pixel_format_width_to_padding(image->pixel_format, image->width);
size_t i = 0, padding_offset = 0;
size_t offset; size_t offset;
switch (image->pixel_format) { switch (image->pixel_format) {
case MP_PIXEL_FMT_BGGR8: case MP_PIXEL_FMT_BGGR8:
@@ -220,8 +222,12 @@ process_image(MPPipeline *pipeline, MPZBarImage **_image)
if (x % 4 == 0) if (x % 4 == 0)
offset += 1; offset += 1;
data[i++] = image->data[x + offset + row_length * y]; data[i++] = image->data[x + offset + padding_offset +
row_length * y];
} }
// Skip padding
padding_offset += padding_bytes * 2;
} }
break; break;
default: default: