Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Buffer to SWT image?
Buffer to SWT image? [message #531958] Thu, 06 May 2010 15:08 Go to next message
Eclipse User
Originally posted by: txbarth.web.de

Hi,
I would like to grab frames of a webcam by pressing a button. The frame
is saved in a buffer and than converted to an image. In the following
example I have to convert the buffer to an awt image first and than
convert it to an swt image to be able to display the image on a swt
canvas. Is it possible to create the swt image from buffer directly?

button2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FrameGrabbingControl fgc = (FrameGrabbingControl)
player.getControl("javax.media.control.FrameGrabbingControl ");

Buffer buffer = fgc.grabFrame();

BufferToImage bufferToImage = new
BufferToImage((VideoFormat)buffer.getFormat());

java.awt.Image image = bufferToImage.createImage(buffer);

imageData = convertAWTImageToSWT(image);

canvas.redraw();
}
});

The convertAWTImageToSWT method can be found here
http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/Convertsab ufferedimagetoSWTImageData.htm

Thomas B
Re: Buffer to SWT image? [message #532154 is a reply to message #531958] Fri, 07 May 2010 11:13 Go to previous message
Vijay Raj
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:Proxy type in swt.Browser
Next Topic:Fasted way to display images?
Goto Forum:
  


Current Time: Fri Sep 19 17:59:09 GMT 2014

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

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