コード例 #1
0
  public void testTileStackImage() throws Exception {
    final SunTileCache tileCache = (SunTileCache) JAI.getDefaultInstance().getTileCache();
    tileCache.flush();
    long cacheTileCount = tileCache.getCacheTileCount();
    assertEquals(0, cacheTileCount);

    Operator operator =
        new Operator() {
          @Override
          public void initialize() throws OperatorException {
            Product product = new Product("name", "desc", 1, 1);

            RenderedOp d =
                ConstantDescriptor.create(
                    (float) product.getSceneRasterWidth(),
                    (float) product.getSceneRasterHeight(),
                    new Float[] {0.5f},
                    null);

            product.addBand("a", ProductData.TYPE_INT32);
            product.addBand("b", ProductData.TYPE_INT32);
            product.addBand("c", ProductData.TYPE_INT32);
            product.addBand("d", ProductData.TYPE_FLOAT32).setSourceImage(d);
            setTargetProduct(product);
          }

          @Override
          public void computeTileStack(
              Map<Band, Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm)
              throws OperatorException {
            assertEquals(3, targetTiles.size());

            for (Tile tt : targetTiles.values()) {
              ProductData dataBuffer = tt.getDataBuffer();
              int numElems = dataBuffer.getNumElems();
              for (int i = 0; i < numElems; i++) {
                dataBuffer.setElemIntAt(i, i);
              }
            }

            assertEquals(0, tileCache.getCacheTileCount());
          }
        };

    Product targetProduct = operator.getTargetProduct();
    assertNotNull(targetProduct);
    assertEquals(4, targetProduct.getNumBands());

    MultiLevelImage sourceImage = targetProduct.getBandAt(0).getSourceImage();
    RenderedImage image = sourceImage.getImage(0);
    assertNotNull(image);
    assertEquals(OperatorImageTileStack.class, image.getClass());
    // pull data to trigger computation
    image.getData();

    cacheTileCount = tileCache.getCacheTileCount();
    assertEquals(3, cacheTileCount);
  }
コード例 #2
0
ファイル: ImageUtilities.java プロジェクト: nacerix/xmind
 public static BufferedImage createBufferedImage(
     RenderedImage image, ImageObserver observer, Color bkg) {
   if (image instanceof BufferedImage) return (BufferedImage) image;
   throw new IllegalArgumentException("not supperted " + image.getClass()); // $NON-NLS-1$
 }