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


Java RenderContext.getRenderingHints方法代码示例

本文整理汇总了Java中java.awt.image.renderable.RenderContext.getRenderingHints方法的典型用法代码示例。如果您正苦于以下问题:Java RenderContext.getRenderingHints方法的具体用法?Java RenderContext.getRenderingHints怎么用?Java RenderContext.getRenderingHints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.renderable.RenderContext的用法示例。


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

示例1: 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));
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:21,代码来源:AffineRable8Bit.java

示例2: 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);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:31,代码来源:FilterAsAlphaRable.java

示例3: 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();

    // We only want it's alpha channel...
    rh.put(RenderingHintsKeyExt.KEY_COLORSPACE, 
           ColorSpaceHintKey.VALUE_COLORSPACE_ALPHA);

    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) 
        return cr; // It listened to us...

    return new FilterAlphaRed(cr);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:33,代码来源:FilterAlphaRable.java

示例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;

    return new ComponentTransferRed(convertSourceCS(srcRI),
                                    getTransferFunctions(),
                                    rc.getRenderingHints());
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:14,代码来源:ComponentTransferRable8Bit.java

示例5: createRendering

import java.awt.image.renderable.RenderContext; //导入方法依赖的package包/类
public RenderedImage createRendering(RenderContext rc) {
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    Filter src = getSource();
    Shape aoi = rc.getAreaOfInterest();

    if(aoi == null){
        aoi = getBounds2D();
    }

    AffineTransform usr2dev = rc.getTransform();

    // We only depend on our source for stuff that is inside
    // our bounds and his bounds (remember our bounds may be
    // tighter than his in one or both directions).
    Rectangle2D srect = src.getBounds2D();
    Rectangle2D rect  = getBounds2D();
    Rectangle2D arect = aoi.getBounds2D();

    // System.out.println("Rects Src:" + srect +
    //                    "My: " + rect +
    //                    "AOI: " + arect);
    if ( ! arect.intersects(rect) )
        return null;
    Rectangle2D.intersect(arect, rect, arect);

    RenderedImage ri = null;
    if ( arect.intersects(srect) ) {
        srect = (Rectangle2D)srect.clone();
        Rectangle2D.intersect(srect, arect, srect);

        RenderContext srcRC = new RenderContext(usr2dev, srect, rh);
        ri = src.createRendering(srcRC);

        // System.out.println("Pad filt: " + src + " R: " +
        //                    src.getBounds2D());
    }

    // No source image so create a 1,1 transparent one...
    if (ri == null)
        ri = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);

    // org.apache.batik.test.gvt.ImageDisplay.showImage("Paded: ", ri);
    // System.out.println("RI: " + ri + " R: " + srect);

    CachableRed cr = GraphicsUtil.wrap(ri);

    arect = usr2dev.createTransformedShape(arect).getBounds2D();

    // System.out.println("Pad rect : " + arect);
    // Use arect (my bounds intersect area of interest)
    cr = new PadRed(cr, arect.getBounds(), padMode, rh);
    return cr;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:56,代码来源:PadRable8Bit.java

示例6: createRendering

import java.awt.image.renderable.RenderContext; //导入方法依赖的package包/类
public RenderedImage createRendering(RenderContext rc) {

        AffineTransform usr2dev = rc.getTransform();

        // Just copy over the rendering hints.
        RenderingHints rh = rc.getRenderingHints();
        if (rh == null)  rh = new RenderingHints(null);

        Shape aoi = rc.getAreaOfInterest();
        if (aoi == null) aoi = getBounds2D();

        Rectangle2D rect     = getBounds2D();
        Rectangle2D clipRect = clipPath.getBounds2D();
        Rectangle2D aoiRect  = aoi.getBounds2D();

        if ( ! rect.intersects(clipRect) )
            return null;
        Rectangle2D.intersect(rect, clipRect, rect);


        if ( ! rect.intersects(aoiRect) )
            return null;
        Rectangle2D.intersect(rect, aoi.getBounds2D(), rect);

        Rectangle devR = usr2dev.createTransformedShape(rect).getBounds();

        if ((devR.width == 0) || (devR.height == 0))
            return null;

        BufferedImage bi = new BufferedImage(devR.width, devR.height,
                                             BufferedImage.TYPE_BYTE_GRAY);

        Shape devShape = usr2dev.createTransformedShape(getClipPath());
        Rectangle devAOIR;
        devAOIR = usr2dev.createTransformedShape(aoi).getBounds();

        Graphics2D g2d = GraphicsUtil.createGraphics(bi, rh);

        if (false) {
            java.util.Set s = rh.keySet();
            java.util.Iterator i = s.iterator();
            while (i.hasNext()) {
                Object o = i.next();
                System.out.println("XXX: " + o + " -> " + rh.get(o));
            }
        }
        g2d.translate(-devR.x, -devR.y);
        g2d.setPaint(Color.white);
        g2d.fill(devShape);
        g2d.dispose();

        RenderedImage ri;
        ri = getSource().createRendering(new RenderContext(usr2dev, rect, rh));

        CachableRed cr, clipCr;
        cr = RenderedImageCachableRed.wrap(ri);
        clipCr = new BufferedImageCachableRed(bi, devR.x, devR.y);
        CachableRed ret = new MultiplyAlphaRed(cr, clipCr);

          // Pad back out to the proper size...
        ret = new PadRed(ret, devAOIR, PadMode.ZERO_PAD, rh);

        return ret;
    }
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:65,代码来源:ClipRable8Bit.java

