Images


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Images

  1. #1
    Join Date
    Oct 2004
    Posts
    151

    Question 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

    Code:
    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

  2. #2
    Join Date
    Jan 2005
    Posts
    45
    Hello,

    An alternative strategy could be to emule print screen key (using robot class) then save the clipboard content (clipboard class) to a BMP file, yet honestly I haven't try it.

    Hope that could be useful,
    Lionel Badiou
    CodeFutures -
    Java Code Generation

    http://www.codefutures.com



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center