Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Fasted way to display images?
Fasted way to display images? [message #531649] Wed, 05 May 2010 16:21 Go to next message
Eclipse UserFriend
Originally posted by: txbarth.web.de

Hi,
I would like to display catched images of a webcam in my Java/SWT
Application. Today I simulated a webcam by loading 24 jpeg pictures per
second on canvas. But the cpu is beeing charged by 60-70%.

[...]
canvas.addPaintListener (new PaintListener () {
public void paintControl (PaintEvent event) {
if(null != imageData) {
Image image = new Image(getDisplay(), imageData);

[code to get sizes and position]

event.gc.drawImage (image, 0, 0, img_width, img_height,
destX, destY, scale_width, scale_height);

image.dispose();

}
}
});

[...]


// Method that calls canvas.redraw 41 times a second
private static void startTimer() {
if(null != timer) {
return;
}

timer = new Timer();
TimerTask timerTask = new TimerTask() {
public void run() {
String filename = files[pos];
imageData = loadImageData(filename);

Display.getDefault().asyncExec(new Runnable() {
public void run() {
if(canvas.isDisposed()) return;

canvas.redraw();
}
});

pos++;

if(pos >= files.length) {
pos = 0;
}
}
};

timer.schedule(timerTask, 0, 41);
}


Is this the fasted way to paint complete images on canvas?

Thomas B
Re: Fasted way to display images? [message #532157 is a reply to message #531649] Fri, 07 May 2010 11:14 Go to previous message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
May be this snippet for showing animated gif will help you

http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.ecli pse.swt.snippets/src/org/eclipse/swt/snippets/Snippet141.jav a


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Previous Topic:Buffer to SWT image?
Next Topic:Video support using SWT
Goto Forum:
  


Current Time: Fri Nov 28 08:55:15 GMT 2014

Powered by FUDForum. Page generated in 0.01766 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software