当前位置: 首页>>代码示例>>Java>>正文


Java RenderedOp类代码示例

本文整理汇总了Java中javax.media.jai.RenderedOp的典型用法代码示例。如果您正苦于以下问题:Java RenderedOp类的具体用法?Java RenderedOp怎么用?Java RenderedOp使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RenderedOp类属于javax.media.jai包,在下文中一共展示了RenderedOp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import javax.media.jai.RenderedOp; //导入依赖的package包/类
public void run() {
    try {

        if (Thread.interrupted()) return;
        if (timeOut.get() > startTime) return;

        //ImageIcon icon = TiffConverter.getImageIcon(fileKey, 0, 0);
        RenderedImage img = imageProvider.getThumbnail(fileKey);
        img = contrastEnhancer.enhanceContrast(img);
        ImageIcon icon = new ImageIcon(RenderedOp.wrapRenderedImage(img).getAsBufferedImage());

        if ((iconHash != null) && (icon != null)) {
            iconHash.put(fileKey, icon);
            //setPreferredSize(new Dimension(getWidth(),icon.getImage().getHeight(list)));
            //list.revalidate();
            list.repaint();
        }
    } catch (Throwable t) {
        //can happen (e.g. outofmemory) but no problem
        //System.out.println("icon error: "+t);
        //t.printStackTrace();
    }
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:24,代码来源:RdfThnCellRendererBig.java

示例2: graphicFillLineString

import javax.media.jai.RenderedOp; //导入依赖的package包/类
private static void graphicFillLineString(final LineSymbolizer symbolizer, final Shape shape, final Image image, final float size, final double opacity) {
    Double width = new Double(Math.max(1, shape.getBounds2D().getWidth()));
    Double height = new Double(Math.max(1, shape.getBounds2D().getHeight()));
    Double shapeHeight = new Double(size);
    double factor = shapeHeight.doubleValue() / image.getHeight(null);
    Double shapeWidth = new Double(image.getWidth(null) * factor);
    AffineTransform transform = AffineTransform.getTranslateInstance(shape.getBounds2D().getMinX(), shape.getBounds2D().getMinY());
    Image scaledImage = image.getScaledInstance(shapeWidth.intValue(), shapeHeight.intValue(), Image.SCALE_FAST);
    BufferedImage buff = new BufferedImage(shapeWidth.intValue(), shapeHeight.intValue(), BufferedImage.TYPE_INT_ARGB);
    buff.getGraphics().drawImage(scaledImage, 0, 0, null);
    ParameterBlock p = new ParameterBlock();
    p.addSource(buff);
    p.add(width.intValue());
    p.add(height.intValue());
    RenderedOp im = JAI.create("pattern", p);//$NON-NLS-1$
    BufferedImage bufferedImage = im.getAsBufferedImage();
    glDrawImage(bufferedImage, transform, null);
    bufferedImage.flush();
    im.dispose();
    scaledImage.flush();
    buff.flush();
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:23,代码来源:RenderGL11Util.java

示例3: drawGraphicFillPolygon

import javax.media.jai.RenderedOp; //导入依赖的package包/类
private static void drawGraphicFillPolygon(Image image, float size, Graphics2D graphics, double opacity, double widthSymbol, double heightSymbol, double offsetYSymbol, double offsetXSymbol) {
    Double shapeHeight = new Double(size);
    double factor = shapeHeight / image.getHeight(null);
    Double shapeWidth = new Double(Math.max(image.getWidth(null) * factor, 1));
    AffineTransform transform = AffineTransform.getTranslateInstance(offsetXSymbol, offsetYSymbol);
    Image scaledImage = image.getScaledInstance(shapeWidth.intValue(), shapeHeight.intValue(), Image.SCALE_FAST);
    BufferedImage buff = new BufferedImage(shapeWidth.intValue(), shapeHeight.intValue(), BufferedImage.TYPE_INT_ARGB);
    buff.getGraphics().drawImage(scaledImage, 0, 0, null);
    ParameterBlock p = new ParameterBlock();
    p.addSource(buff);
    p.add((int) widthSymbol);
    p.add((int) heightSymbol);
    RenderedOp im = JAI.create("pattern", p);//$NON-NLS-1$
    BufferedImage bufferedImage = im.getAsBufferedImage();
    graphics.drawImage(bufferedImage, transform, null);
    bufferedImage.flush();
    im.dispose();
    scaledImage.flush();
    buff.flush();
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:21,代码来源:LayerStylesPanel.java

示例4: computeEdgeDensityClutter

import javax.media.jai.RenderedOp; //导入依赖的package包/类
private double computeEdgeDensityClutter(PlanarImage image) {
  // first compute the RenderedOp that computes both vertical and
  // horizontal
  // edge detection
  KernelJAI sobelVertKernel = KernelJAI.GRADIENT_MASK_SOBEL_VERTICAL;
  KernelJAI sobelHorizKernel = KernelJAI.GRADIENT_MASK_SOBEL_HORIZONTAL;
  ParameterBlock pb = new ParameterBlock();
  pb.addSource(image);
  pb.add(sobelHorizKernel);
  pb.add(sobelVertKernel);
  RenderedOp renderedOp = JAI.create("gradientmagnitude", pb);
  BufferedImage edgeImage = renderedOp.getAsBufferedImage();

  // then compute a density value, i.e. the mean
  int edgeTotal = 0;
  for (int i = 0; i < edgeImage.getWidth(); i++)
    for (int j = 0; j < edgeImage.getHeight(); j++)
      edgeTotal += Math.abs(edgeImage.getRGB(i, j));

  return Math.abs(edgeTotal / (edgeImage.getWidth() * edgeImage.getHeight()));
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:22,代码来源:RasterClutterMethod.java

示例5: run

import javax.media.jai.RenderedOp; //导入依赖的package包/类
public void run() {
    try {

        if (Thread.interrupted()) return;
        if (timeOut.get() > startTime) return;

        //ImageIcon icon = TiffConverter.getImageIcon(fileKey, 0, 0);
        RawDataFile rdf = new RawDataFile();
        rdf.setRawDataFileId(fileKey);
        RenderedImage img = imageProviderOmero.getThumbnail(rdf);
        ImageIcon icon = new ImageIcon(RenderedOp.wrapRenderedImage(img).getAsBufferedImage());

        if ((RdfThnCellRendererOmero.iconHash != null) && (icon != null)) {
            RdfThnCellRendererOmero.iconHash.put(fileKey, icon);
            //setPreferredSize(new Dimension(getWidth(),icon.getImage().getHeight(list)));
            //list.revalidate();
            list.repaint();
        }
    } catch (Throwable t) {
        //can happen (e.g. outofmemory) but no problem
        //System.out.println("icon error: "+t);
        //t.printStackTrace();
    }
}
 
开发者ID:mstritt,项目名称:image-provider-omero,代码行数:25,代码来源:RdfThnCellRendererOmero.java

示例6: colorReduceMedianCut

import javax.media.jai.RenderedOp; //导入依赖的package包/类
public static BufferedImage colorReduceMedianCut(BufferedImage image, int colorCount) {
	int pixelBits = image.getColorModel().getPixelSize();
	if (pixelBits != 24) {
		/*
		 * For preventing the javax.media.jai.util.ImagingException: All
		 * factories fail for the operation "ColorQuantizer" we have to
		 * create a "compatible" (e.g. TYPE_3BYTE_BGR) BufferedImage
		 */
		BufferedImage trueColorImage = new BufferedImage(image.getWidth(), image.getHeight(),
				BufferedImage.TYPE_3BYTE_BGR);
		Graphics g = trueColorImage.getGraphics();
		g.drawImage(image, 0, 0, null);
		g.dispose();
		image = trueColorImage;
	}
	RenderedOp ro = ColorQuantizerDescriptor.create(image, ColorQuantizerDescriptor.MEDIANCUT, // 
			new Integer(colorCount), // Max number of colors
			null, null, new Integer(1), Integer.valueOf(1), null);
	return ro.getAsBufferedImage();
}
 
开发者ID:bh4017,项目名称:mobac,代码行数:21,代码来源:JavaAdvancedImaging.java

示例7: testMosaicUpdate

import javax.media.jai.RenderedOp; //导入依赖的package包/类
@Test
public void testMosaicUpdate() {
    final RenderedOp firstImage = MosaicDescriptor.create(Arrays.copyOf(sourceImages1, 3),
                                                          MosaicDescriptor.MOSAIC_TYPE_OVERLAY,
                                                          Arrays.copyOf(alphaImages, 3), null, null, null, null);
    final PlanarImage[] alphaUpdateImages = {
            PlanarImage.wrapRenderedImage(ConstantDescriptor.create(10.0f, 10.0f, new Float[]{6.0f}, null)),
            PlanarImage.wrapRenderedImage(ConstantDescriptor.create(10.0f, 10.0f, new Float[]{4.0f}, null))
    };
    final RenderedImage[] sourceUpdateImages = {firstImage, sourceImages1[3]};
    final RenderedOp updatedImage = MosaicDescriptor.create(sourceUpdateImages,
                                                            MosaicDescriptor.MOSAIC_TYPE_OVERLAY,
                                                            alphaUpdateImages, null, null, null, null);

    final Raster data = updatedImage.getData();
    float sample = data.getSampleFloat(0, 0, 0);
    assertEquals(2.0f, sample, 0.0f);
    sample = data.getSampleFloat(5, 5, 0);
    assertEquals(2.0f, sample, 0.0f);
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:21,代码来源:S2tbxMosaicOpImageTest.java

示例8: doVectorize

import javax.media.jai.RenderedOp; //导入依赖的package包/类
/**
 * Helper function to run the Vectorize operation with given parameters and
 * retrieve the vectors.
 * 
 * @param src the source image
 * @param args a {@code Map} of parameter names and values
 * 
 * @return the generated vectors as JTS Polygons
 */
@SuppressWarnings("unchecked")
private Collection<Polygon> doVectorize( RenderedImage src, Map<String, Object> args ) {
    ParameterBlockJAI pb = new ParameterBlockJAI("Vectorize");
    pb.setSource("source0", src);

    // Set any parameters that were passed in
    for( Entry<String, Object> e : args.entrySet() ) {
        pb.setParameter(e.getKey(), e.getValue());
    }

    // Get the desintation image: this is the unmodified source image data
    // plus a property for the generated vectors
    RenderedOp dest = JAI.create("Vectorize", pb);

    // Get the vectors
    Object property = dest.getProperty(VectorizeDescriptor.VECTOR_PROPERTY_NAME);
    return (Collection<Polygon>) property;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:28,代码来源:OmsVectorizer.java

示例9: getKey

import javax.media.jai.RenderedOp; //导入依赖的package包/类
/** Derives a hash key for this ParameterBlock. */
private static final Object getKey(ParameterBlock paramBlock) {
    // Initialize the key string.
    String key = new String();

    // Add the hash code of the source to the key.
    key += String.valueOf(paramBlock.getRenderedSource(0).hashCode());

    // Add the RenderedOp parameter to the key.
    key += getKey((RenderedOp)paramBlock.getObjectParameter(0));

    // Add the numerical parameters to the key.
    key += String.valueOf(paramBlock.getIntParameter(1));
    key += String.valueOf(paramBlock.getFloatParameter(2));
    key += String.valueOf(paramBlock.getFloatParameter(3));
    key += String.valueOf(paramBlock.getFloatParameter(4));

    return key;
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:20,代码来源:RenderableCRIF.java

示例10: create

import javax.media.jai.RenderedOp; //导入依赖的package包/类
/**
 * Creates a mosaic of two or more rendered images.
 *
 * <p>Creates a <code>ParameterBlockJAI</code> from all
 * supplied arguments except <code>hints</code> and invokes
 * {@link JAI#create(String,ParameterBlock,RenderingHints)}.
 *
 * @see JAI
 * @see ParameterBlockJAI
 * @see RenderedOp
 *
 * @param sources <code>RenderedImage</code> sources.
 * @param mosaicType Mosaicking type.
 * May be <code>null</code>.
 * @param sourceAlpha 
 * May be <code>null</code>.
 * @param sourceAlpha Source alpha masks.
 * May be <code>null</code>.
 * @param sourceROI Source region of interest masks.
 * May be <code>null</code>.
 * @param sourceThreshold Source threshold values.
 * May be <code>null</code>.
 * @param backgroundValues Destination background value.
 * May be <code>null</code>.
 * @param hints The <code>RenderingHints</code> to use.
 * May be <code>null</code>.
 * @return The <code>RenderedOp</code> destination.
 * @throws IllegalArgumentException if any source is <code>null</code>.
 */
public static RenderedOp create(RenderedImage[] sources,
                                MosaicType mosaicType,
                                PlanarImage[] sourceAlpha,
                                ROI[] sourceROI,
                                double[][] sourceThreshold,
                                double[] backgroundValues,
                                RenderingHints hints)  {
    ParameterBlockJAI pb =
        new ParameterBlockJAI("Mosaic",
                              RenderedRegistryMode.MODE_NAME);

    int numSources = sources.length;
    for(int i = 0; i < numSources; i++) {
        pb.addSource(sources[i]);
    }

    pb.setParameter("mosaicType", mosaicType);
    pb.setParameter("sourceAlpha", sourceAlpha);
    pb.setParameter("sourceROI", sourceROI);
    pb.setParameter("sourceThreshold", sourceThreshold);
    pb.setParameter("backgroundValues", backgroundValues);

    return JAI.create("Mosaic", pb, hints);
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:54,代码来源:MosaicDescriptor.java

示例11: resizeImageAsJPG

import javax.media.jai.RenderedOp; //导入依赖的package包/类
/**
 * This method takes in an image as a byte array (currently supports GIF, JPG, PNG and
 * possibly other formats) and
 * resizes it to have a width no greater than the pMaxWidth parameter in pixels.
 * It converts the image to a standard
 * quality JPG and returns the byte array of that JPG image.
 *
 * @param pImageData
 *                the image data.
 * @param pMaxWidth
 *                the max width in pixels, 0 means do not scale.
 * @return the resized JPG image.
 * @throws IOException
 *                 if the image could not be manipulated correctly.
 */
public byte[] resizeImageAsJPG(byte[] pImageData, int pMaxWidth) throws IOException {
    InputStream imageInputStream = new ByteArrayInputStream(pImageData);
    // read in the original image from an input stream
    SeekableStream seekableImageStream = SeekableStream.wrapInputStream(imageInputStream, true);
    RenderedOp originalImage = JAI.create(JAI_STREAM_ACTION, seekableImageStream);
    ((OpImage) originalImage.getRendering()).setTileCache(null);
    int origImageWidth = originalImage.getWidth();
    // now resize the image
    double scale = 1.0;
    if (pMaxWidth > 0 && origImageWidth > pMaxWidth) {
        scale = (double) pMaxWidth / originalImage.getWidth();
    }
    ParameterBlock paramBlock = new ParameterBlock();
    paramBlock.addSource(originalImage); // The source image
    paramBlock.add(scale); // The xScale
    paramBlock.add(scale); // The yScale
    paramBlock.add(0.0); // The x translation
    paramBlock.add(0.0); // The y translation

    RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    RenderedOp resizedImage = JAI.create(JAI_SUBSAMPLE_AVERAGE_ACTION, paramBlock, qualityHints);

    // lastly, write the newly-resized image to an output stream, in a specific encoding
    ByteArrayOutputStream encoderOutputStream = new ByteArrayOutputStream();
    JAI.create(JAI_ENCODE_ACTION, resizedImage, encoderOutputStream, JAI_ENCODE_FORMAT_JPEG, null);
    // Export to Byte Array
    byte[] resizedImageByteArray = encoderOutputStream.toByteArray();
    return resizedImageByteArray;
}
 
开发者ID:aysenurbilgin,项目名称:cww_framework,代码行数:47,代码来源:ImageResize.java

示例12: crop

import javax.media.jai.RenderedOp; //导入依赖的package包/类
public static RenderedOp crop(
    final RenderedImage renderedImage,
    final float x,
    final float y,
    final float width,
    final float height) {
  final ParameterBlock pb = new ParameterBlock();
  pb.addSource(renderedImage); // The source image
  pb.add(x);
  pb.add(y);
  pb.add(width);
  pb.add(height);
  return JAI.create("Crop", pb); //$NON-NLS-1$
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:15,代码来源:ImageContainerUtilities.java

示例13: translate

import javax.media.jai.RenderedOp; //导入依赖的package包/类
public static RenderedOp translate(final RenderedImage renderedImage, final float x, final float y) {
  final ParameterBlock params = new ParameterBlock();
  params.addSource(renderedImage);
  params.add(x);
  params.add(y);
  return JAI.create("Translate", params); //$NON-NLS-1$
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:8,代码来源:ImageContainerUtilities.java

示例14: scale

import javax.media.jai.RenderedOp; //导入依赖的package包/类
public BufferedImage scale(final URL resource, final float factor) throws IOException {
  final IResourceReference resourceReference = this.factory.create(resource);
  try (InputStream stream = this.handler.openInputStream(resourceReference)) {
    final RenderedOp scaledRenderedOp = ImageContainerUtilities.scale(createRenderOp(stream), factor);
    try {
      final BufferedImage image = scaledRenderedOp.getAsBufferedImage();
      return image;
    } finally {
      scaledRenderedOp.dispose();
    }
  }
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:13,代码来源:ImageReader.java

示例15: readBufferedImage

import javax.media.jai.RenderedOp; //导入依赖的package包/类
public BufferedImage readBufferedImage(final InputStream inputStream) throws IOException {
  try {
    final RenderedOp renderedOp = createRenderOp(inputStream);
    try {
      return renderedOp.getAsBufferedImage();
    } finally {
      renderedOp.dispose();
    }
  } catch (final RuntimeException exception) {
    throw new IOException(exception);
  }
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:13,代码来源:ImageReader.java


注:本文中的javax.media.jai.RenderedOp类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。