Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

png with transparency/alpha channel wouldn't shown #84

Open
r4mp opened this issue Dec 7, 2020 · 9 comments
Open

png with transparency/alpha channel wouldn't shown #84

r4mp opened this issue Dec 7, 2020 · 9 comments
Milestone

Comments

@r4mp
Copy link

r4mp commented Dec 7, 2020

printpdf version: 0.3.3

If I try to add a png with transparency, the image wouldn't shown. Other png files works fine.

let mut image_file = File::open("test.png").unwrap();
let image = Image::try_from(image::png::PngDecoder::new(&mut image_file).unwrap()).unwrap();
image.add_to_layer(current_layer.clone(), Some(Mm(x)), Some(Mm(y)), None, Some(1.0), Some(1.0), Some(300.0));
@fschutt
Copy link
Owner

fschutt commented Dec 7, 2020

Can you upload the PNG file to GitHub?

As far as I know, images with an alpha channel aren't supported right now because that would require support for "soft masks" in the PDF, which isn't implemented yet.

Also see #61

@r4mp
Copy link
Author

r4mp commented Dec 7, 2020

wouldnt_shown

It really seems to be the problem/reason you described.

@fschutt
Copy link
Owner

fschutt commented Dec 8, 2020

I'm putting soft masks on my todo list, it's not that hard to implement (you need to split out the alpha channel and then reference it as a separate greyscale image). Can't say when I'll get back to working on printpdf though.

@anhtumai
Copy link

anhtumai commented Nov 3, 2022

for newcomer going here, this is the workaround #119 (comment) (work only with Rgba color space)

@BXHlixiaodong
Copy link

Hi, I find SoftMask is ready, but how to use it? it has no constructor function.

@fschutt
Copy link
Owner

fschutt commented Jun 2, 2023

@BXHlixiaodong This is a stub API, it doesn't work yet

@mikeparisstuff
Copy link

@fschutt, I'm also interested in soft mask functionality and would be willing to help out if you'd like. If interested, could you point out some relevant parts of the code where you think it would make sense to plug it in and I'll see if I can help out?

@mikeparisstuff
Copy link

I went ahead and submitted a PR that adds support for rgba8 images. I think it may be helpful to more people so ideally we can merge it, but I am as of now unblocked via my fork. Here is the diff #158

@fschutt
Copy link
Owner

fschutt commented Nov 12, 2024

Yeah, this is definitely fixed in 0.8, soft masks are implemented. Can be closed once 0.8 releases.

@fschutt fschutt added this to the 0.8 milestone Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants