vpandya Posted July 1, 2009 Share Posted July 1, 2009 Has anybody ever been able to display image on the report without saving it into local drive? I am working hard but no success since last three days.Various options to display image are net.sf.jasperreports.engine.JRRenderable java.lang.String java.io.InputStreamI have tried above three options. The second option works as I pass the path and image is stored in to local drive. But first and last option doesn't work. I get byte[] of image from database(blob --> byte[]) and I pass it to ByteArrayInputStream class. But it doesn't work. I have also tried JRRenderable option but no success. Can somebody tell me what am I missing? Code: PS : Size of imageByteArray is not zero. I have verified that.Post Edited by vpandya at 07/01/2009 15:09 Link to comment Share on other sites More sharing options...
vpandya Posted July 1, 2009 Author Share Posted July 1, 2009 I took a bird's eye view into JRImageRenderer class from source code and found below code snippet, Code: Here, imageLocation variable is of String type but If I have passed an object of InputStream then how come imageLocation variable would get initialized?Post Edited by vpandya at 07/01/2009 15:49 Link to comment Share on other sites More sharing options...
lucianc Posted July 1, 2009 Share Posted July 1, 2009 I have used InputStream and JRRenderable object as image source and it worked fine. I can't tell what you are doing wrong based on the current information, post more details (full test case would be best), or do more debugging on your code.Regards,LucianPS: If you take another look at the JRImageRenderer code you'll notice that imageLocation is only used when imageData is null, and it shouldn't be null in your case. Link to comment Share on other sites More sharing options...
lukus Posted July 2, 2009 Share Posted July 2, 2009 Hi I found that the best way to do this was with my own class. I used the awt Toolkit to create the image from a bit stream, then used MediaTracker to load it and pass it to a BufferedImage where its resized and drawn on a Graphics object. The Graphics object is then returned. The class is invoked in jasper report. Hope this gets you started 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