public interface VImage extends VType
ValueUtil.toImage(org.epics.vtype.VImage)
and ValueUtil.toVImage(java.awt.image.BufferedImage)
to convert objects
of this class to and from awt images.
The data is currently encoded as 3 bytes for each pixel (RGB). To read the buffer in AWT use the following code:
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR); System.arraycopy(buffer, 0, ((DataBufferByte) image.getRaster().getDataBuffer()).getData(), 0, 100*100*3);
To read in SWT:
ImageData imageData = new ImageData(width, height, 24, new PaletteData(0xFF, 0xFF00, 0xFF0000), width*3, buffer); Image image = new Image(gc.getDevice(), imageData);
To prepare an image using Java2D:
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR); Graphics2D g = image.createGraphics(); ... byte[] buffer = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
TODO: should be extended to support different encodings.
Copyright © 2010–2015. All rights reserved.