Java 类java.awt.image.DataBufferDouble 实例源码

项目:OpenJSharp    文件:Buffers.java   
/**
  * 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();
     }
 }
项目:OpenJSharp    文件:Buffers.java   
/**
  * 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();
     }
 }
项目:javify    文件:Buffers.java   
/**
 * 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();
    }
}
项目:javify    文件:Buffers.java   
/**
 * 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();
    }
}
项目:jvm-stm    文件:Buffers.java   
/**
  * 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();
     }
 }
项目:jvm-stm    文件:Buffers.java   
/**
  * 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();
     }
 }
项目:RipplePower    文件:GraphicsUtils.java   
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 !");
    }
}
项目:modelingcommons    文件:PatchDataset.java   
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);
}
项目:cn1    文件:AwtImageBackdoorAccessorImpl.java   
@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()));
    }
}
项目:cn1    文件:DataBufferDoubleTest.java   
@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);
}
项目:JamVM-PH    文件:Buffers.java   
/**
  * 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();
     }
 }
项目:JamVM-PH    文件:Buffers.java   
/**
  * 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();
     }
 }
项目:classpath    文件:Buffers.java   
/**
 * 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();
    }
}
项目:classpath    文件:Buffers.java   
/**
 * 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();
    }
}
项目:freeVM    文件:AwtImageBackdoorAccessorImpl.java   
@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()));
    }
}
项目:freeVM    文件:DataBufferDoubleTest.java   
@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);
}
项目:freeVM    文件:AwtImageBackdoorAccessorImpl.java   
@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()));
    }
}
项目:freeVM    文件:DataBufferDoubleTest.java   
@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);
}
项目:scifio    文件:AWTImageTools.java   
/** 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;
}
项目:WorldPainter    文件:ObjectUtils.java   
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());
    }
}
项目:ImagingKit    文件:ColorImg.java   
@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;
}
项目:modelingcommons    文件:RasterDataset.java   
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);
}
项目:cn1    文件:AwtImageBackdoorAccessorImpl.java   
@Override
public double[] getDataDouble(DataBuffer db) {
    if (db instanceof DataBufferDouble){
        return ((DataBufferDouble)db).getData();
    }
    return null;
}
项目:breakout    文件:AWTTextureData.java   
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);
}
项目:breakout    文件:AWTTextureData.java   
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?");
    }
}
项目:freeVM    文件:AwtImageBackdoorAccessorImpl.java   
@Override
public double[] getDataDouble(DataBuffer db) {
    if (db instanceof DataBufferDouble){
        return ((DataBufferDouble)db).getData();
    }
    return null;
}
项目:freeVM    文件:AwtImageBackdoorAccessorImpl.java   
@Override
public double[] getDataDouble(DataBuffer db) {
    if (db instanceof DataBufferDouble){
        return ((DataBufferDouble)db).getData();
    }
    return null;
}
项目:geoxygene    文件:RasterImage.java   
/**
 * read a raster Image
 * 
 * @param image
 * @param symbolizer
 */
