Jump to content
We've recently updated our Privacy Statement, available here ×

Printing java.awt.Image from report parameter


niik

Recommended Posts

Hi all,

Does anyone have experience printing an image from a report parameter of type java.awt.Image? The image prints, but the colors are distorted/inverted.

These are the corresponding lines in the report:

<parameter name="sigImage" isForPrompting="false" class="java.awt.Image"/>

<imageExpression class="java.awt.Image"><![CDATA[$P{sigImage}]]></imageExpression>


The image is generated from an encrypted signature file before filling the report and stored as a java.awt.Image in a HashMap along with other report parameters that are passed into the report:

Map parameters = new HashMap();
parameters.put("sigImage",img);
jasperPrint = JasperFillManager.fillReport(rptfile,parameters,ds);


img is a java.awt.Image. I have tried replacing img with a JPG read from disk: same result, the image prints with inverted colors. If I export img as a file to disk from the Java program, it looks fine, even if I use the image retrieved from the HashMap. Only if I change the image expression in the report to type String and specify a file name, the image prints correctly.

Any help would be appreciated, thanks in advance.
 



Post Edited by niik at 06/29/2009 16:26
Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

As a workaround, I ended up writing the image to disk as a temporary JPG file. I can pass the file name into the report as a report parameter and use an image expression of type String to print the JPG.

I can use this for right now, but would appreciate any information on a cleaner solution. Thanks.

Link to comment
Share on other sites

  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...