Retrieve Image From JLabel and store it in a variable in Java

旧街凉风 提交于 2020-01-23 17:48:30

问题


How do I retrieve an my image that has been fetched from mysql database and store it in a variable?

The image retrieved from the database is as follows:

byte[] imageData = rs.getBytes("Image");
format = new ImageIcon(imageData);
lblimg.setIcon(format);

Now what I want to do, to store the lblimg into a variable. Then I can use the variable which contains the image to add in a pdf file.

Document doc = new Document();
PdfWriter.getInstance(doc, new FileOutputStream("Report.pdf"));
doc.open();

doc.add(new Paragraph( // img to be added here ));

Please help me to achieve that. Thanks

来源:https://stackoverflow.com/questions/29644685/retrieve-image-from-jlabel-and-store-it-in-a-variable-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!