DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
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



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links