Don't hardcode pixel stride
This commit is contained in:
parent
7555135260
commit
4e6cd9d1f9
3 changed files with 8 additions and 6 deletions
|
@ -34,8 +34,8 @@ typedef struct _cammy_photo {
|
||||||
|
|
||||||
#pragma pack(pop)
|
#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 */
|
#endif /* _CAMMY_PHOTO_H */
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
||||||
|
void cammy_photo_import(cammy_photo *dest, uint8_t *src, int stride) {
|
||||||
size_t x, y;
|
size_t x, y;
|
||||||
|
|
||||||
memset(&dest->tiles, '\x00', sizeof(dest->tiles));
|
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,
|
int tile_x = x & 7,
|
||||||
tile_y = y & 7;
|
tile_y = y & 7;
|
||||||
|
|
||||||
uint8_t r = src[4*CAMMY_PHOTO_WIDTH*y+4*x],
|
uint8_t r = src[stride*CAMMY_PHOTO_WIDTH*y+stride*x],
|
||||||
g = src[4*CAMMY_PHOTO_WIDTH*y+4*x+1],
|
g = src[stride*CAMMY_PHOTO_WIDTH*y+stride*x+1],
|
||||||
b = src[4*CAMMY_PHOTO_WIDTH*y+4*x+2];
|
b = src[stride*CAMMY_PHOTO_WIDTH*y+stride*x+2];
|
||||||
|
|
||||||
uint8_t gray = (uint8_t)
|
uint8_t gray = (uint8_t)
|
||||||
((0.2126 * (float)r)
|
((0.2126 * (float)r)
|
||||||
|
|
|
@ -91,7 +91,7 @@ int main(int argc, char **argv) {
|
||||||
goto error_png_get_data;
|
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);
|
free(buf);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue