fschutt / printpdf

A fully-featured PDF library for Rust, WASM-ready
https://fschutt.github.io/printpdf/
MIT License
829 stars 98 forks source link

I am trying to insert an image into the background, but I encountered the following problem. #194

Closed EZ-Super closed 1 week ago

EZ-Super commented 1 week ago

code

use ::image::codecs::bmp::BmpDecoder;
let PngData = include_bytes!("background.png");
let mut cursor = Cursor::new(PngData);
let decoder = BmpDecoder::new(&mut cursor).unwrap();
let backend = Image::try_from(decoder).unwrap();

Cargo.toml

[dependencies]
printpdf = { version = "0.7.0", features = [ "embedded_images" ] }
image = { version = "0.25", features = ["bmp"] } 

error

   --> src/main.rs:22:35
    |
22  |     let backend = Image::try_from(decoder).unwrap();
    |                   --------------- ^^^^^^^ the trait `printpdf::image::ImageDecoder<'_>` is not implemented for `image::codecs::bmp::BmpDecoder<&mut std::io::Cursor<&[u8; 13660]>>`
    |                   |
    |                   required by a bound introduced by this call
hahazexia commented 1 week ago

yeah, i have the same problem

fschutt commented 1 week ago

Use image = 0.24 instead of 0.25.