Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3078 > unrolled thread

Creating image thumbnails

Started by"Bill" <bill@THRWHITE.remove-dii-this>
First post2011-04-27 15:42 +0000
Last post2011-04-27 15:42 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.lang.java.gui


Contents

  Creating image thumbnails "Bill" <bill@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000
    Re: Creating image thumbn "RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000
    Re: Creating image thumbn "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000

#3078 — Creating image thumbnails

From"Bill" <bill@THRWHITE.remove-dii-this>
Date2011-04-27 15:42 +0000
SubjectCreating image thumbnails
Message-ID<bill-A6EC28.06533726012008@sn-ip.vsrv-sjc.supernews.net>
  To: comp.lang.java.gui
My java application is given a list of image files.  For each image, it 
creates an image thumbnail and displays this thumbnail in a separate 
JFrame.  The creation of these thumbnails is very slow compared to the 
Mac Preview application.  Is there a way to speed this up?

Each thumbnail is displayed in a separate JFrame to allow the thumbnails 
to be dragged and repositioned on the screen independently.  Each 
thumbnail is converted to an ImageIcon and displayed in a JButton.  
Clicking on the button will rotate the image 90 degrees.

Here is the method which creates the JFrame.  I'd appreciate any 
suggestions how I can improve performance speed.



private final static int
    FRAME_WIDTH  = 0,
    FRAME_HEIGHT = 20,
    THUMB_WIDTH  = 150,
    THUMB_HEIGHT = 225;

            
private JFrame createFrame(File file)
{
    Image image = 
Toolkit.getDefaultToolkit().createImage(file.getPath());

    Image thumb = image.getScaledInstance(THUMB_WIDTH, THUMB_HEIGHT, 
Image.SCALE_SMOOTH);
            
    JButton button = new JButton(new ImageIcon(thumb));
    button.addActionListener(myButtonListener);
            
    JFrame frame = new JFrame();
    frame.setTitle(file.getName());
    frame.setSize(FRAME_WIDTH + THUMB_WIDTH, FRAME_HEIGHT + 
THUMB_HEIGHT);
    frame.setLayout(new BorderLayout());
    frame.add(button, BorderLayout.CENTER);
                
    return frame;
}

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#3080 — Re: Creating image thumbn

From"RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this>
Date2011-04-27 15:42 +0000
SubjectRe: Creating image thumbn
Message-ID<DcqdnUO9pfwRpwbanZ2dnUVZ8hednZ2d@bt.com>
In reply to#3078
  To: comp.lang.java.gui
Bill wrote:
> My java application is given a list of image files.  For each image,
> it creates an image thumbnail and displays this thumbnail in a
> separate JFrame.  The creation of these thumbnails is very slow
> compared to the Mac Preview application.  Is there a way to speed
> this up?

When optimising, I'd first find out what part of your program is slow -
instrument it and/or profile it or benchmark it.


> Each thumbnail is displayed in a separate JFrame to allow the
> thumbnails to be dragged and repositioned on the screen
> independently.

To me that seems a bit unnecessary. I imagine it would be a great deal
faster to do your own 2d rendering. That way you're avoid instantiating
lots of JFrames.


> Each thumbnail is converted to an ImageIcon and displayed in a
> JButton. Clicking on the button will rotate the image 90 degrees.
> 
> Here is the method which creates the JFrame.  I'd appreciate any 
> suggestions how I can improve performance speed.

I believe a lot of similar applications cache the thumbnails in memory
and some save the thumbnails to disk - reading a thumbnail from disk has
to be faster than reading a large image and then resizing it.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3084 — Re: Creating image thumbn

From"Roedy Green" <roedy.green@THRWHITE.remove-dii-this>
Date2011-04-27 15:42 +0000
SubjectRe: Creating image thumbn
Message-ID<96tnp31v11j6qcl3pid2dseb9jh256d8ch@4ax.com>
In reply to#3078
  To: comp.lang.java.gui
On Sat, 26 Jan 2008 06:53:38 -0600, Bill <bill@nospam.com> wrote,
quoted or indirectly quoted someone who said :

>My java application is given a list of image files.  For each image, it 
>creates an image thumbnail and displays this thumbnail in a separate 
>JFrame.  The creation of these thumbnails is very slow compared to the 
>Mac Preview application.  Is there a way to speed this up?

Consider looking for a fast app, possibly not written in Java that has
batch facilities to convert images.  Then use the exec feature to
control it.

See http://mindprod.com/jgloss/exec.html

The hard way to do it is to study up on the format of the files you
are thumbnailing, then see if you can come up with a fast algorithm to
shrink them and write it in assembler and hook to it with JNI. This
might be feasible if the shrinking is always a power of two.  A power
of two algorithm would be faster than a generic one. Each pixel is a
weighted average of a set of surrounding pixels. Use shift for your
divide.

See http://mindprod.com/jgloss/jni.html
-- 
Roedy Green, Canadian Mind Products
The Java Glossary, http://mindprod.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web