Video support using SWT [message #531455] |
Wed, 05 May 2010 04:32 |
vrush Mising name Messages: 51 Registered: July 2009 Location: Pune |
Member |
|
|
Hi,
I have a view in eclipse where in I wish to show a clipping by handling pixel information. View initializes properly but fails to update in spite of setting new image to canvas.
I tried refreshing the view by hiding and showing the view where it updates the images properly but looses the smoothness.
Please provide any pointers.
Thanks in advance,
Vrushali.
|
|
|
|
Re: Video support using SWT [message #531767 is a reply to message #531752] |
Thu, 06 May 2010 06:15 |
vrush Mising name Messages: 51 Registered: July 2009 Location: Pune |
Member |
|
|
I'm suppose to display a video clipping so to mock I have restricted the scope to viewing 4 different images in view one by one after a particular interval.
Added paint and control listeners.
paintListener calls method paint.
for(int i=0;i<4;i++){
System.out.println("filename\t" + path + arr[i]);
loadImage(path + arr[i]);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
loadImage(String filename){
if (sourceImage != null && !sourceImage.isDisposed()) {
sourceImage.dispose();
sourceImage = null;
}
sourceImage = new Image(getDisplay(), filename);
}
private void paint(GC gc) {
Rectangle clientRect = getClientArea(); /* Canvas' painting area */
if (sourceImage != null) {
Rectangle imageRect =
SWT2Dutil.inverseTransformRect(transform, clientRect);
int gap = 2; /* find a better start point to render */
imageRect.x -= gap; imageRect.y -= gap;
imageRect.width += 2 * gap; imageRect.height += 2 * gap;
Rectangle imageBound = sourceImage.getBounds();
imageRect = imageRect.intersection(imageBound);
Rectangle destRect = SWT2Dutil.transformRect(transform, imageRect);
if (screenImage != null)
screenImage.dispose();
screenImage =
new Image(getDisplay(), clientRect.width, clientRect.height);
GC newGC = new GC(screenImage);
newGC.setClipping(clientRect);
newGC.drawImage(
sourceImage,
imageRect.x,
imageRect.y,
imageRect.width,
imageRect.height,
destRect.x,
destRect.y,
destRect.width,
destRect.height);
newGC.dispose();
gc.drawImage(screenImage, 0, 0);
System.out.println("updated");
} else {
gc.setClipping(clientRect);
gc.fillRectangle(clientRect);
initScrollBars();
}
}
If I debug, value of images changes correctly but fail to update view with those images. It directly shows last image out of those 4 images.
Please help with some pointers. Stuck badly.
Thanks a lot in advance,
Vrushali.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03035 seconds