944,083 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2630
  • Java RSS
Jan 16th, 2005
0

Images

Expand Post »
Hi everyone,

I have a bit of a problem converting a JTextPane to an image.
I am able to convert the JTextPane to a PNG image but its quality is really bad. Is there a way that i can convert my JTextPane to a high quality image.

The type of image format does not matter

Here is what i have so far

Java Syntax (Toggle Plain Text)
  1.  
  2. public void export(JComponent Component)
  3. {
  4.  
  5. File f1 = new File("C:\\Temp.PNG");
  6. Dimension Size5 = Component.getSize();
  7. BufferedImage Image1 = new BufferedImage(Size5.width, Size5.height, BufferedImage.TYPE_INT_ARGB);
  8. Graphics2D g2 = Image1.createGraphics();
  9. g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC);
  10. Component.paint(g2);
  11.  
  12. try
  13. {
  14. ImageIO.write(Image1, "PNG", f1);
  15. }
  16.  
  17. catch (Exception e)
  18. {
  19. e.printStackTrace();
  20. }
  21.  
  22. }

I hope someone can help with this problem

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
Similar Threads
Reputation Points: 25
Solved Threads: 10
Practically a Master Poster
freesoft_2000 is offline Offline
623 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Creating data access layer in java
Next Thread in Java Forum Timeline: simple calculator help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC