本文整理汇总了Java中java.awt.image.renderable.ParameterBlock.addSource方法的典型用法代码示例。如果您正苦于以下问题:Java ParameterBlock.addSource方法的具体用法?Java ParameterBlock.addSource怎么用?Java ParameterBlock.addSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.renderable.ParameterBlock
的用法示例。
在下文中一共展示了ParameterBlock.addSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adjustBrightness
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
public static PlanarImage adjustBrightness(PlanarImage src, final double b) {
final double[][] matrixRGB = {
{1d, 0D, 0D, b},
{0D, 1d, 0D, b},
{0, 0D, 1d, b}
};
final double[][] matrixGrey = {
{1d, b}
};
double[][] matrix;
if (src.getSampleModel().getNumBands() > 1)
matrix = matrixRGB;
else matrix = matrixGrey;
ParameterBlock pb = new ParameterBlock();
pb.addSource(src);
pb.add(matrix);
return JAI.create("bandcombine", pb);
}
示例2: graphicFillLineString
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的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 java.awt.image.renderable.ParameterBlock; //导入方法依赖的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 java.awt.image.renderable.ParameterBlock; //导入方法依赖的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: addBorder
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
/**
* add a border to image
* @param thickness
* @param color
* @param borderType
*/
public void addBorder(int thickness, Color color, int borderType) throws ExpressionException{
double colorArray[] = {color.getRed(), color.getGreen(), color.getBlue()};
BorderExtender borderExtender = new BorderExtenderConstant(colorArray);
ParameterBlock params = new ParameterBlock();
params.addSource(image());
params.add(thickness);
params.add(thickness);
params.add(thickness);
params.add(thickness);
if(BORDER_TYPE_CONSTANT==borderType) params.add(borderExtender);
else params.add(BorderExtender.createInstance(borderType));
//else if(BORDER_TYPE_WRAP==borderType)params.add(BorderExtender.createInstance(BorderExtender.BORDER_REFLECT));
image((JAI.create("border", params)).getAsBufferedImage());
}
示例6: translate
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
public void translate(int xtrans, int ytrans, Object interpolation) throws ExpressionException {
RenderingHints hints = new RenderingHints(RenderingHints.KEY_INTERPOLATION,interpolation);
if(interpolation!=RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR) {
hints.add(new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(1)));
}
ParameterBlock pb = new ParameterBlock();
pb.addSource(image());
BufferedImage img = JAI.create("translate", pb).getAsBufferedImage();
Graphics2D graphics = img.createGraphics();
graphics.clearRect(0, 0, img.getWidth(), img.getHeight());
AffineTransform at = new AffineTransform();
at.setToIdentity();
graphics.drawImage(image(), new AffineTransformOp(at, hints), xtrans, ytrans);
graphics.dispose();
image(img);
}
示例7: crop
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
public void crop(float x, float y, float width, float height) throws ExpressionException {
ParameterBlock params = new ParameterBlock();
params.addSource(image());
params.add(x);
params.add(y);
float w = getWidth();
float h = getHeight();
if (w < x + width) params.add(w - x);
else params.add(width);
if (h < y + height) params.add(h - y);
else params.add(height);
image(JAI.create("crop", params).getAsBufferedImage());
}
示例8: _rotate
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
public void _rotate(float x, float y, float angle, String interpolation) throws ExpressionException {
float radiansAngle = (float)Math.toRadians(angle);
// rotation center
float centerX = (float)getWidth() / 2;
float centerY = (float)getHeight() / 2;
ParameterBlock pb = new ParameterBlock();
pb.addSource(image());
pb.add(centerX);
pb.add(centerY);
pb.add(radiansAngle);
pb.add(new javax.media.jai.InterpolationBicubic(10));
// create a new, rotated image
image(JAI.create("rotate", pb).getAsBufferedImage());
}
示例9: create
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
/**
* Creates a <code>RenderedOp</code> that takes 1
* <code>RenderedImage</code> source and
* 6 <code>Object</code> parameters.
*
* @param opName The name of the operation.
* @param src The <code>RenderedImage</code> src parameter.
* @param param1 The first <code>Object</code> parameter.
* @param param2 The second <code>Object</code> parameter.
* @param param3 The third <code>Object</code> parameter.
* @param param4 The fourth <code>Object</code> parameter.
* @param param5 The fifth <code>Object</code> parameter.
* @param param6 The sixth <code>Object</code> parameter.
* @deprecated as of JAI 1.1. Instead use
* <code>create(String,ParameterBlock)</code>.
*/
public static RenderedOp create(String opName,
RenderedImage src,
Object param1,
Object param2,
Object param3,
Object param4,
Object param5,
Object param6) {
ParameterBlock args = new ParameterBlock();
args.addSource(src);
args.add(param1);
args.add(param2);
args.add(param3);
args.add(param4);
args.add(param5);
args.add(param6);
return create(opName, args, null);
}
示例10: resizeImage
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
public static RenderedImage resizeImage(RenderedImage image, int width, int height)
throws InconsistentImageScale
{
RenderedImage resizedImage=image;
// Computes ratio and scale
float scale=getScale(image.getWidth(),image.getHeight(),width,height);
// Processing resize process
ParameterBlock pb = new ParameterBlock();
// The source image
pb.addSource(resizedImage);
// The xScale
pb.add(scale);
// The yScale
pb.add(scale);
// The x translation
pb.add(0.0F);
// The y translation
pb.add(0.0F);
// The interpolation
pb.add(Interpolation.getInstance(Interpolation.INTERP_BICUBIC));
resizedImage = JAI.create("scale", pb, null);
LOGGER.debug("Image resized to : " + resizedImage.getWidth() + "x"
+ resizedImage.getHeight());
return resizedImage;
}
示例11: resizeImageAsJPG
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的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: TestWarp
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
/**
* Creates a new TestWarp object.
*/
public TestWarp (String path)
{
srcImage = JAI.create("fileload", new ParameterBlock().add(path), null);
// srcImage = PictureLoader.loadImages(new File(path), null)
// .get(1);
// srcImage = buildPattern(20, 10, 50, 50);
dimension = new Dimension(srcImage.getWidth(), srcImage.getHeight());
setPreferredSize(dimension);
// float[] xCoeffs = new float[] { 0f, 1.25f, 0.04f };
// float[] yCoeffs = new float[] { 0f, -0.02f, 1.5f };
// Warp warp = new WarpAffine(xCoeffs, yCoeffs);
//
int xStep = 500;
int xNumCells = 2;
int yStep = 500;
int yNumCells = 1;
float[] warpPositions = new float[]{
-100f, 0f, 500f, 100f, 1000f, 0f, // top line
0f, 500f, 500f, 500f, 1000f, 500f
}; // bot line
Warp warp = new WarpGrid(0, xStep, xNumCells, 0, yStep, yNumCells, warpPositions);
ParameterBlock pb = new ParameterBlock();
pb.addSource(invert(srcImage));
pb.add(warp);
pb.add(new InterpolationBilinear());
dstImage = invert(JAI.create("warp", pb));
((PlanarImage) dstImage).getTiles();
}
示例13: crop
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的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$
}
示例14: translate
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的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$
}
示例15: process
import java.awt.image.renderable.ParameterBlock; //导入方法依赖的package包/类
public PlanarImage process() {
if (!parameterSet) throw new IllegalStateException("parameters not set");
PlanarImage pi = source;
// for (int i=0; i<numIter; i++) {
ParameterBlock pb = new ParameterBlock();
pb.addSource(pi);
pb.add(MedianFilterDescriptor.MEDIAN_MASK_SQUARE);
pb.add(radius);
pi = JAI.create("MedianFilter", pb);
// }
return pi;
}