本文整理汇总了Java中java.awt.image.renderable.RenderContext类的典型用法代码示例。如果您正苦于以下问题:Java RenderContext类的具体用法?Java RenderContext怎么用?Java RenderContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RenderContext类属于java.awt.image.renderable包,在下文中一共展示了RenderContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawImage
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
* Draws a <code>Filter</code> (<code>RenderableImage</code>) into a
* Graphics 2D.<p>
*
* This method also attempts to unwind the rendering chain a bit.
* So it knows about certain operations (like affine, pad,
* composite), rather than applying each of these operations in
* turn it accounts for their affects through modifications to the
* Graphics2D. This avoids generating lots of intermediate images.
*
* @param g2d The Graphics to draw into.
* @param filter The filter to draw
*/
public static void drawImage(Graphics2D g2d,
RenderableImage filter) {
if (filter instanceof PaintRable) {
PaintRable pr = (PaintRable)filter;
if (pr.paintRable(g2d))
// paintRable succeeded so we are done...
return;
}
// Get our sources image...
// System.out.println("UnOpt: " + filter);
AffineTransform at = g2d.getTransform();
RenderedImage ri = filter.createRendering
(new RenderContext(at, g2d.getClip(), g2d.getRenderingHints()));
if (ri == null)
return;
g2d.setTransform(IDENTITY);
drawImage(g2d, GraphicsUtil.wrap(ri));
g2d.setTransform(at);
}
示例2: createRendering
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
* Creates a RenderedImage that represented a rendering of this image
* using a given RenderContext. This is the most general way to obtain a
* rendering of a RenderableImage.
*
* <p> The created RenderedImage may have a property identified
* by the String HINTS_OBSERVED to indicate which RenderingHints
* (from the RenderContext) were used to create the image.
* In addition any RenderedImages
* that are obtained via the getSources() method on the created
* RenderedImage may have such a property.
*
* @param renderContext the RenderContext to use to produce the rendering.
* @return a RenderedImage containing the rendered data.
*/
public RenderedImage createRendering(RenderContext renderContext){
Rectangle2D r2d = getBounds2D();
// System.out.println("Rendering called");
Shape aoi = renderContext.getAreaOfInterest();
if (aoi != null) {
Rectangle2D aoiR2d = aoi.getBounds2D();
// System.out.println("R2d: " + r2d);
// System.out.println("AOI: " + aoiR2d);
if ( ! r2d.intersects(aoiR2d) )
return null;
Rectangle2D.intersect(r2d, aoiR2d, r2d);
}
Filter background = getBackground(node, null, r2d);
// System.out.println("BG: " + background);
if ( background == null)
return null;
background = new PadRable8Bit(background, r2d, PadMode.ZERO_PAD);
RenderedImage ri = background.createRendering
(new RenderContext(renderContext.getTransform(), r2d,
renderContext.getRenderingHints()));
// System.out.println("RI: [" + ri.getMinX() + ", "
// + ri.getMinY() + ", " +
// + ri.getWidth() + ", " +
// + ri.getHeight() + "]");
// org.ImageDisplay.showImage("BG: ", ri);
return ri;
}
示例3: drawImage
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
* Draws a <tt>Filter</tt> (<tt>RenderableImage</tt>) into a
* Graphics 2D.<p>
*
* This method also attempts to unwind the rendering chain a bit.
* So it knows about certain operations (like affine, pad,
* composite), rather than applying each of these operations in
* turn it accounts for their affects through modifications to the
* Graphics2D. This avoids generating lots of intermediate images.
*
* @param g2d The Graphics to draw into.
* @param filter The filter to draw
*/
public static void drawImage(Graphics2D g2d,
RenderableImage filter) {
if (filter instanceof PaintRable) {
PaintRable pr = (PaintRable)filter;
if (pr.paintRable(g2d))
// paintRable succeeded so we are done...
return;
}
// Get our sources image...
// System.out.println("UnOpt: " + filter);
AffineTransform at = g2d.getTransform();
RenderedImage ri = filter.createRendering
(new RenderContext(at, g2d.getClip(), g2d.getRenderingHints()));
if (ri == null)
return;
g2d.setTransform(IDENTITY);
drawImage(g2d, GraphicsUtil.wrap(ri));
g2d.setTransform(at);
}
示例4: createRendering
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
public RenderedImage createRendering(RenderContext rc) {
//
// Get source's rendered image
//
RenderedImage srcRI = getSource().createRendering(rc);
if(srcRI == null)
return null;
computeHistogram(rc);
SampleModel sm = srcRI.getSampleModel();
int bands = sm.getNumBands();
// System.out.println("Slope, Intercept: " + slope + ", " + intercept);
TransferFunction [] tfs = new TransferFunction[bands];
TransferFunction tf = new LinearTransfer(slope, intercept);
for (int i=0; i<tfs.length; i++)
tfs[i] = tf;
return new ComponentTransferRed(convertSourceCS(srcRI), tfs, null);
}
示例5: renderGNR
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
protected CachableRed renderGNR() {
AffineTransform at, rcAT;
at = usr2dev;
rcAT = new AffineTransform(at.getScaleX(), at.getShearY(),
at.getShearX(), at.getScaleY(),
0, 0);
RenderContext rc = new RenderContext(rcAT, null, renderingHints);
RenderedImage ri = rootFilter.createRendering(rc);
if (ri == null)
return null;
CachableRed ret;
ret = GraphicsUtil.wrap(ri);
ret = setupCache(ret);
int dx = Math.round((float)at.getTranslateX());
int dy = Math.round((float)at.getTranslateY());
ret = new TranslateRed(ret, ret.getMinX()+dx, ret.getMinY()+dy);
ret = GraphicsUtil.convertTosRGB(ret);
return ret;
}
示例6: createRendering
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
public RenderedImage createRendering(RenderContext rc) {
// Degenerate Affine no output image..
if (invAffine == null) return null;
// Just copy over the rendering hints.
RenderingHints rh = rc.getRenderingHints();
if (rh == null) rh = new RenderingHints(null);
// Map the area of interest to our input...
Shape aoi = rc.getAreaOfInterest();
if (aoi != null)
aoi = invAffine.createTransformedShape(aoi);
// update the current affine transform
AffineTransform at = rc.getTransform();
at.concatenate(affine);
// Return what our input creates (it should factor in our affine).
return getSource().createRendering(new RenderContext(at, aoi, rh));
}
示例7: createScaledRendering
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
public RenderedImage createScaledRendering(int w, int h,
RenderingHints hints) {
float sX = w/getWidth();
float sY = h/getHeight();
float scale = Math.min(sX, sY);
AffineTransform at = AffineTransform.getScaleInstance(scale, scale);
RenderContext rc = new RenderContext(at, hints);
float dX = (getWidth()*scale)-w;
float dY = (getHeight()*scale)-h;
RenderedImage ri = createRendering(rc);
CachableRed cr = RenderedImageCachableRed.wrap(ri);
return new PadRed(cr, new Rectangle((int)(dX/2), (int)(dY/2), w, h),
PadMode.ZERO_PAD, null);
}
示例8: mapRenderContext
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
* Maps the output RenderContext into the RenderContext for the ith
* source.
* This method satisfies the implementation of CRIF.
*
* @param i The index of the source image.
* @param renderContext The renderContext being applied to the operation.
* @param paramBlock The ParameterBlock containing the sources
* and the translation factors.
* @param image The RenderableImageOp from which this method
* was called.
*/
public RenderContext mapRenderContext(int i,
RenderContext renderContext,
ParameterBlock paramBlock,
RenderableImage image) {
float x_center = paramBlock.getFloatParameter(0);
float y_center = paramBlock.getFloatParameter(1);
float angle = paramBlock.getFloatParameter(2);
AffineTransform rotate =
AffineTransform.getRotateInstance(angle, x_center, y_center);
RenderContext RC = (RenderContext)renderContext.clone();
AffineTransform usr2dev = RC.getTransform();
usr2dev.concatenate(rotate);
RC.setTransform(usr2dev);
return RC;
}
示例9: mapRenderContext
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
* Maps the output RenderContext into the RenderContext for the ith
* source.
* This method satisfies the implementation of CRIF.
*
* @param i The index of the source image.
* @param renderContext The renderContext being applied to the operation.
* @param paramBlock The ParameterBlock containing the sources
* and the translation factors.
* @param image The RenderableImageOp from which this method
* was called.
*/
public RenderContext mapRenderContext(int i,
RenderContext renderContext,
ParameterBlock paramBlock,
RenderableImage image) {
double scaleX = paramBlock.getDoubleParameter(0);
double scaleY = paramBlock.getDoubleParameter(1);
AffineTransform scale =
new AffineTransform(scaleX, 0.0, 0.0, scaleY, 0.0, 0.0);
RenderContext RC = (RenderContext)renderContext.clone();
AffineTransform usr2dev = RC.getTransform();
usr2dev.concatenate(scale);
RC.setTransform(usr2dev);
return RC;
}
示例10: create
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
* Creates a <Code>RenderedImage</Code> from the renderable layer.
*
* @param renderContext The rendering information associated with
* this rendering.
* @param paramBlock The parameters used to create the image.
* @return A <code>RenderedImage</code>.
*/
public RenderedImage create(RenderContext renderContext,
ParameterBlock paramBlock) {
// Get the two renderable alpha images from the parameter block
RenderableImage alphaImage1 =
(RenderableImage)paramBlock.getObjectParameter(0);
RenderableImage alphaImage2 =
(RenderableImage)paramBlock.getObjectParameter(1);
// Cause the two renderable alpha images to be rendered
RenderedImage rAlphaImage1 =
alphaImage1.createRendering(renderContext);
RenderedImage rAlphaImage2 =
alphaImage2.createRendering(renderContext);
ParameterBlock newPB = (ParameterBlock)paramBlock.clone();
// Replace the renderable alpha images in the ParameterBlock with
// their renderings
newPB.set(rAlphaImage1, 0);
newPB.set(rAlphaImage2, 1);
// Return JAI.create("composite")
return JAI.create("composite", newPB,
renderContext.getRenderingHints());
}
示例11: mapRenderContext
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
* Maps the output RenderContext into the RenderContext for the ith
* source.
* This method satisfies the implementation of CRIF.
*
* @param i The index of the source image.
* @param renderContext The renderContext being applied to the operation.
* @param paramBlock The ParameterBlock containing the sources
* and the translation factors.
* @param image The RenderableImageOp from which this method
* was called.
*/
public RenderContext mapRenderContext(int i,
RenderContext renderContext,
ParameterBlock paramBlock,
RenderableImage image) {
float scale_x = paramBlock.getFloatParameter(0);
float scale_y = paramBlock.getFloatParameter(1);
float trans_x = paramBlock.getFloatParameter(2);
float trans_y = paramBlock.getFloatParameter(3);
AffineTransform scale = new AffineTransform(scale_x, 0.0, 0.0, scale_y,
trans_x, trans_y);
RenderContext RC = (RenderContext)renderContext.clone();
AffineTransform usr2dev = RC.getTransform();
usr2dev.concatenate(scale);
RC.setTransform(usr2dev);
return RC;
}
示例12: mapRenderContext
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
/**
* Maps the output RenderContext into the RenderContext for the ith
* source.
* This method satisfies the implementation of CRIF.
*
* @param i The index of the source image.
* @param renderContext The renderContext being applied to the operation.
* @param paramBlock The ParameterBlock containing the sources
* and the translation factors.
* @param image The RenderableImageOp from which this method
* was called.
*/
public RenderContext mapRenderContext(int i,
RenderContext renderContext,
ParameterBlock paramBlock,
RenderableImage image) {
float scale_x = paramBlock.getFloatParameter(0);
float scale_y = paramBlock.getFloatParameter(1);
AffineTransform scale = new AffineTransform(scale_x, 0.0, 0.0, scale_y,
0.0, 0.0);
RenderContext RC = (RenderContext)renderContext.clone();
AffineTransform usr2dev = RC.getTransform();
usr2dev.concatenate(scale);
RC.setTransform(usr2dev);
return RC;
}
示例13: createScaledRendering
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
public RenderedImage createScaledRendering(int w, int h,
RenderingHints hints) {
if(w <= 0 && h <= 0) {
throw new IllegalArgumentException(JaiI18N.getString("RenderableGraphics1"));
} else if(w <= 0) {
w = (int)Math.round(h*dimensions.getWidth()/dimensions.getHeight());
} else if(h <= 0) {
h = (int)Math.round(w*dimensions.getHeight()/dimensions.getWidth());
}
double sx = (double)w/dimensions.getWidth();
double sy = (double)h/dimensions.getHeight();
AffineTransform usr2dev = new AffineTransform();
usr2dev.setToScale(sx, sy);
return createRendering(new RenderContext(usr2dev, hints));
}
示例14: createRendering
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
public RenderedImage createRendering(RenderContext rc) {
// Source gets my usr2dev transform
AffineTransform at = rc.getTransform();
// Just copy over the rendering hints.
RenderingHints rh = rc.getRenderingHints();
if (rh == null) rh = new RenderingHints(null);
// if we didn't have an aoi specify our bounds as the aoi.
Shape aoi = rc.getAreaOfInterest();
if (aoi == null) {
aoi = getBounds2D();
}
rh.put(RenderingHintsKeyExt.KEY_COLORSPACE,
ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT);
RenderedImage ri;
ri = getSource().createRendering(new RenderContext(at, aoi, rh));
if (ri == null)
return null;
CachableRed cr = RenderedImageCachableRed.wrap(ri);
Object val = cr.getProperty(ColorSpaceHintKey.PROPERTY_COLORSPACE);
if (val == ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA_CONVERT)
return cr;
return new FilterAsAlphaRed(cr);
}
示例15: createRendering
import java.awt.image.renderable.RenderContext; //导入依赖的package包/类
public RenderedImage createRendering(RenderContext rc) {
//
// Get source's rendered image
//
RenderedImage srcRI = getSource().createRendering(rc);
if(srcRI == null)
return null;
CachableRed srcCR = GraphicsUtil.wrap(srcRI);
return new ProfileRed(srcCR, colorSpace);
}