Use canvas to display video frame images is slow.
Canvas code:
//style
int style = SWT.NO_BACKGROUND | SWT. NO_MERGE_PAINTS | SWT. NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED;
//paint listener
@Override
public void paintControl(PaintEvent event) {
ImageData imageData = getImageData();
if(imageData != null) {
event.gc.setAdvanced(true);
event.gc.setAntialias(SWT.OFF);
org.eclipse.swt.graphics.Image image = new org.eclipse.swt.graphics.Image(canvas.getDisplay(), imageData);
//canvas.setBackgroundImage(iamge);
long start = System.currentTimeMillis();
event.gc.drawImage(image, 0, 0);
System.out.println("Draw image: width=" + imageData.width + ",height=" + imageData.height +
",time=" + (System.currentTimeMillis() - start) + "ms" );
image.dispose();
}
}
Result log:
Draw image: width=1910,height=969,time=160ms
Draw image: width=1910,height=969,time=157ms
Draw image: width=1910,height=969,time=162ms
Draw image: width=1910,height=969,time=167ms
Draw image: width=852,height=501,time=38ms
Draw image: width=852,height=501,time=42ms
Draw image: width=852,height=501,time=43ms
Draw image: width=852,height=501,time=40ms
When image width=1901,height=963, canvas draw image is too slow to display video frames