Skip to content

Commit

Permalink
BGRA sorted decoding using AVIF_RGB_FORMAT_BGRA
Browse files Browse the repository at this point in the history
  • Loading branch information
sincos2854 committed Oct 1, 2022
1 parent 8abf57a commit 411e3b1
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions extractor.c
Expand Up @@ -56,6 +56,7 @@ int getBMPFromAVIF(const uint8_t *input_data, size_t file_size,
bit_length = bit_width;
avifRGBImageSetDefaults(&rgb, decoder->image);
rgb.depth = 8;
rgb.format = AVIF_RGB_FORMAT_BGRA;

bitmap_data = (uint8_t *)malloc(sizeof(uint8_t) * bit_length * height);
if (!bitmap_data)
Expand All @@ -69,19 +70,6 @@ int getBMPFromAVIF(const uint8_t *input_data, size_t file_size,
{
goto cleanup;
}
// Convert from RGBA to BGRA
for (int j = 0; j < height; j++)
{
uint8_t *curbit = bitmap_data + (height - (1 + j)) * bit_length;
for (int i = 0; i < width; i++)
{
uint8_t b = curbit[0];
uint8_t r = curbit[2];
curbit[2] = b;
curbit[0] = r;
curbit += 4;
}
}
// Flip along the horizontal axis
for (int j = 0; j < height / 2; j++)
{
Expand Down

0 comments on commit 411e3b1

Please sign in to comment.