Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Canvas draw image slow
Canvas draw image slow [message #1794687] Wed, 05 September 2018 01:15
zhangyuxiang Mising name is currently offline zhangyuxiang Mising nameFriend
Messages: 31
Registered: March 2011
Member
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
Previous Topic:How to change caret color?
Next Topic:How to Force stop SWT Browser when it runs infinite java script.
Goto Forum:
  


Current Time: Thu Apr 25 11:47:25 GMT 2024

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

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

Back to the top