2001 JI Open Discussion Posted August 21, 2006 Share Posted August 21, 2006 By: Hawk - crunchyk9 HTML/Java2d Export Images Look Terrible 2005-03-29 14:37My images look like they were hit with the ugly stick. They look great in PDF, but when I look at them in HTML or using the JRViewer, the scaling looks terrible. The images are scaled to about 1/2 their size, and the scaling algorythm both JRViewer and my browser use just mutilate them. Because of my existing asset store, going in and rescaling the images is not an option. I need a way to scale them as the report is being generated, but do it using a better algorythm. anybody got any ideas? Thanks. -- Hawk By: Doug Berkland - berkland RE: HTML/Java2d Export Images Look Terrible 2005-03-29 15:52If you have the algorithm, create a class that exposes the algorithm. (e.g. package mymagicpackage; public class MagicImageScaler { public java.awt.Image scaleImage(String argImageLocation) { /*magic goes here*/ } }). Create an instance of this class and pass it into the report as a parameter (e.g. named "ImageScaler".) In your image field, use the parameter to scale the actual image. (e.g. ((mymagicpackage.MagicImageScaler)$P{ImageScaler}).scaleImage($F{ImageURI})) By: Hawk - crunchyk9 RE: HTML/Java2d Export Images Look Terrible 2005-03-31 10:47For anyone else that ends up in this boat: All I had to do was create a new class which implements JRRenderable. I create an instance of JRImageRenderer and just delegate everthing to it, except render(), which just sets some hints on the graphics context (dithering to off and interpolation to bilinear) and then I just delegate the actual rendering to the JRImageRenderer instance. It's works well. All I have to do is specify my new class name in my .jrxml file. The HTML was a little nasier. I just extended the JRHtmlExporter and overrode exportImage(). It was much Easier than you'd think. Excellent job teodord, you've really developed a great product. -- Hawk Link to comment Share on other sites More sharing options...
shivenderd Posted November 20, 2007 Share Posted November 20, 2007 Hey,I am facing this problem. I did not understand the solution can anybody explain me this? Thanks,Shiv Link to comment Share on other sites More sharing options...
shivenderd Posted November 21, 2007 Share Posted November 21, 2007 I believe I found the solution for my problem. It is like this:The actual size of the image file is 515 X 287 and We have following statements in JRHtmlExporter:int imageWidth = image.getWidth() - image.getLeftPadding() - image.getRightPadding(); int imageHeight = image.getHeight() - image.getTopPadding() - image.getBottomPadding(); The caluculated width and height values are used in HTML <img> tag for width and height. This shrinks the actual image size... Solution:I have given padding values to zero in the corrosponding <style> tag in JRXML file as I don't want to change the JRHtmlExporter content. any comments?? Thanks,Shivender Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now