render-cg: update to bopti formats for Azur

This commit is contained in:
Lephe 2021-09-28 09:55:26 +02:00
parent 73446aae61
commit 1384c54b5f
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
2 changed files with 18 additions and 7 deletions

View file

@ -69,18 +69,29 @@ typedef struct
later on */
uint16_t profile;
/* Color code assigned to transparent pixels (unused in 16-bit) */
/* Color code assigned to transparent pixels (unused in 16-bit). In
P8_RGB565A, the value assigned to alpha is always 0. */
uint16_t alpha;
/* Full width and height, in pixels */
uint16_t width;
uint16_t height;
/* Color palette:
* 16-bit and 16-bit alpha: none
* 8-bit: 256 colors (total 512 bytes)
* 4-bit: 16 colors (total 32 bytes)
Then raw pixel data in row-major order. */
/* Here we lose structure because of the flexible array.
RGB565, RGB565A:
* Pixels in row-major order, 16 bits per pixel
P8:
* Palette with 256 entries (512 bytes total)
* Pixels in row-major order, 8 bits per pixel
P8_RGB565A, P8_RGB565:
* Number of entries in palette, N (2 bytes)
* Palette with N entries (2N bytes)
* Pixels in row-major order, 8 bits per pixel (signed indices in an
uint16_t array starting at <palette>+<256 bytes>)
P4/P4_RGB565A, P4_RGB565:
* Palette with 16 entries (32 bytes total)
* Pixels in row-major order, 4 bits per pixel, each row byte-padded */
uint16_t data[];
} GPACKED(4) bopti_image_t;

View file

@ -61,7 +61,7 @@ void bopti_render(bopti_image_t const *img, struct box *box)
/* Due to nibble alignment being a hassle, in this function the
input stride is expressed in pixels. */
int in = img->width - w;
int in = img->width - w + (img->width & 1);
/* Also we don't move pointers, we just use pixel offsets. */
int offset = img->width * box->top + box->left;