Andrey has posted 1 posts at DZone. View Full User Profile

Imagero Rivi 1.2: fast image viewer for RenderedImages

02.20.2008
| 2774 views |
  • submit to reddit
Imagero Rivi is a high-performance image display component (Swing) suitable for viewing very big images.
Rivi uses asynchronous image tile loading in separate thread so that GUI always stays responsible. 
Rivi uses own tile cache to increase speed.
To avoid OutOfMemoryErrors tile cache uses SoftReferences.
Rivi is open source and very easy to use.
http://reader.imagero.com/rivi/
 
Requirements:
* Java 1.4 and later
* JAI
* Tiled RenderedImage
Changes: 
This release fixes well known Java2D performance problem which occurs with TYPE_CUSTOM BufferedImages.
Usage:
1. Show RenderedImage:
public void show(RenderedImage img) {
    RIViewer ri = new RIViewer(img);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new JScrollPane(ri));
frame.pack()
frame.show();
} 
2. Create RenderedImage:
2.a.  with ImageIO:
public static RenderedImage createImage_IIO(File f, int tileWidth, int ileHeight) {
ImageInputStream iis = ImageIO.createImageInputStream(f); ParameterBlockJAI pbj = new ParameterBlockJAI("ImageRead"); ImageLayout layout = new ImageLayout(); layout.setTileWidth(tileWidth); layout.setTileHeight(tileHeight); RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
    pbj.setParameter("Input", iis);
return JAI.create("ImageRead", pbj, hints);
}
 2.b. with Imagero:
public static RenderedImage createImage_Imagero(File f, int tileWidth, int ileHeight) {
    IOParameterBlock iopb = new IOParameterBlock();
    iopb.addSource(f); 
     ImageProcOptions options = new ImageProcOptions();
    options.setSource(iopb); 
    return Imagero.getAsRenderedImage(options, tileWidth, tileHeight); 
} 
 
 
0
Published at DZone with permission of its author, Andrey Kuznetsov.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)