954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Images

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

public void export(JComponent Component) 
{

  File f1 = new File("C:\\Temp.PNG");
  Dimension Size5 = Component.getSize();  
  BufferedImage Image1 = new BufferedImage(Size5.width, Size5.height,  BufferedImage.TYPE_INT_ARGB);	
  Graphics2D g2 = Image1.createGraphics();		
  g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC);
  Component.paint(g2);	

try
{
     ImageIO.write(Image1, "PNG", f1);
}

catch (Exception e)
{
     e.printStackTrace();
}

}


I hope someone can help with this problem

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West

freesoft_2000
Practically a Master Poster
623 posts since Jun 2004
Reputation Points: 25
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You