本文整理汇总了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();
}
}
示例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();
}
示例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();
}
示例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()));
}
示例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();
}
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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$
}
示例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$
}
示例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();
}
}
}
示例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);
}
}