Package java.awt.image

Examples of java.awt.image.DataBuffer


    /**
     * Recycle the given tile.
     */
    public void recycleTile(Raster tile) {
        DataBuffer db = tile.getDataBuffer();

        Long key = new Long(((long)db.getDataType() << 56) |
                            ((long)db.getNumBanks() << 32) |
                            (long)db.getSize());

        if(DEBUG) {
            System.out.println("Recycling array for: "+
                               db.getDataType()+" "+
                               db.getNumBanks()+" "+
                               db.getSize());
            //System.out.println("recycleTile(); key = "+key);
        }

        synchronized(recycledArrays) {
            Object value = recycledArrays.get(key);
            ArrayList arrays = null;
            if(value != null) {
                arrays = (ArrayList)value;
            } else {
                arrays = new ArrayList();
            }

            memoryUsed += getDataBankSize(db.getDataType(),
                                          db.getNumBanks(),
                                          db.getSize());

            arrays.add(getBankReference(db));

            if(value == null) {
                recycledArrays.put(key, arrays);
View Full Code Here


            break;
        default:
            throw new IllegalArgumentException("dataType == "+dataType+"!");
        }

        DataBuffer dataBuffer = null;
        try {
            Constructor constructor = dbClass.getConstructor(paramTypes);
            dataBuffer = (DataBuffer)constructor.newInstance(paramValues);
        } catch(Exception e) {
            throw new RuntimeException(JaiI18N.getString("DataBufferUtils1"));
View Full Code Here

        this.tileCacheMetric = tileCacheMetric;  // may be null

        key = hashKey(owner, tileX, tileY);

        // tileMemorySize(Raster tile) inlined for performance
        DataBuffer db = tile.getDataBuffer();
        memorySize = db.getDataTypeSize(db.getDataType()) / 8L *
                     db.getSize() * db.getNumBanks();

    }
View Full Code Here

        if(location == null) {
           location = new Point(0,0);
        }

        DataBuffer db = null;

        int type = sampleModel.getTransferType();
        long numBanks = 0;
        long size = 0;
View Full Code Here

    /**
     * Recycle the given tile.
     */
    public void recycleTile(Raster tile) {
        DataBuffer db = tile.getDataBuffer();

        Long key = new Long(((long)db.getDataType() << 56) |
                            ((long)db.getNumBanks() << 32) |
                            (long)db.getSize());

        if(DEBUG) {
            System.out.println("Recycling array for: "+
                               db.getDataType()+" "+
                               db.getNumBanks()+" "+
                               db.getSize());
            //System.out.println("recycleTile(); key = "+key);
        }

        synchronized(recycledArrays) {
            Object value = recycledArrays.get(key);
            ArrayList arrays = null;
            if(value != null) {
                arrays = (ArrayList)value;
            } else {
                arrays = new ArrayList();
            }

            memoryUsed += getDataBankSize(db.getDataType(),
                                          db.getNumBanks(),
                                          db.getSize());

            arrays.add(getBankReference(db));

            if(value == null) {
                recycledArrays.put(key, arrays);
View Full Code Here

  // Get the data array out of the DataBuffer
  byte bdata[] = null;
  short sdata[] = null;
  int idata[] = null;
  float fdata[] = null;
  DataBuffer buffer = sampleModel.createDataBuffer();

  int dataType = sampleModel.getDataType();
  if (dataType == DataBuffer.TYPE_BYTE) {
      bdata = ((DataBufferByte)buffer).getData();
  } else if (dataType == DataBuffer.TYPE_USHORT) {
      sdata = ((DataBufferUShort)buffer).getData();
  } else if (dataType == DataBuffer.TYPE_SHORT) {
      sdata = ((DataBufferShort)buffer).getData();
  } else if (dataType == DataBuffer.TYPE_INT) {
      idata = ((DataBufferInt)buffer).getData();
  } else if (dataType == DataBuffer.TYPE_FLOAT) {
            if(buffer instanceof DataBufferFloat) {
                fdata = ((DataBufferFloat)buffer).getData();
            } else {
                // This is a hack to make this work with JAI which in some
                // cases downcasts the DataBuffer to a type-specific class.
                // In the case of float data this current means the JAI class
                // com.lightcrafts.mediax.jai.DataBufferFloat.
                try {
                    Method getDataMethod =
                        buffer.getClass().getMethod("getData", null);
                    fdata = (float[])getDataMethod.invoke(buffer, null);
                } catch(Exception e) {
                    String message = JaiI18N.getString("TIFFImage18");
                    ImagingListenerProxy.errorOccurred(message,
                                           new ImagingException(message, e),
View Full Code Here

    @Override
    public void append(BufferedImage img, int lines) throws IOException {

      /* get raw data of image */
      DataBuffer imageDataBuffer = img.getRaster().getDataBuffer();
      int[] data = (((DataBufferInt)imageDataBuffer).getData());
     
      /* create one ImageLine that will be refilled and written to png */
      ImageLineByte bline = new ImageLineByte(imgInfo);
      byte[] line = bline.getScanline();
View Full Code Here

      // collect and write content

      ByteBuffer writeBuffer = ByteBuffer.allocate(
          3 * img.getWidth() * lines);
     
      DataBuffer imageDataBuffer = img.getRaster().getDataBuffer();
      int[] data = (((DataBufferInt)imageDataBuffer).getData());
     
      for (int i = 0; i < img.getWidth() * lines; i++) {
        int value = data[i];
        writeBuffer.put((byte)(value >>> 16));
View Full Code Here

                    intDataArrays[i] = dbi.getData(bankIndices[i]);
                }
                break;

            case DataBuffer.TYPE_FLOAT:
                DataBuffer dbf = (DataBuffer)raster.getDataBuffer();
                floatDataArrays = new float[numBands][];
                for (int i = 0; i < numBands; i++) {
                    floatDataArrays[i] =
                        DataBufferUtils.getDataFloat(dbf, bankIndices[i]);
                }
                break;

            case DataBuffer.TYPE_DOUBLE:
                DataBuffer dbd = (DataBuffer)raster.getDataBuffer();
                doubleDataArrays = new double[numBands][];
                for (int i = 0; i < numBands; i++) {
                    doubleDataArrays[i] =
                        DataBufferUtils.getDataDouble(dbd, bankIndices[i]);
                }
View Full Code Here

            theObject = null;
            return;
        }

        // Restore the DataBuffer from its serialized form.
        DataBuffer dataBuffer = (DataBuffer)dataBufferState.getObject();

        // Reconstruct the Raster.
        theObject = Raster.createRaster(sampleModel, dataBuffer, location);
    }
View Full Code Here

TOP

Related Classes of java.awt.image.DataBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.