This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Saving a JDialog using ImageIO giving many problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Saving a JDialog using ImageIO giving many problems" Watch "Saving a JDialog using ImageIO giving many problems" New topic
Author

Saving a JDialog using ImageIO giving many problems

Repala Madhu
Greenhorn

Joined: Jun 12, 2007
Posts: 14
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

Joined: Jun 12, 2007
Posts: 14
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

Joined: Sep 20, 2005
Posts: 862
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?


bitguru blog
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Saving a JDialog using ImageIO giving many problems
 
Similar Threads
SWING Multiple GUI
Help with JDialog Close Operation
Diagram Size Part II Please Help!!!!!!
JUDE produces big JPEG images
JFileChooser loses focus when clicked away and back