Results 1 to 1 of 1
- 08-20-2009, 04:05 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 1
- Rep Power
- 0
Multiple Images on a Canvas with SWT
Hi i was using this as reference h**p://w**.eclipse.org/articles/Article-Image-Viewer/Image_viewer.html, A basic image viewer to create an image viewer, and the class of the example works perfectly. The thing is i am trying to create a vertical index on one of the sides of the interface and the idea is that the index will show and smaller image of the pictures that are on the same folder of the main image i am displaying on my program. So they have to be displayed on a certain size so they would fit on canvas. I tried a lot of things but i finally end up creating a Class called Indice that is a daughter class from Canvas (swt), and it has a paint function, and has an array of images. But this has been proved to be very un-efficient because when i am loading a folder with more tha 20 images it takes for ever to load the index.
Is there a way to load a mini image of a picture instead of the whole image? What would be the correct way of loading this images.
This is my paint function.
Kind of like an image previewJava Code:private void paint(GC gc) { Rectangle clientRect = getClientArea(); /* Canvas' painting area */ if (sourceImage != null){ int alto=0; /* Y point for sourceImage[i] to s*/ int espacio=10; /* Gap or space between images*/ for(int i=0;i<sourceImage.length;i++){ if (sourceImage[i] != null) { if(i>0) alto+=espacio; Rectangle imageBound = sourceImage[i].getBounds(); // Ratio of the Image real width with the Canvas width double prop = (double)imageBound.width/clientRect.width; //The height of the image displayed. int altoImg = (int)((double)imageBound.height/prop); //gc.drawImage(sourceImage[i], 0, alto); gc.drawImage( sourceImage[i], 0, 0, imageBound.width, imageBound.height, 0, alto, clientRect.width, altoImg ); alto+=altoImg; } } } else { gc.setClipping(clientRect); gc.fillRectangle(clientRect); initScrollBars(); } }
Similar Threads
-
SWT Canvas drawing realtive to image space not canvas space.
By bobbie in forum SWT / JFaceReplies: 0Last Post: 07-05-2009, 12:31 PM -
Adding multiple images to frame
By 435.mahesh in forum AWT / SwingReplies: 1Last Post: 04-24-2009, 08:31 PM -
Using a Canvas
By a_klasanov in forum CLDC and MIDPReplies: 3Last Post: 12-08-2008, 10:36 AM -
Help with canvas
By tankhardrive in forum New To JavaReplies: 13Last Post: 10-29-2008, 08:08 PM -
Privileged processing of multiple images?
By peci1 in forum Java AppletsReplies: 0Last Post: 11-20-2007, 11:57 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks