[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.technology.nebula] Re: load image to Gallery very slow

Hi Gaston,

AWT will add additionnal work to convert images to SWT so this won't give you any speed improvements.

The code you provided uses the virtual mode but does not use threads. Try to do the image loading and resize work in a Thread or a Job.

Note that the code on my blog uses the maximum processing quality, which is the slowest :

gc.setAntialias(SWT.ON);
gc.setInterpolation(SWT.HIGH);

try to replace the previous code by

gc.setAntialias(SWT.OFF);
gc.setInterpolation(SWT.LOW);

This is often enough for thumbnails.

And don't forget to keep track of Image objects. You have to dispose them after use (the gallery won't do this automatically).

--
Nicolas

gaston a écrit :
Hi, I change mi code, is better, but is a bit slow.
It is better to do with AWT and then convert to SWT for use in the gallery? The code for Resize is yours and is in your blog.


gallery.addListener(SWT.SetData, new Listener() {

   public void handleEvent(Event event) {
    GalleryItem item = (GalleryItem) event.item;
    int index;
    if (item.getParentItem() != null) {
        index = item.getParentItem().indexOf(item);
        item.setItemCount(0);
    } else {
        index = gallery.indexOf(item);
        item.setItemCount(100);
    }

System.out.println( "setData index " + index); //$NON-NLS-1$
// map is a map with file path
Image img = resize(map.get(index), 640,480); item.setImage(img);
item.setText("Item " + index); //$NON-NLS-1$
}
}); Regards.
And Thank you.