Category: | Bug report |
Priority: | Normal |
Status: | Feedback Requested |
Project: | Severity: | Minor |
Resolution: | Open |
|
Component: | Reproducibility: | Always |
Assigned to: |
My report files (jrxml) use the tag "imageExpression", I pass java.awt.Image instances into it, they have an alpha channel and some transparency.
Expected result:
When I generate my reports (PDF), the background color is the one set in Jasper Studio.
Current result:
When I generate my reports (PDF), I always obtain a black background.
Workaround:
Pass an instance of net.sf.jasperreports.engine.Renderable with the image type ImageTypeEnum.PNG when the alpha and the transparency are properly detected instead of an instance of java.awt.Image. It requires to modify each report.
Root cause:
The alpha and the transparency are correctly handled only in a very particular case when the passed java.awt.Image is an instance of java.awt.image.RenderedImage:
http://sourceforge.net/p/jasperreports/code/ci/master/tree/jasperreports...
http://sourceforge.net/p/jasperreports/code/ci/master/tree/jasperreports...
However, there are some other trivial cases not handled by the code above as you can see in this example:
http://exampledepot.8waytrips.com/egs/java.awt.image/GetColorModel.html
A (debatable) addition consists in using a class of the internal Java API to avoid using a pixel grabber when the image comes from the AWT toolkit:
if (image instanceof sun.awt.image.ToolkitImage) {
sun.awt.image.ToolkitImage tkImage = (sun.awt.image.ToolkitImage) image;
return tkImage.getColorModel();
}
Possible patch:
Use the method getColorModel() above instead of handling only java.awt.image.RenderedImage.
I can provide a clean patch if you want. Best regards.
5 Comments:
Hi,
A patch would be great!
Thanks,
Teodor
Thank you Teodor. I'll post a patch next week.
Please find my first patch above (see bug5031_jasperreportslibrary.patch).
I provided a patch more than two years ago and I'm still waiting for a feedback about it. Is there anything wrong?