Examples of WritableRaster


Examples of java.awt.image.WritableRaster

    final int        imgW      = tmpBufSize2; //  << info.shift;
    final int        maxLen      = imgW << info.shift; // * stepSize;

//    final int        imgW      = view.getWidth(); // (int) info.sublength;
    final BufferedImage    bufImg      = new BufferedImage( imgW, modelChannels, BufferedImage.TYPE_INT_RGB );
    final WritableRaster  raster      = bufImg.getRaster();
    final int[]        data      = new int[ imgW * modelChannels ];
    final int        dataStartOff  = imgW * (modelChannels - 1);

//    final AffineTransform  atOrig      = g2.getTransform();
    final Shape        clipOrig    = g2.getClip();
   
//    float[]          chanBuf;
    long          start      = info.span.start;
    long          totalLength    = info.getTotalLength();
    Span          chunkSpan;
    long          fullLen;
//    long          fullStop;
    int            chunkLen; // decimLen;
    float          scaleX, ampLog;
    Rectangle        r;
   
//    final float        scaleX      = (float) (view.getWidth() * stepSize) / totalLength;
   
//final float pixScale = 1072 / (view.getAmpLogMax() - view.getAmpLogMin());
//final float pixOff   = -view.getAmpLogMin();
final float pixScale = 10720 / (view.getAmpLogMax() - view.getAmpLogMin());
final float pixOff   = -view.getAmpLogMin() / 10;

    g2.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR );
   
    try {
      drawBusyList.clear(); // "must be called in the event thread"

      synchronized( bufSync ) {
        createBuffers();

long screenOffX = 0;
        while( totalLength > 0 ) {
          fullLen    = Math.min( maxLen, totalLength );
//          chunkLen  = (int) (fromPCM ? fullLen : decimHelps[ info.idx ].fullrateToSubsample( fullLen ));
          chunkLen  = (int) (decimHelps[ info.idx ].fullrateToSubsample( fullLen ));
//          decimLen  = chunkLen / info.inlineDecim;
//          chunkLen  = decimLen * info.inlineDecim;
          fullLen    = (long) chunkLen << info.shift;
//          chunkLen  = (int) (fullLen / stepSize);

//          if( fromPCM ) {
//            fullStop = fullScale.getSpan().stop;
//            if( start + fullLen <= fullStop ) {
//              chunkSpan = new Span( start, start + fullLen );
//              fullScale.readFrames( tmpBuf, 0, chunkSpan );
//            } else {
//              chunkSpan = new Span( start, fullStop );
//              fullScale.readFrames( tmpBuf, 0, chunkSpan );
//              // duplicate last frames
////              for( int i = (int) chunkSpan.getLength(), j = i - 1; i < (int) fullLen; i++ ) {
////                for( int ch = 0; ch < fullChannels; ch++ ) {
////                  sPeakP    = tmpBuf[ ch ];
////                  sPeakP[ i ]  = sPeakP[ j ];
////                }
////              }
//            }
//            decimator.decimatePCM( tmpBuf, tmpBuf2, fftBuf, 0, decimLen, info.inlineDecim );
//          } else {
////            chunkSpan = new Span( start, start + fullLen );
//            chunkSpan = new Span( start, start + fullLen );
//            readFrames( info.idx, tmpBuf2, 0, drawBusyList, chunkSpan, null);
//            if( info.inlineDecim > 1 ) decimator.decimate( tmpBuf2, tmpBuf2, 0, decimLen, info.inlineDecim );
//          }

          chunkSpan = new Span( start, start + fullLen );
         
//System.out.println( "chunkSpan = " + chunkSpan + "; chunkLen = " + chunkLen + "; fullLen = " + fullLen + "; screenOffX " + screenOffX + "; subLength " + info.sublength + "; shift " + info.shift + "; totalLen " + info.getTotalLength() );
         
          if( readFrames( info.idx, tmpBuf2, 0, drawBusyList, chunkSpan, null )) {
//          if( tempFAsync == null || tempFAsync[0] == null ) break;
//          tempFAsync[0].seekFrame( Math.min( start / stepSize, tempFAsync[0].getFrameNum() ));
//          int gaga = (int) Math.min( fullLen, Math.min( tmpBufSize2, tempFAsync[0].getFrameNum() - tempFAsync[0].getFramePosition() ));
//          tempFAsync[0].readFrames( tmpBuf2, 0, gaga);
         
            for( int ch = 0, tmpChReset = 0; ch < fullChannels; ch++, tmpChReset += modelChannels ) {
              r = view.rectForChannel( ch );
              scaleX = (float) r.width / info.getTotalLength();
  //System.out.println( " ... for ch = " + ch + "; scaleX = " + scaleX );
              for( int x = 0, off = 0; x < chunkLen; x++ ) {
                for( int y = 0, off2 = x + dataStartOff, tmpCh = tmpChReset; y < modelChannels; y++, tmpCh++, off2 -= imgW, off++ ) {
  //                ampLog = log10.calc( tmpBuf2[ tmpCh ][ x ]) * 20;
                  ampLog = log10.calc( Math.max( 1.0e-9f, tmpBuf2[ tmpCh ][ x ]));
                  data[ off2 ] = colors[ Math.max( 0, Math.min( 1072, (int) ((ampLog + pixOff) * pixScale) ))];
                }
              }
              raster.setDataElements( 0, 0, imgW, modelChannels, data );
              g2.drawImage( bufImg, r.x + (int) (screenOffX * scaleX + 0.5f), r.y, r.x + (int) ((screenOffX + fullLen) * scaleX + 0.5f), r.y + r.height, 0, 0, chunkLen, modelChannels, view );
            }
          }
          start += fullLen; // chunkLen * stepSize;
          totalLength -= fullLen; // chunkLen * stepSize;
 
View Full Code Here

Examples of java.awt.image.WritableRaster

    public void copyDataToRaster() {
        if (isDataCopy()) {

            // Writeback should only be necessary on destRasters which
            // should be writable so this cast should succeed.
            WritableRaster wr = (WritableRaster)raster;
            switch (getDataType()) {
            case DataBuffer.TYPE_BYTE:
                // Note: ALL branches of this case have been tested.
                // (bpb 10 May 2000)
                if(!isBinary()) {
                    // If this exception occurs then there is a logic
                    // error within this accessor since the only case
                    // wherein byte data should be COPIED is when the
                    // data set is binary.
                    throw new RuntimeException(JaiI18N.getString("RasterAccessor1"));
                }

                // This case only occurs for binary src and dst.

                ImageUtil.setUnpackedBinaryData(byteDataArrays[0],
                                                wr,
                                                new Rectangle(rectX, rectY,
                                                              rectWidth,
                                                              rectHeight));
                break;
            case DataBuffer.TYPE_INT:
                wr.setPixels(rectX,rectY,
                             rectWidth,rectHeight,
                             intDataArrays[0]);
                break;

            case DataBuffer.TYPE_FLOAT:
                wr.setPixels(rectX,rectY,
                             rectWidth,rectHeight,
                             floatDataArrays[0]);
                break;

            case DataBuffer.TYPE_DOUBLE:
                wr.setPixels(rectX,rectY,
                             rectWidth,rectHeight,
                             doubleDataArrays[0]);
                break;
            }
        }
View Full Code Here

Examples of java.awt.image.WritableRaster

    }

    public Raster computeTile(int tileX, int tileY) {
        // Create a new WritableRaster.
        Point org = new Point(tileXToX(tileX), tileYToY(tileY));
        WritableRaster dest = createWritableRaster(sampleModel, org);

        // Output bounds are initially equal to the tile bounds.
        int destMinX = dest.getMinX();
        int destMinY = dest.getMinY();
        int destMaxX = destMinX + dest.getWidth();
        int destMaxY = destMinY + dest.getHeight();

        // Clip output bounds to the dest image bounds.
        Rectangle bounds = getBounds();
        if (destMinX < bounds.x) {
            destMinX = bounds.x;
View Full Code Here

Examples of java.awt.image.WritableRaster

    public Raster computeTile(int tileX, int tileY) {
        //
        // Create a new WritableRaster to represent this tile.
        //
        Point org = new Point(tileXToX(tileX), tileYToY(tileY));
        WritableRaster dest = createWritableRaster(sampleModel, org);

        //
        // Clip output rectangle to image bounds.
        //
        Rectangle rect = new Rectangle(org.x,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.