Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-13-2004, 03:22 PM   #1 (permalink)
freesoft_2000
Code Monkey
 
Join Date: Oct 2004
Posts: 51
freesoft_2000 is on a distinguished road
Question Quality

Hi everyone,
I am trying to export a jcomponent as an image. The program all works but seriously the the quality of the saved image is really disgusting.
The words seems to be blurred. I think i have to use rendereing hints but i am not sure how there work or which hint to use for my situation.

Here is the code i use to convert a jcomponent to an image file

public void exporttableasjpeg(JComponent Component)
{
String k;

FileChooser1.setDialogType(JFileChooser.SAVE_DIALO G);
FileChooser1.setDialogTitle("Select Export File");

if(FileChooser1.showDialog(fr1, "Export") != JFileChooser.APPROVE_OPTION)
{
return;
}

File f = FileChooser1.getSelectedFile();
k = (f.toString() + ".JPG");
Dimension Size4 = Component.getSize();
BufferedImage Image1= new BufferedImage(Size4.width, Size4.height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = Image1.createGraphics();
//I need someone to suggest a good hint to use for this situation

g2.setRenderingHint(RenderingHints.KEY_INTERPOLATI ON,RenderingHints.VALUE_INTERPOLATION_BICUBIC);
Component.paint(g2);

try
{
OutputStream out = new FileOutputStream(k);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(Image1);
out.close();
}

catch (Exception e)
{
Label1.setText("An error exporting the table as an image has occurred");
}

}

Basically i need someone to tell me if i am using the rendering hint in the right way and also to recommend an appropriate hint for my situation

Thank You

Yours Sincerely

Richard West
freesoft_2000 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 10:51 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting