diff --git a/include/cammy/photo.h b/include/cammy/photo.h index 22a7263..fcbaac2 100644 --- a/include/cammy/photo.h +++ b/include/cammy/photo.h @@ -34,8 +34,8 @@ typedef struct _cammy_photo { #pragma pack(pop) -void cammy_photo_export(cammy_photo *src, uint8_t *dest); +void cammy_photo_export(cammy_photo *src, uint8_t *dest, int stride); -void cammy_photo_import(cammy_photo *dest, uint8_t *src); +void cammy_photo_import(cammy_photo *dest, uint8_t *src, int stride); #endif /* _CAMMY_PHOTO_H */ diff --git a/src/photo.c b/src/photo.c index 40c6457..5eeee50 100644 --- a/src/photo.c +++ b/src/photo.c @@ -70,6 +70,8 @@ static uint32_t bayer_matrix[256] = { }; void cammy_photo_import(cammy_photo *dest, uint8_t *src) { + +void cammy_photo_import(cammy_photo *dest, uint8_t *src, int stride) { size_t x, y; memset(&dest->tiles, '\x00', sizeof(dest->tiles)); @@ -82,9 +84,9 @@ void cammy_photo_import(cammy_photo *dest, uint8_t *src) { int tile_x = x & 7, tile_y = y & 7; - uint8_t r = src[4*CAMMY_PHOTO_WIDTH*y+4*x], - g = src[4*CAMMY_PHOTO_WIDTH*y+4*x+1], - b = src[4*CAMMY_PHOTO_WIDTH*y+4*x+2]; + uint8_t r = src[stride*CAMMY_PHOTO_WIDTH*y+stride*x], + g = src[stride*CAMMY_PHOTO_WIDTH*y+stride*x+1], + b = src[stride*CAMMY_PHOTO_WIDTH*y+stride*x+2]; uint8_t gray = (uint8_t) ((0.2126 * (float)r) diff --git a/src/test.c b/src/test.c index b729b6f..6b2d419 100644 --- a/src/test.c +++ b/src/test.c @@ -91,7 +91,7 @@ int main(int argc, char **argv) { goto error_png_get_data; } - cammy_photo_import(&sram->data->photos[photo-1], buf); + cammy_photo_import(&sram->data->photos[photo-1], buf, (int)png->bpp); free(buf);