本文整理了Java中java.awt.image.Raster.createWritableRaster
方法的一些代码示例,展示了Raster.createWritableRaster
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Raster.createWritableRaster
方法的具体详情如下:
包路径:java.awt.image.Raster
类名称:Raster
方法名:createWritableRaster
暂无
代码示例来源:origin: sarxos/webcam-capture
@Override
public BufferedImage getImage() {
ByteBuffer buffer = getImageBytes();
if (buffer == null) {
LOG.error("Images bytes buffer is null!");
return null;
}
byte[] bytes = new byte[size.width * size.height * 3];
byte[][] data = new byte[][] { bytes };
buffer.get(bytes);
DataBufferByte dbuf = new DataBufferByte(data, bytes.length, OFFSET);
WritableRaster raster = Raster.createWritableRaster(smodel, dbuf, null);
BufferedImage bi = new BufferedImage(cmodel, raster, false, null);
bi.flush();
return bi;
}
代码示例来源:origin: loklak/loklak_server
DataBuffer videoBuffer = new DataBufferByte(frame, frame.length);
ComponentSampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_BYTE, width, height, 3, width * 3, new int[] {0, 1, 2});
this.grid = Raster.createWritableRaster(sampleModel, videoBuffer, null);
ColorModel colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), null, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
this.image = new BufferedImage(colorModel, this.grid, false, null);
代码示例来源:origin: sarxos/webcam-capture
WritableRaster raster = Raster.createWritableRaster(sampleModel, dataBuffer, null);
BufferedImage image = new BufferedImage(colorModel, raster, false, null);
代码示例来源:origin: runelite/runelite
@MethodHook(value = "<init>", end = true)
@Inject
public void init(int width, int height, Component canvas)
{
if (!client.isGpu())
{
return;
}
final int[] pixels = getPixels();
// we need to make our own buffered image for the client with the alpha channel enabled in order to
// have alphas for the overlays applied correctly
DataBufferInt dataBufferInt = new DataBufferInt(pixels, pixels.length);
DirectColorModel directColorModel = new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
32, 0xff0000, 0xff00, 0xff, 0xff000000,
true, DataBuffer.TYPE_INT);
WritableRaster writableRaster = Raster.createWritableRaster(directColorModel.createCompatibleSampleModel(width, height), dataBufferInt, null);
BufferedImage bufferedImage = new BufferedImage(directColorModel, writableRaster, true, new Hashtable());
setImage(bufferedImage);
}
代码示例来源:origin: geoserver/geoserver
return Raster.createWritableRaster(sampleModel, db, location);
代码示例来源:origin: haraldk/TwelveMonkeys
@Override
public final WritableRaster createCompatibleWritableRaster(final int w, final int h) {
return Raster.createWritableRaster(createCompatibleSampleModel(w, h), new Point(0, 0));
}
代码示例来源:origin: mapsforge/mapsforge
@Override
public AwtHillshadingBitmap createMonoBitmap(int width, int height, byte[] buffer, int padding, BoundingBox area) {
DataBuffer dataBuffer = new DataBufferByte(buffer, buffer.length);
SampleModel singleByteSampleModel = monoColorModel.createCompatibleSampleModel(width + 2 * padding, height + 2 * padding);
WritableRaster writableRaster = Raster.createWritableRaster(singleByteSampleModel, dataBuffer, null);
BufferedImage bufferedImage = new BufferedImage(monoColorModel, writableRaster, false, null);
return new AwtHillshadingBitmap(bufferedImage, padding, area);
}
代码示例来源:origin: geotools/geotools
protected BufferedImage getStartImage(BufferedImage copyFrom, int width, int height) {
Map<String, Object> properties = null;
if (copyFrom.getPropertyNames() != null) {
properties = new HashMap<String, Object>();
for (String name : copyFrom.getPropertyNames()) {
properties.put(name, copyFrom.getProperty(name));
}
}
SampleModel sm = copyFrom.getSampleModel().createCompatibleSampleModel(width, height);
WritableRaster raster = Raster.createWritableRaster(sm, null);
BufferedImage image =
new BufferedImage(
copyFrom.getColorModel(),
raster,
copyFrom.isAlphaPremultiplied(),
(Hashtable<?, ?>) properties);
// white background
Graphics2D g2D = (Graphics2D) image.getGraphics();
Color save = g2D.getColor();
g2D.setColor(Color.WHITE);
g2D.fillRect(0, 0, image.getWidth(), image.getHeight());
g2D.setColor(save);
return image;
}
代码示例来源:origin: geotools/geotools
private BufferedImage getStartImage(BufferedImage copyFrom) {
Dimension dim = getStartDimension();
Hashtable<String, Object> properties = null;
if (copyFrom.getPropertyNames() != null) {
properties = new Hashtable<String, Object>();
for (String name : copyFrom.getPropertyNames()) {
properties.put(name, copyFrom.getProperty(name));
}
}
SampleModel sm =
copyFrom.getSampleModel()
.createCompatibleSampleModel((int) dim.getWidth(), (int) dim.getHeight());
WritableRaster raster = Raster.createWritableRaster(sm, null);
ColorModel colorModel = copyFrom.getColorModel();
boolean alphaPremultiplied = copyFrom.isAlphaPremultiplied();
DataBuffer dataBuffer =
createDataBufferFilledWithNoDataValues(raster, colorModel.getPixelSize());
raster = Raster.createWritableRaster(sm, dataBuffer, null);
BufferedImage image = new BufferedImage(colorModel, raster, alphaPremultiplied, properties);
if (levelInfo.getNoDataValue() == null) {
Graphics2D g2D = (Graphics2D) image.getGraphics();
Color save = g2D.getColor();
g2D.setColor(backgroundColor);
g2D.fillRect(0, 0, image.getWidth(), image.getHeight());
g2D.setColor(save);
}
return image;
}
代码示例来源:origin: geotools/geotools
return Raster.createWritableRaster(sampleModel, db, location);
代码示例来源:origin: geotools/geotools
final ColorModel colorModel = ImageIOUtilities.createColorModel(sampleModel);
final WritableRaster raster = Raster.createWritableRaster(sampleModel, new Point(0, 0));
Hashtable<String, Object> properties = getNoDataProperties(wrapper);
final BufferedImage image =
代码示例来源:origin: geotools/geotools
SampleModel sampleModel = imageTypeSpecifier.getSampleModel();
Point location = new Point(0, 0);
WritableRaster raster = Raster.createWritableRaster(sampleModel, location);
GridCoverage2D emptyCoverage;
emptyCoverage = coverageFactory.create(coverageName, raster, requestedEnvelope);
代码示例来源:origin: org.apache.xmlgraphics/batik-awt-util
public Raster getTile(int x, int y) {
if (me2src == null)
return null;
int tx = tileGridXOff+x*tileWidth;
int ty = tileGridYOff+y*tileHeight;
Point pt = new Point(tx, ty);
WritableRaster wr = Raster.createWritableRaster(sm, pt);
genRect(wr);
return wr;
}
代码示例来源:origin: net.imagej/ij
void createBufferedImage() {
if (rgbSampleModel==null)
rgbSampleModel = getRGBSampleModel();
if (rgbRaster==null) {
DataBuffer dataBuffer = new DataBufferInt(rgbPixels, width*height, 0);
rgbRaster = Raster.createWritableRaster(rgbSampleModel, dataBuffer, null);
}
if (rgbImage==null)
rgbImage = new BufferedImage(rgbCM, rgbRaster, false, null);
awtImage = rgbImage;
}
代码示例来源:origin: org.apache.xmlgraphics/batik-awt-util
public Raster getData(Rectangle rect) {
SampleModel smRet = sm.createCompatibleSampleModel
(rect.width, rect.height);
Point pt = new Point(rect.x, rect.y);
WritableRaster wr = Raster.createWritableRaster(smRet, pt);
// System.out.println("GD DB: " + wr.getDataBuffer().getSize());
return copyData(wr);
}
代码示例来源:origin: net.imagej/ij
Image createBufferedImage() {
if (rgbSampleModel==null)
rgbSampleModel = getRGBSampleModel();
if (rgbRaster==null) {
DataBuffer dataBuffer = new DataBufferInt(pixels, width*height, 0);
rgbRaster = Raster.createWritableRaster(rgbSampleModel, dataBuffer, null);
}
if (image==null) {
image = new BufferedImage(cm, rgbRaster, false, null);
}
return image;
}
代码示例来源:origin: xSAVIKx/AndroidScreencast
private static BufferedImage rawImage32toARGB(RawImage rawImage) {
// Do as much as we can to not make an extra copy of the data. This is just a bunch of
// classes that wrap's the raw byte array of the image data.
DataBufferByte dataBuffer = new DataBufferByte(rawImage.data, rawImage.size);
PixelInterleavedSampleModel sampleModel =
new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, rawImage.width, rawImage.height,
4, rawImage.width * 4, BAND_OFFSETS_32);
WritableRaster raster = Raster.createWritableRaster(sampleModel, dataBuffer,
new Point(0, 0));
return new BufferedImage(new ThirtyTwoBitColorModel(rawImage), raster, false, EMPTY_HASH);
}
代码示例来源:origin: xSAVIKx/AndroidScreencast
private static BufferedImage rawImage16toARGB(RawImage rawImage) {
// Do as much as we can to not make an extra copy of the data. This is just a bunch of
// classes that wrap's the raw byte array of the image data.
DataBufferByte dataBuffer = new DataBufferByte(rawImage.data, rawImage.size);
PixelInterleavedSampleModel sampleModel =
new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, rawImage.width, rawImage.height,
2, rawImage.width * 2, BAND_OFFSETS_16);
WritableRaster raster = Raster.createWritableRaster(sampleModel, dataBuffer,
new Point(0, 0));
return new BufferedImage(new SixteenBitColorModel(), raster, false, EMPTY_HASH);
}
}
代码示例来源:origin: org.apache.xmlgraphics/batik-bridge
/**
* Implementation helper: converts a RenderedImage to an Image
*/
protected Image renderedImageToImage(RenderedImage ri) {
int x = ri.getMinX();
int y = ri.getMinY();
SampleModel sm = ri.getSampleModel();
ColorModel cm = ri.getColorModel();
WritableRaster wr = Raster.createWritableRaster(sm, new Point(x,y));
ri.copyData(wr);
return new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
}
代码示例来源:origin: net.imglib2/imglib2
private BufferedImage createBufferedImage( final T type, final A data, final int width, final int height )
{
final DataBuffer buffer = createDataBuffer( data );
final SampleModel model = new PixelInterleavedSampleModel( buffer.getDataType(), width, height, 1, width, new int[] { 0 } );
final ColorModel colorModel = createColorModel( type, buffer );
final WritableRaster raster = Raster.createWritableRaster( model, buffer, null );
return new BufferedImage( colorModel, raster, false, null );
}
内容来源于网络,如有侵权,请联系作者删除!