Help please! JPEG export format doesn't work well

User 23bf771907

12-08-2005 01:48:19

I want to convert the byte[] to java.awt.Image, and it did success. But I found that the Image's width and height are both -1. That will cause a exception during making a BufferedImage(In fact I used jasperreports to export img to a PDF file.). My code like this:





MolHandler handler = new MolHandler(cd_structure);





byte[] molPNG = handler .toBinFormat("jpeg:w600,h600");





java.awt.Image cd_structureImg = Toolkit.getDefaultToolkit().createImage(molPNG);





I don't know where is wrong, Toolkit.getDefaultToolkit() method or the toBinFormat method.





Who have ever met this problem and kindly give me some help? 3Q

ChemAxon 12eab24e0a

12-08-2005 13:25:25

You should use instead of "handler .toBinFormat("jpeg:w600,h600")" the "Molecule.toObject("image:w600,h600")". Which is going to give back an Image object.


http://www.chemaxon.com/marvin/doc/api/chemaxon/struc/Molecule.html#toObject(java.lang.String)

User 23bf771907

15-08-2005 09:07:32

ha, it's perfect!





Thank you very much!