示例7: createRendering

import java.awt.image.renderable.RenderContext; //导入方法依赖的package包/类
/**
 *
 */
public RenderedImage createRendering(RenderContext renderContext) {
    // Get user space to device space transform
    AffineTransform usr2dev = renderContext.getTransform();
    if(usr2dev == null){
        usr2dev = new AffineTransform();
    }

    RenderingHints hints = renderContext.getRenderingHints();

    // As per specification, a value of zero for the
    // x-axis or y-axis causes the filter to produce
    // nothing.
    // The processing is done as follows:
    // + if the x resolution is zero, this is a no-op
    //   else compute the x scale.
    // + if the y resolution is zero, this is a no-op
    //   else compute the y resolution from the x scale
    //   and compute the corresponding y scale.
    // + if the y or x scale is less than one, insert
    //   an AffineRable.
    //   Else, return the source as is.
    int filterResolutionX = getFilterResolutionX();
    int filterResolutionY = getFilterResolutionY();
    // System.out.println("FilterResRable: " + filterResolutionX + "x" +
    //                    filterResolutionY);

    if ((filterResolutionX <= 0) || (filterResolutionY == 0))
        return null;

    // Find out the renderable area
    Rectangle2D imageRect = getBounds2D();
    Rectangle   devRect;
    devRect = usr2dev.createTransformedShape(imageRect).getBounds();

    // Now, compare the devRect with the filter
    // resolution hints
    float scaleX = 1;
    if(filterResolutionX < devRect.width)
        scaleX = filterResolutionX / (float)devRect.width;

    float scaleY = 1;
    if(filterResolutionY < 0)
        scaleY = scaleX;
    else if(filterResolutionY < devRect.height)
        scaleY = filterResolutionY / (float)devRect.height;

    // Only resample if either scaleX or scaleY is
    // smaller than 1
    if ((scaleX >= 1) && (scaleY >= 1))
        return getSource().createRendering(renderContext);

    // System.out.println("Using Fixed Resolution...");

    // Using fixed resolution image since we need an image larger
    // than this.
    RenderedImage resRed   = getResRed(hints);
    float         resScale = getResScale();

    AffineTransform residualAT;
    residualAT = new AffineTransform(usr2dev.getScaleX()/resScale,
                                     usr2dev.getShearY()/resScale,
                                     usr2dev.getShearX()/resScale,
                                     usr2dev.getScaleY()/resScale,
                                     usr2dev.getTranslateX(),
                                     usr2dev.getTranslateY());

    // org.ImageDisplay.showImage("AT: " + newUsr2Dev, result);

    return new AffineRed(GraphicsUtil.wrap(resRed), residualAT, hints);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:74,代码来源:FilterResRable8Bit.java

示例8: createRendering

import java.awt.image.renderable.RenderContext; //导入方法依赖的package包/类
public RenderedImage createRendering(RenderContext rc) {
    // System.out.println("RedRable Create Rendering: " + this);

    // Just copy over the rendering hints.
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    Shape aoi = rc.getAreaOfInterest();
    Rectangle aoiR;
    if (aoi != null)
        aoiR = aoi.getBounds();
    else
        aoiR = getBounds2D().getBounds();

    // get the current affine transform
    AffineTransform at = rc.getTransform();

    // For high quality output we should really apply a Gaussian
    // Blur when we are scaling the image down significantly this
    // helps to prevent aliasing in the result image.
    CachableRed cr = getSource();

    if ( ! aoiR.intersects(cr.getBounds()) )
        return null;

    if (at.isIdentity()) {
        // System.out.println("Using as is");
        return cr;
    }

    if ((at.getScaleX() == 1.0) && (at.getScaleY() == 1.0) &&
        (at.getShearX() == 0.0) && (at.getShearY() == 0.0)) {
        int xloc = (int)(cr.getMinX()+at.getTranslateX());
        int yloc = (int)(cr.getMinY()+at.getTranslateY());
        double dx = xloc - (cr.getMinX()+at.getTranslateX());
        double dy = yloc - (cr.getMinY()+at.getTranslateY());
        if (((dx > -0.0001) && (dx < 0.0001)) &&
            ((dy > -0.0001) && (dy < 0.0001))) {
            // System.out.println("Using TranslateRed");
            return new TranslateRed(cr, xloc, yloc);
        }
    }

    // System.out.println("Using Full affine: " + at);
    return new AffineRed(cr, at, rh);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:47,代码来源:RedRable.java

示例9: createRendering

import java.awt.image.renderable.RenderContext; //导入方法依赖的package包/类
public RenderedImage createRendering(RenderContext rc) {
    RenderingHints rh = rc.getRenderingHints();
    if (rh == null) rh = new RenderingHints(null);

    Filter src = getSource();
    Shape aoi = rc.getAreaOfInterest();

    if(aoi == null){
        aoi = getBounds2D();
    }

    AffineTransform usr2dev = rc.getTransform();

    // We only depend on our source for stuff that is inside
    // our bounds and his bounds (remember our bounds may be
    // tighter than his in one or both directions).
    Rectangle2D srect = src.getBounds2D();
    Rectangle2D rect  = getBounds2D();
    Rectangle2D arect = aoi.getBounds2D();

    // System.out.println("Rects Src:" + srect +
    //                    "My: " + rect +
    //                    "AOI: " + arect);
    if ( ! arect.intersects(rect) )
        return null;
    Rectangle2D.intersect(arect, rect, arect);

    RenderedImage ri = null;
    if ( arect.intersects(srect) ) {
        srect = (Rectangle2D)srect.clone();
        Rectangle2D.intersect(srect, arect, srect);

        RenderContext srcRC = new RenderContext(usr2dev, srect, rh);
        ri = src.createRendering(srcRC);

        // System.out.println("Pad filt: " + src + " R: " +
        //                    src.getBounds2D());
    }

    // No source image so create a 1,1 transparent one...
    if (ri == null)
        ri = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);

    // org.apache.flex.forks.batik.test.gvt.ImageDisplay.showImage("Paded: ", ri);
    // System.out.println("RI: " + ri + " R: " + srect);

    CachableRed cr = GraphicsUtil.wrap(ri);

    arect = usr2dev.createTransformedShape(arect).getBounds2D();

    // System.out.println("Pad rect : " + arect);
    // Use arect (my bounds intersect area of interest)
    cr = new PadRed(cr, arect.getBounds(), padMode, rh);
    return cr;
}
 
开发者ID:BowlerHatLLC,项目名称:feathers-sdk,代码行数:56,代码来源:PadRable8Bit.java

示例10: createRendering

import java.awt.image.renderable.RenderContext; //导入方法依赖的package包/类
/**
 * Creates a RenderedImage that represents 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.
 *
 * <p> The bounds of the <code>RenderedImage</code> are determined from
 * the dimensions parameter passed to the <code>RenderableGraphics</code>
 * constructor.  These bounds will be transformed by any
 * <code>AffineTransform</code> from the <code>RenderContext</code>.
 * The <code>RenderingHints</code> from the <code>RenderContext</code> may
 * be used to specify the tile width and height, <code>SampleModel</code>,
 * and <code>ColorModel</code> by supplying an <code>ImageLayout</code>
 * hint.  The precedence for determining tile width and height is to use
 * firstly values provided explicitly via the <code>ImageLayout</code>,
 * secondly the width and height of the <code>SampleModel</code> in the
 * hint, and thirdly the bounds of the <code>RenderableGraphics</code>
 * object after transformation.
 *
 * <p> If either the <code>SampleModel</code> or <code>ColorModel</code>
 * is null, an attempt will be made to derive a compatible value for the
 * null object from the non-null object.  If they are both null, a 3-band
 * byte <code>TiledImage</code> with a null <code>ColorModel</code> and a
 * <code>PixelInterleavedSampleModel</code> will be created.
 *
 * @param renderContext the RenderContext to use to produce the rendering.
 * @return a RenderedImage containing the rendered data.
 */
public RenderedImage createRendering(RenderContext renderContext) {
    // Unpack the RenderContext and set local variables based thereon
    AffineTransform usr2dev = renderContext.getTransform();
    if(usr2dev == null) {
        usr2dev = new AffineTransform();
    }
    RenderingHints hints = renderContext.getRenderingHints();
    Shape aoi = renderContext.getAreaOfInterest();
    if(aoi == null) {
        aoi = dimensions.getBounds();
    }

    // Transform the area of interest.
    Shape transformedAOI = usr2dev.createTransformedShape(aoi);

    // Create a TiledImage to be used as the canvas.
    TiledImage ti = createTiledImage(hints, transformedAOI.getBounds());

    // Create the associated Graphics2D object and translate it to
    // account for the initial origin specified in the RenderableGraphics
    // constructor.
    Graphics2D g2d = ti.createGraphics();

    // NOTE: There is no need to copy the state to the TiledImageGraphics
    // object here as all modifications are contained in the opArgList.

    // Set Graphics2D state variables according to the RenderContext
    if(!usr2dev.isIdentity()) {
        AffineTransform tf = getTransform();
        tf.concatenate(usr2dev);
        g2d.setTransform(tf);
    }
    if(hints != null) {
        g2d.addRenderingHints(hints);
    }
    g2d.setClip(aoi);

    // Evaluate the operation queue
    evaluateOpList(g2d);

    // Free Graphics2D resources
    g2d.dispose();

    return ti;
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:79,代码来源:RenderableGraphics.java


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