public void readImage(GridCoverage2D image, RasterSymbolizer symbolizer) {
    System.out.println("READING THE RASTER");
    // To avoid multiple read
    if ((isRead == false) || (symbolizer.getChannelSelection() != null)) // &&(imageFilename
                                                                         // !=
                                                                         // null))
    {
        // Declaration and initialization
        // Set width, height, nbBands and compute size
        width = image.getRenderedImage().getWidth();
        height = image.getRenderedImage().getHeight();
        nbBands = image.getNumSampleDimensions();
        // size of the input image !!
        size = width * height * nbBands;
        // Determine data type of image
        imageDataType = image.getSampleDimension(0).getSampleDimensionType().name();

        // Channel Selection
        // TODO : VALIDATION of channel selection from symbolizer
        selectBands(image, symbolizer);

        // Determine the format
        format = generateFormatFromNbBandSelected();

        // Determine the data type
        GLinternalDataType = generateGLinternalDataTypeFromImageDataType();

        // Automatically detect the best GLinternalFormat
        GLinternalFormat = generateOptimalGLinternalFormat();

        // Buffer allocation and acquisition
        // INFO : bufferImage.order(ByteOrder.nativeOrder()); // to adjust
        // the ByteBuffer instance's endianness to match the current
        // platform.
        if ((GLinternalDataType == GL11.GL_BYTE) || (GLinternalDataType == GL11.GL_UNSIGNED_BYTE)) {
            byte[] byteData = ((DataBufferByte) image.getRenderedImage().getData().getDataBuffer()).getData();
            bufferImage = ByteBuffer.allocateDirect(byteData.length);
            bufferImage.order(ByteOrder.nativeOrder());
            bufferImage.put(ByteBuffer.wrap(byteData));
        } else if ((GLinternalDataType == GL11.GL_SHORT) || (GLinternalDataType == GL11.GL_UNSIGNED_SHORT)) {
            short[] shortData = ((DataBufferShort) image.getRenderedImage().getData().getDataBuffer()).getData();
            bufferImage = ByteBuffer.allocateDirect(shortData.length * 2);
            bufferImage.order(ByteOrder.nativeOrder());
            bufferImage.asShortBuffer().put(ShortBuffer.wrap(shortData));
        } else if ((GLinternalDataType == GL11.GL_INT) || (GLinternalDataType == GL11.GL_UNSIGNED_INT)) {
            int[] intData = ((DataBufferInt) image.getRenderedImage().getData().getDataBuffer()).getData();
            bufferImage = ByteBuffer.allocateDirect(intData.length * 4);
            bufferImage.order(ByteOrder.nativeOrder());
            bufferImage.asIntBuffer().put(IntBuffer.wrap(intData));
        } else if (GLinternalDataType == GL11.GL_FLOAT) {
            float[] floatData = ((DataBufferFloat) image.getRenderedImage().getData().getDataBuffer()).getData();
            bufferImage = ByteBuffer.allocateDirect(floatData.length * 4);
            bufferImage.order(ByteOrder.nativeOrder());
            bufferImage.asFloatBuffer().put(FloatBuffer.wrap(floatData));
        } else if (GLinternalDataType == GL11.GL_DOUBLE) {
            double[] doubleData = ((DataBufferDouble) image.getRenderedImage().getData().getDataBuffer()).getData();
            bufferImage = ByteBuffer.allocateDirect(doubleData.length * 8);
            bufferImage.order(ByteOrder.nativeOrder());
            bufferImage.asDoubleBuffer().put(DoubleBuffer.wrap(doubleData));
        } else {
            System.err.println("This type of data : " + GLinternalDataType + "is not recognized.");
        }

        // Rewind the buffer, not very with our way-to-put but why not
        bufferImage.rewind();

        // Now, bufferImage is ok, reading is complete
        isRead = true;

        // TEMP ?? animation
        animate = symbolizer.getAnimate();
    }
}
项目:RipplePower    文件:GraphicsUtils.java   
public static double[] getDataDouble(final DataBuffer db) {
    return ((DataBufferDouble) db).getData();
}
项目:modelingcommons    文件:ValueColorModel.java   
/** */
public WritableRaster createCompatibleWritableRaster (int w, int h) {
    return Raster.createWritableRaster(createCompatibleSampleModel(w, h), 
                                       new DataBufferDouble(w * h),
                                       null);
}
项目:modelingcommons    文件:AsciiGridFileReader.java   
/** */
public DataBuffer getData () throws IOException {
    int size = _gridSize.width * _gridSize.height;
    DataBufferDouble result = new DataBufferDouble(size);
    int index = 0;
    while (true) {
        String line;
        if (_cachedLine != null) {
            line = _cachedLine;
            _cachedLine = null;
        } else {
            line = _in.readLine();
        }
        if (line == null) {
            break;
        }
        StringTokenizer tokens = new StringTokenizer(line);
        while (tokens.hasMoreTokens()) {
            double value = Double.NaN;
            String token = tokens.nextToken();
            if (token.length() > 0) {
                try {
                    Number n = VALUE_FORMAT.parse(token);
                    if ((n != null) && (n.doubleValue() != _nanValue)) { 
                        value = n.doubleValue();
                    }   
                } catch (ParseException e) {
                    // should we report?
                }
            }
            result.setElemDouble(index++, value);
            if (index >= size) {
                break;
            }
        }
        if (index >= size) {
            break;
        }
    }
    return result;
}
项目:WorldPainter    文件:ObjectUtils.java   
public static DataBufferDouble clone(DataBufferDouble dataBuffer) {
    return new DataBufferDouble(clone(dataBuffer.getBankData()), dataBuffer.getSize(), dataBuffer.getOffsets());
}
项目:scifio    文件:AWTImageTools.java   
/**
 * Creates an image from the given double data.
 *
 * @param data Array containing image data.
 * @param w Width of image plane.
 * @param h Height of image plane.
 * @param c Number of channels.
 * @param interleaved If set, the channels are assumed to be interleaved;
 *          otherwise they are assumed to be sequential. For example, for RGB
 *          data, the pattern "RGBRGBRGB..." is interleaved, while
 *          "RRR...GGG...BBB..." is sequential.
 */
public static BufferedImage makeImage(final double[] data, final int w,
    final int h, final int c, final boolean interleaved)
{
    if (c == 1) return makeImage(data, w, h);
    final int dataType = DataBuffer.TYPE_DOUBLE;
    final DataBuffer buffer = new DataBufferDouble(data, c * w * h);
    return constructImage(c, dataType, w, h, interleaved, false, buffer);
}
项目:scifio    文件:AWTImageTools.java   
/**
 * Creates an image from the given double-precision floating point data.
 *
 * @param data Array containing image data. It is assumed that each channel
 *          corresponds to one element of the array. For example, for RGB
 *          data, data[0] is R, data[1] is G, and data[2] is B.
 * @param w Width of image plane.
 * @param h Height of image plane.
 */
public static BufferedImage makeImage(final double[][] data, final int w,
    final int h)
{
    final int dataType = DataBuffer.TYPE_DOUBLE;
    final DataBuffer buffer = new DataBufferDouble(data, data[0].length);
    return constructImage(data.length, dataType, w, h, false, true, buffer);
}