當前位置: 首頁>>代碼示例>>Java>>正文


Java RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR屬性代碼示例

本文整理匯總了Java中java.awt.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR屬性的典型用法代碼示例。如果您正苦於以下問題:Java RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR屬性的具體用法?Java RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR怎麽用?Java RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.awt.RenderingHints的用法示例。


在下文中一共展示了RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: scaleImage

public static BufferedImage scaleImage(BufferedImage p_scaleImage_0_, int p_scaleImage_1_)
{
    int i = p_scaleImage_0_.getWidth();
    int j = p_scaleImage_0_.getHeight();
    int k = j * p_scaleImage_1_ / i;
    BufferedImage bufferedimage = new BufferedImage(p_scaleImage_1_, k, 2);
    Graphics2D graphics2d = bufferedimage.createGraphics();
    Object object = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;

    if (p_scaleImage_1_ < i || p_scaleImage_1_ % i != 0)
    {
        object = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
    }

    graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, object);
    graphics2d.drawImage(p_scaleImage_0_, 0, 0, p_scaleImage_1_, k, (ImageObserver)null);
    return bufferedimage;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:18,代碼來源:TextureUtils.java

示例2: scaleToPowerOfTwo

public static BufferedImage scaleToPowerOfTwo(BufferedImage p_scaleToPowerOfTwo_0_, int p_scaleToPowerOfTwo_1_)
{
    if (p_scaleToPowerOfTwo_0_ == null)
    {
        return p_scaleToPowerOfTwo_0_;
    }
    else
    {
        int i = p_scaleToPowerOfTwo_0_.getWidth();
        int j = p_scaleToPowerOfTwo_0_.getHeight();
        int k = Math.max(i, p_scaleToPowerOfTwo_1_);
        k = MathHelper.roundUpToPowerOfTwo(k);

        if (k == i)
        {
            return p_scaleToPowerOfTwo_0_;
        }
        else
        {
            int l = j * k / i;
            BufferedImage bufferedimage = new BufferedImage(k, l, 2);
            Graphics2D graphics2d = bufferedimage.createGraphics();
            Object object = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;

            if (k % i != 0)
            {
                object = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
            }

            graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, object);
            graphics2d.drawImage(p_scaleToPowerOfTwo_0_, 0, 0, k, l, (ImageObserver)null);
            return bufferedimage;
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:35,代碼來源:TextureUtils.java

示例3: scaleMinTo

public static BufferedImage scaleMinTo(BufferedImage p_scaleMinTo_0_, int p_scaleMinTo_1_)
{
    if (p_scaleMinTo_0_ == null)
    {
        return p_scaleMinTo_0_;
    }
    else
    {
        int i = p_scaleMinTo_0_.getWidth();
        int j = p_scaleMinTo_0_.getHeight();

        if (i >= p_scaleMinTo_1_)
        {
            return p_scaleMinTo_0_;
        }
        else
        {
            int k;

            for (k = i; k < p_scaleMinTo_1_; k *= 2)
            {
                ;
            }

            int l = j * k / i;
            BufferedImage bufferedimage = new BufferedImage(k, l, 2);
            Graphics2D graphics2d = bufferedimage.createGraphics();
            Object object = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
            graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, object);
            graphics2d.drawImage(p_scaleMinTo_0_, 0, 0, k, l, (ImageObserver)null);
            return bufferedimage;
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:34,代碼來源:TextureUtils.java

示例4: AffineTransformOp

/**
 * Constructs an {@code AffineTransformOp} given an affine transform.
 * The interpolation type is determined from the
 * {@code RenderingHints} object.  If the interpolation hint is
 * defined, it will be used. Otherwise, if the rendering quality hint is
 * defined, the interpolation type is determined from its value.  If no
 * hints are specified ({@code hints} is null),
 * the interpolation type is {@link #TYPE_NEAREST_NEIGHBOR
 * TYPE_NEAREST_NEIGHBOR}.
 *
 * @param xform The {@code AffineTransform} to use for the
 * operation.
 *
 * @param hints The {@code RenderingHints} object used to specify
 * the interpolation type for the operation.
 *
 * @throws ImagingOpException if the transform is non-invertible.
 * @see java.awt.RenderingHints#KEY_INTERPOLATION
 * @see java.awt.RenderingHints#KEY_RENDERING
 */
public AffineTransformOp(AffineTransform xform, RenderingHints hints){
    validateTransform(xform);
    this.xform = (AffineTransform) xform.clone();
    this.hints = hints;

    if (hints != null) {
        Object value = hints.get(RenderingHints.KEY_INTERPOLATION);
        if (value == null) {
            value = hints.get(RenderingHints.KEY_RENDERING);
            if (value == RenderingHints.VALUE_RENDER_SPEED) {
                interpolationType = TYPE_NEAREST_NEIGHBOR;
            }
            else if (value == RenderingHints.VALUE_RENDER_QUALITY) {
                interpolationType = TYPE_BILINEAR;
            }
        }
        else if (value == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR) {
            interpolationType = TYPE_NEAREST_NEIGHBOR;
        }
        else if (value == RenderingHints.VALUE_INTERPOLATION_BILINEAR) {
            interpolationType = TYPE_BILINEAR;
        }
        else if (value == RenderingHints.VALUE_INTERPOLATION_BICUBIC) {
            interpolationType = TYPE_BICUBIC;
        }
    }
    else {
        interpolationType = TYPE_NEAREST_NEIGHBOR;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:50,代碼來源:AffineTransformOp.java


注:本文中的java.awt.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。