Fix QR-code/symbol not rendering on top of QR-code correctly

This commit is contained in:
Kristian Vos
2024-07-10 13:45:59 +02:00
parent 1a27c4b15b
commit 8b525210bc
3 changed files with 45 additions and 12 deletions

View File

@@ -77,6 +77,19 @@ is_3d_code(zbar_symbol_type_t type)
}
}
/*
* This function gets given the x/y coordinates of the corners of a QR-code/symbol,
* but zbar is given an image buffer that may be rotated/mirrored.
* So here we adjust the coordinates based on that, so it can be used in src/main.c
* to display the symbol on top of the correctly rotated/mirrored camera preview.
*
* Rotation 0 is the phone in landscape mode (counter-clockwise)
* Rotation 90 is the phone in portrait mode upside down
* Rotation 180 is the phone in landscape mode (clockwise)
* Rotation 270 is the phone in portrait mode
*
* Mirrored is mainly/only(?) used for front cameras
*/
static inline void
map_coords(int *x, int *y, int width, int height, int rotation, bool mirrored)
{
@@ -109,6 +122,7 @@ process_symbol(const MPZBarImage *image,
int height,
const zbar_symbol_t *symbol)
{
// When device is in portrait mode, swap width/height
if (image->rotation == 90 || image->rotation == 270) {
int tmp = width;
width = height;