Images

Reply

Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 7
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Images

 
0
  #1
Jan 16th, 2005
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

  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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC