本文整理汇总了Java中java.awt.image.DataBufferDouble类的典型用法代码示例。如果您正苦于以下问题:Java DataBufferDouble类的具体用法?Java DataBufferDouble怎么用?Java DataBufferDouble使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataBufferDouble类属于java.awt.image包,在下文中一共展示了DataBufferDouble类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBuffer
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
/**
* Create a data buffer of a particular type.
*
* @param dataType the desired data type of the buffer.
* @param size the size of the data buffer bank
* @param numBanks the number of banks the buffer should have
*/
public static DataBuffer createBuffer(int dataType, int size, int numBanks)
{
switch (dataType)
{
case DataBuffer.TYPE_BYTE:
return new DataBufferByte(size, numBanks);
case DataBuffer.TYPE_SHORT:
return new DataBufferShort(size, numBanks);
case DataBuffer.TYPE_USHORT:
return new DataBufferUShort(size, numBanks);
case DataBuffer.TYPE_INT:
return new DataBufferInt(size, numBanks);
case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat(size, numBanks);
case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble(size, numBanks);
default:
throw new UnsupportedOperationException();
}
}
示例2: createBufferFromData
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
/**
* Create a data buffer of a particular type.
*
* @param dataType the desired data type of the buffer
* @param data an array containing the data
* @param size the size of the data buffer bank
*/
public static DataBuffer createBufferFromData(int dataType, Object data,
int size)
{
switch (dataType)
{
case DataBuffer.TYPE_BYTE:
return new DataBufferByte((byte[]) data, size);
case DataBuffer.TYPE_SHORT:
return new DataBufferShort((short[]) data, size);
case DataBuffer.TYPE_USHORT:
return new DataBufferUShort((short[]) data, size);
case DataBuffer.TYPE_INT:
return new DataBufferInt((int[]) data, size);
case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat((float[]) data, size);
case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble((double[]) data, size);
default:
throw new UnsupportedOperationException();
}
}
示例3: createBuffer
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
/**
* Create a data buffer of a particular type.
*
* @param dataType the desired data type of the buffer.
* @param size the size of the data buffer bank
* @param numBanks the number of banks the buffer should have
*/
public static DataBuffer createBuffer(int dataType, int size, int numBanks)
{
switch (dataType)
{
case DataBuffer.TYPE_BYTE:
return new DataBufferByte(size, numBanks);
case DataBuffer.TYPE_SHORT:
return new DataBufferShort(size, numBanks);
case DataBuffer.TYPE_USHORT:
return new DataBufferUShort(size, numBanks);
case DataBuffer.TYPE_INT:
return new DataBufferInt(size, numBanks);
case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat(size, numBanks);
case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble(size, numBanks);
default:
throw new UnsupportedOperationException();
}
}
示例4: createBufferFromData
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
/**
* Create a data buffer of a particular type.
*
* @param dataType the desired data type of the buffer
* @param data an array containing the data
* @param size the size of the data buffer bank
*/
public static DataBuffer createBufferFromData(int dataType, Object data,
int size)
{
switch (dataType)
{
case DataBuffer.TYPE_BYTE:
return new DataBufferByte((byte[]) data, size);
case DataBuffer.TYPE_SHORT:
return new DataBufferShort((short[]) data, size);
case DataBuffer.TYPE_USHORT:
return new DataBufferUShort((short[]) data, size);
case DataBuffer.TYPE_INT:
return new DataBufferInt((int[]) data, size);
case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat((float[]) data, size);
case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble((double[]) data, size);
default:
throw new UnsupportedOperationException();
}
}
示例5: getData
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
public static Object getData(final DataBuffer db) {
if (db instanceof DataBufferByte) {
return ((DataBufferByte) db).getData();
} else if (db instanceof DataBufferUShort) {
return ((DataBufferUShort) db).getData();
} else if (db instanceof DataBufferShort) {
return ((DataBufferShort) db).getData();
} else if (db instanceof DataBufferInt) {
return ((DataBufferInt) db).getData();
} else if (db instanceof DataBufferFloat) {
return ((DataBufferFloat) db).getData();
} else if (db instanceof DataBufferDouble) {
return ((DataBufferDouble) db).getData();
} else {
throw new RuntimeException("Not found DataBuffer class !");
}
}
示例6: reportInternal
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
public Object reportInternal (Argument args[], Context context)
throws ExtensionException, LogoException {
_reference patchVar = (_reference)((org.nlogo.nvm.Argument)args[0]).getReporter();
World world = context.getAgent().world();
int width = world.worldWidth();
int height = world.worldHeight();
Envelope envelope = GISExtension.getState().getTransformation().getEnvelope(world);
GridDimensions dimensions = new GridDimensions(new Dimension(width, height), envelope);
DataBuffer data = new DataBufferDouble(width * height);
BandedSampleModel sampleModel = new BandedSampleModel(data.getDataType(),width, height, 1);
WritableRaster raster = Raster.createWritableRaster(sampleModel, data, null);
for (int px = world.minPxcor(), ix = 0; px <= world.maxPxcor(); px += 1, ix += 1) {
for (int py = world.minPycor(), iy = raster.getHeight() - 1; py <= world.maxPycor(); py += 1, iy -= 1) {
Patch p = world.fastGetPatchAt(px, py);
Object value = p.getVariable(patchVar.reference.vn());
if (value instanceof Number) {
raster.setSample(ix, iy, 0, ((Number)value).doubleValue());
} else {
raster.setSample(ix, iy, 0, Double.NaN);
}
}
}
return new RasterDataset(dimensions, raster);
}
示例7: getData
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
@Override
public Object getData(DataBuffer db) {
if (db instanceof DataBufferByte){
return ((DataBufferByte)db).getData();
} else if (db instanceof DataBufferUShort){
return ((DataBufferUShort)db).getData();
} else if (db instanceof DataBufferShort){
return ((DataBufferShort)db).getData();
} else if (db instanceof DataBufferInt){
return ((DataBufferInt)db).getData();
} else if (db instanceof DataBufferFloat){
return ((DataBufferFloat)db).getData();
} else if (db instanceof DataBufferDouble){
return ((DataBufferDouble)db).getData();
} else {
// awt.235=Wrong Data Buffer type : {0}
throw new IllegalArgumentException(Messages.getString("awt.235", //$NON-NLS-1$
db.getClass()));
}
}
示例8: setUp
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
double dataArrays[][] = new double[numBanks][];
for(int i = 0; i < numBanks; i++){
dataArrays[i] = new double[arraySize];
}
double dataArray[] = new double[arraySize];
int offsets[] = new int[numBanks];
for(int i = 0; i < numBanks; i++){
offsets[i] = i;
}
db1 = new DataBufferDouble(dataArrays, size);
db2 = new DataBufferDouble(dataArrays, size, offsets);
db3 = new DataBufferDouble(dataArray, size);
db4 = new DataBufferDouble(dataArray, size, numBanks);
db5 = new DataBufferDouble(size);
db6 = new DataBufferDouble(size, numBanks);
}
示例9: getDoubles
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
/** Extracts pixel data as arrays of doubles, one per channel. */
public static double[][] getDoubles(final WritableRaster r, final int x,
final int y, final int w, final int h)
{
if (canUseBankDataDirectly(r, DataBuffer.TYPE_DOUBLE,
DataBufferDouble.class) &&
x == 0 && y == 0 && w == r.getWidth() && h == r.getHeight())
{
return ((DataBufferDouble) r.getDataBuffer()).getBankData();
}
// NB: an order of magnitude faster than the naive makeType solution
final int c = r.getNumBands();
final double[][] samples = new double[c][w * h];
for (int i = 0; i < c; i++)
r.getSamples(x, y, w, h, i, samples[i]);
return samples;
}
示例10: clone
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
public static DataBuffer clone(DataBuffer dataBuffer) {
if (dataBuffer instanceof DataBufferByte) {
return clone((DataBufferByte) dataBuffer);
} else if (dataBuffer instanceof DataBufferDouble) {
return clone((DataBufferDouble) dataBuffer);
} else if (dataBuffer instanceof DataBufferFloat) {
return clone((DataBufferFloat) dataBuffer);
} else if (dataBuffer instanceof DataBufferInt) {
return clone((DataBufferInt) dataBuffer);
} else if (dataBuffer instanceof DataBufferShort) {
return clone((DataBufferShort) dataBuffer);
} else if (dataBuffer instanceof DataBufferUShort) {
return clone((DataBufferUShort) dataBuffer);
} else {
throw new UnsupportedOperationException("Don't know how to clone " + dataBuffer.getClass().getName());
}
}
示例11: getRemoteBufferedImage
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
@Override
public BufferedImage getRemoteBufferedImage(){
SampleModel samplemodel = new BandedSampleModel(DataBuffer.TYPE_DOUBLE, getWidth(), getHeight(), hasAlpha() ? 4:3);
DataBufferDouble databuffer = new DataBufferDouble(getData(), numValues());
WritableRaster raster = Raster.createWritableRaster(samplemodel, databuffer, null);
ColorModel colormodel = new ComponentColorModel(
ColorSpace.getInstance(ColorSpace.CS_sRGB),
hasAlpha(),
false,
hasAlpha() ? ComponentColorModel.TRANSLUCENT:ComponentColorModel.OPAQUE,
DataBuffer.TYPE_DOUBLE
);
BufferedImage bimg = new BufferedImage(colormodel, raster, false, null);
return bimg;
}
示例12: reportInternal
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
public Object reportInternal (Argument args[], Context context)
throws ExtensionException, LogoException, ParseException {
int width = args[0].getIntValue();
int height = args[1].getIntValue();
Envelope envelope = EnvelopeLogoListFormat.getInstance().parse(args[2].getList());
GridDimensions dimensions = new GridDimensions(new Dimension(width, height), envelope);
DataBuffer data = new DataBufferDouble(width * height);
BandedSampleModel sampleModel = new BandedSampleModel(data.getDataType(),width, height, 1);
WritableRaster raster = Raster.createWritableRaster(sampleModel, data, null);
return new RasterDataset(dimensions, raster);
}
示例13: getDataDouble
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
@Override
public double[] getDataDouble(DataBuffer db) {
if (db instanceof DataBufferDouble){
return ((DataBufferDouble)db).getData();
}
return null;
}
示例14: setupLazyCustomConversion
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
private void setupLazyCustomConversion(final BufferedImage image) {
imageForLazyCustomConversion = image;
final boolean hasAlpha = image.getColorModel().hasAlpha();
int pixelFormat = pixelAttributes.format;
int pixelType = pixelAttributes.type;
if (pixelFormat == 0) {
pixelFormat = hasAlpha ? GL.GL_RGBA : GL.GL_RGB;
}
alignment = 1; // FIXME: do we need better?
rowLength = width; // FIXME: correct in all cases?
// Allow previously-selected pixelType (if any) to override that
// we can infer from the DataBuffer
final DataBuffer data = image.getRaster().getDataBuffer();
if (data instanceof DataBufferByte || isPackedInt(image)) {
// Don't use GL_UNSIGNED_INT for BufferedImage packed int images
if (pixelType == 0) pixelType = GL.GL_UNSIGNED_BYTE;
} else if (data instanceof DataBufferDouble) {
throw new RuntimeException("DataBufferDouble rasters not supported by OpenGL");
} else if (data instanceof DataBufferFloat) {
if (pixelType == 0) pixelType = GL.GL_FLOAT;
} else if (data instanceof DataBufferInt) {
// FIXME: should we support signed ints?
if (pixelType == 0) pixelType = GL.GL_UNSIGNED_INT;
} else if (data instanceof DataBufferShort) {
if (pixelType == 0) pixelType = GL.GL_SHORT;
} else if (data instanceof DataBufferUShort) {
if (pixelType == 0) pixelType = GL.GL_UNSIGNED_SHORT;
} else {
throw new RuntimeException("Unexpected DataBuffer type?");
}
pixelAttributes = new GLPixelAttributes(pixelFormat, pixelType);
}
示例15: wrapImageDataBuffer
import java.awt.image.DataBufferDouble; //导入依赖的package包/类
private Buffer wrapImageDataBuffer(final BufferedImage image) {
//
// Note: Grabbing the DataBuffer will defeat Java2D's image
// management mechanism (as of JDK 5/6, at least). This shouldn't
// be a problem for most JOGL apps, but those that try to upload
// the image into an OpenGL texture and then use the same image in
// Java2D rendering might find the 2D rendering is not as fast as
// it could be.
//
final DataBuffer data = image.getRaster().getDataBuffer();
if (data instanceof DataBufferByte) {
return ByteBuffer.wrap(((DataBufferByte) data).getData());
} else if (data instanceof DataBufferDouble) {
throw new RuntimeException("DataBufferDouble rasters not supported by OpenGL");
} else if (data instanceof DataBufferFloat) {
return FloatBuffer.wrap(((DataBufferFloat) data).getData());
} else if (data instanceof DataBufferInt) {
return IntBuffer.wrap(((DataBufferInt) data).getData());
} else if (data instanceof DataBufferShort) {
return ShortBuffer.wrap(((DataBufferShort) data).getData());
} else if (data instanceof DataBufferUShort) {
return ShortBuffer.wrap(((DataBufferUShort) data).getData());
} else {
throw new RuntimeException("Unexpected DataBuffer type?");
}
}