File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Saving a JDialog using ImageIO giving many problems

 
Repala Madhu
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I am saving a JDialog of sige 8000 X 8000 by using ImageIO.

In my project one JInternalFrame of size 600 X 600 is there, I have a network topology (Ring) on that, It has zoom in and zoom out fecility, if i save the same dialog box the topology which is there on that, that much only i could have save as an image. So i am taking the panal of that InternalFrame and adding to JDialog. and saving this dialog box which is of size 8000 X 8000 by using ImageIO.

to save this dialog box it is taking more than 15 mins.

How can i decrease the saving time,

My project main frame is freezing while saving this dialog box,
How could i stop freezing.

And i want to show a progress bar while saving the image, but this progress bar is getting visible after saving the image, and unfortunately this progress bar is adding the my saving image.


Can anybody help me in this regard.

Thanks in adwans.
 
Repala Madhu
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all the code i am using is


/**
* Create a BufferedImage for given component.
* Opens a Save dialog box, takes the location to save.
* All or part of the component can be captured to an image.
*@param component Swing component to create image from
* */

private void saveDtv(Component component,String fileName)
{
if (fileName != null)
{
try{
File name=new File(fileName);
BufferedImage image =new BufferedImage( component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB);

Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
component.paint(g);
g.dispose();
ImageIO.write(image,"png",name);
}catch(Exception ex)
{
Log.gLog().debug("In createImage() Error while image capture:",ex);
JOptionPane.showMessageDialog(MainFrame.getMainFrame(),ex,"Error",JOptionPane.ERROR_MESSAGE);
((JDialog)component).dispose();
}
}
((JDialog)component).dispose();
}
 
Brian Cole
Author
Ranch Hand
Posts: 886
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's really an 8000x8000 image, that's on the order of 200MB of raw data before PNG compression. Could it be that this has nothing to do with your dialog or Swing and that writing almost any 8000x8000 PNG would take that long?

things that I wonder:

A) What kind of screen do you have that can display a 8000x8000 pixel dialog box?

B) Does it really make sense to store a dialog box as an image?

C) Would it work any better if you used TYPE_BYTE_INDEXED instead of TYPE_INT_RGB?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic