Buffer to SWT image? [message #531958] |
Thu, 06 May 2010 15:08 |
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03112 seconds