ajrcarey/pdfium-render

DynamicImage::Bgra8 removed from upstream image crate in 0.24.x

ajrcarey opened this issue · 3 comments

The upstream image crate removed enum variants relating to BGR8 from the DynamicImage enum. Upstream issue:

image-rs/image#1671

It might be possible to tell Pdfium to render using a different pixel format, or just perform some conversion ourselves. In the meantime, locked image version to ^0.23 in Cargo.toml.

Pushed version lock as part of 0.5.3 release.

Updated Cargo.toml to use image 0.24. Changed default setting of PdfBitmapConfig::set_reverse_byte_order() from false to true to have Pdfium render bitmaps using RGBA8 rather than the default BGRA8. Switched from using DynamicImage::Bgra8() to DynamicImage::Rgba8() in all internal code and in examples. Pushed version 0.5.4 to crates.io.

Reversing the byte order conveniently fixes the problem of colors being reversed in WASM compared to native, which required two separate implementations of PdfColor::color(). This is now no longer necessary. Removed redundant implementation as part of release 0.5.5.