• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MultiResolutionImage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中sun.awt.image.MultiResolutionImage的典型用法代码示例。如果您正苦于以下问题:Java MultiResolutionImage类的具体用法?Java MultiResolutionImage怎么用?Java MultiResolutionImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MultiResolutionImage类属于sun.awt.image包,在下文中一共展示了MultiResolutionImage类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testToolkitMultiResolutionImageLoad

import sun.awt.image.MultiResolutionImage; //导入依赖的package包/类
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {

        MediaTracker tracker = new MediaTracker(new JPanel());
        tracker.addImage(image, 0);
        tracker.waitForID(0);
        if (tracker.isErrorAny()) {
            throw new RuntimeException("Error during image loading");
        }
        tracker.removeImage(image, 0);

        testImageLoaded(image);

        int w = image.getWidth(null);
        int h = image.getHeight(null);

        Image resolutionVariant = ((MultiResolutionImage) image)
                .getResolutionVariant(2 * w, 2 * h);

        if (image == resolutionVariant) {
            throw new RuntimeException("Resolution variant is not loaded");
        }

        testImageLoaded(resolutionVariant);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:MultiResolutionImageTest.java


示例2: testToolkitMultiResolutionImageChache

import sun.awt.image.MultiResolutionImage; //导入依赖的package包/类
static void testToolkitMultiResolutionImageChache(String fileName, URL url) {

        Image img1 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        Image img2 = Toolkit.getDefaultToolkit().getImage(fileName);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }

        img1 = Toolkit.getDefaultToolkit().getImage(url);
        if (!(img1 instanceof MultiResolutionImage)) {
            throw new RuntimeException("Not a MultiResolutionImage");
        }

        img2 = Toolkit.getDefaultToolkit().getImage(url);
        if (img1 != img2) {
            throw new RuntimeException("Image is not cached");
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:MultiResolutionImageTest.java


示例3: createFromImage

import sun.awt.image.MultiResolutionImage; //导入依赖的package包/类
public CImage createFromImage(final Image image) {
    if (image instanceof MultiResolutionImage) {
        List<Image> resolutionVariants
                = ((MultiResolutionImage) image).getResolutionVariants();
        return createFromImages(resolutionVariants);
    }

    int[] buffer = imageToArray(image, true);
    if (buffer == null) {
        return null;
    }
    return new CImage(nativeCreateNSImageFromArray(buffer, image.getWidth(null), image.getHeight(null)));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:CImage.java


示例4: createFromImage

import sun.awt.image.MultiResolutionImage; //导入依赖的package包/类
private CImage createFromImage(final Image image, final boolean prepareImage) {
    if (image instanceof MultiResolutionImage) {
        List<Image> resolutionVariants
                = ((MultiResolutionImage) image).getResolutionVariants();
        return createFromImages(resolutionVariants, prepareImage);
    }

    int[] buffer = imageToArray(image, prepareImage);
    if (buffer == null) {
        return null;
    }
    return new CImage(nativeCreateNSImageFromArray(buffer, image.getWidth(null), image.getHeight(null)));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:CImage.java


示例5: main

import sun.awt.image.MultiResolutionImage; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
            return;
        }

        String icon = "NSImage://NSApplicationIcon";
        final Image image = Toolkit.getDefaultToolkit().getImage(icon);

        if (!(image instanceof MultiResolutionImage)) {
            throw new RuntimeException("Icon does not have resolution variants!");
        }

        MultiResolutionImage multiResolutionImage = (MultiResolutionImage) image;

        int width = 0;
        int height = 0;

        for (Image resolutionVariant : multiResolutionImage.getResolutionVariants()) {
            int rvWidth = resolutionVariant.getWidth(null);
            int rvHeight = resolutionVariant.getHeight(null);
            if (rvWidth < width || rvHeight < height) {
                throw new RuntimeException("Resolution variants are not sorted!");
            }
            width = rvWidth;
            height = rvHeight;
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:NSImageToMultiResolutionImageTest.java


示例6: isHiDPIImage

import sun.awt.image.MultiResolutionImage; //导入依赖的package包/类
private boolean isHiDPIImage(final Image img) {
    return (SurfaceManager.getImageScale(img) != 1) ||
           (resolutionVariantHint != SunHints.INTVAL_RESOLUTION_VARIANT_OFF
                && img instanceof MultiResolutionImage);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:SunGraphics2D.java


示例7: drawHiDPIImage

import sun.awt.image.MultiResolutionImage; //导入依赖的package包/类
private boolean drawHiDPIImage(Image img, int dx1, int dy1, int dx2,
                               int dy2, int sx1, int sy1, int sx2, int sy2,
                               Color bgcolor, ImageObserver observer) {

    if (SurfaceManager.getImageScale(img) != 1) {  // Volatile Image
        final int scale = SurfaceManager.getImageScale(img);
        sx1 = Region.clipScale(sx1, scale);
        sx2 = Region.clipScale(sx2, scale);
        sy1 = Region.clipScale(sy1, scale);
        sy2 = Region.clipScale(sy2, scale);
    } else if (img instanceof MultiResolutionImage) {
        // get scaled destination image size

        int width = img.getWidth(observer);
        int height = img.getHeight(observer);

        Image resolutionVariant = getResolutionVariant(
                (MultiResolutionImage) img, width, height,
                dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2);

        if (resolutionVariant != img && resolutionVariant != null) {
            // recalculate source region for the resolution variant

            ImageObserver rvObserver = MultiResolutionToolkitImage.
                    getResolutionVariantObserver(img, observer,
                            width, height, -1, -1);

            int rvWidth = resolutionVariant.getWidth(rvObserver);
            int rvHeight = resolutionVariant.getHeight(rvObserver);

            if (0 < width && 0 < height && 0 < rvWidth && 0 < rvHeight) {

                float widthScale = ((float) rvWidth) / width;
                float heightScale = ((float) rvHeight) / height;

                sx1 = Region.clipScale(sx1, widthScale);
                sy1 = Region.clipScale(sy1, heightScale);
                sx2 = Region.clipScale(sx2, widthScale);
                sy2 = Region.clipScale(sy2, heightScale);

                observer = rvObserver;
                img = resolutionVariant;
            }
        }
    }

    try {
        return imagepipe.scaleImage(this, img, dx1, dy1, dx2, dy2, sx1, sy1,
                                    sx2, sy2, bgcolor, observer);
    } catch (InvalidPipeException e) {
        try {
            revalidateAll();
            return imagepipe.scaleImage(this, img, dx1, dy1, dx2, dy2, sx1,
                                        sy1, sx2, sy2, bgcolor, observer);
        } catch (InvalidPipeException e2) {
            // Still catching the exception; we are not yet ready to
            // validate the surfaceData correctly.  Fail for now and
            // try again next time around.
            return false;
        }
    } finally {
        surfaceData.markDirty();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:65,代码来源:SunGraphics2D.java


示例8: getResolutionVariant

import sun.awt.image.MultiResolutionImage; //导入依赖的package包/类
private Image getResolutionVariant(MultiResolutionImage img,
        int srcWidth, int srcHeight, int dx1, int dy1, int dx2, int dy2,
        int sx1, int sy1, int sx2, int sy2) {

    if (srcWidth <= 0 || srcHeight <= 0) {
        return null;
    }

    int sw = sx2 - sx1;
    int sh = sy2 - sy1;

    if (sw == 0 || sh == 0) {
        return null;
    }

    int type = transform.getType();
    int dw = dx2 - dx1;
    int dh = dy2 - dy1;
    double destRegionWidth;
    double destRegionHeight;

    if ((type & ~(TYPE_TRANSLATION | TYPE_FLIP)) == 0) {
        destRegionWidth = dw;
        destRegionHeight = dh;
    } else if ((type & ~(TYPE_TRANSLATION | TYPE_FLIP | TYPE_MASK_SCALE)) == 0) {
        destRegionWidth = dw * transform.getScaleX();
        destRegionHeight = dh * transform.getScaleY();
    } else {
        destRegionWidth = dw * Math.hypot(
                transform.getScaleX(), transform.getShearY());
        destRegionHeight = dh * Math.hypot(
                transform.getShearX(), transform.getScaleY());
    }

    int destImageWidth = (int) Math.abs(srcWidth * destRegionWidth / sw);
    int destImageHeight = (int) Math.abs(srcHeight * destRegionHeight / sh);

    Image resolutionVariant
            = img.getResolutionVariant(destImageWidth, destImageHeight);

    if (resolutionVariant instanceof ToolkitImage
            && ((ToolkitImage) resolutionVariant).hasError()) {
        return null;
    }

    return resolutionVariant;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:SunGraphics2D.java


示例9: testToolkitMultiResolutionImage

import sun.awt.image.MultiResolutionImage; //导入依赖的package包/类
static void testToolkitMultiResolutionImage(Image image, boolean enableImageScaling)
        throws Exception {

    MediaTracker tracker = new MediaTracker(new JPanel());
    tracker.addImage(image, 0);
    tracker.waitForID(0);
    if (tracker.isErrorAny()) {
        throw new RuntimeException("Error during image loading");
    }

    final BufferedImage bufferedImage1x = new BufferedImage(IMAGE_WIDTH, IMAGE_HEIGHT,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g1x = (Graphics2D) bufferedImage1x.getGraphics();
    setImageScalingHint(g1x, false);
    g1x.drawImage(image, 0, 0, null);
    checkColor(bufferedImage1x.getRGB(3 * IMAGE_WIDTH / 4, 3 * IMAGE_HEIGHT / 4), false);

    Image resolutionVariant = ((MultiResolutionImage) image).
            getResolutionVariant(2 * IMAGE_WIDTH, 2 * IMAGE_HEIGHT);

    if (resolutionVariant == null) {
        throw new RuntimeException("Resolution variant is null");
    }

    MediaTracker tracker2x = new MediaTracker(new JPanel());
    tracker2x.addImage(resolutionVariant, 0);
    tracker2x.waitForID(0);
    if (tracker2x.isErrorAny()) {
        throw new RuntimeException("Error during scalable image loading");
    }

    final BufferedImage bufferedImage2x = new BufferedImage(2 * IMAGE_WIDTH,
            2 * IMAGE_HEIGHT, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2x = (Graphics2D) bufferedImage2x.getGraphics();
    setImageScalingHint(g2x, enableImageScaling);
    g2x.drawImage(image, 0, 0, 2 * IMAGE_WIDTH, 2 * IMAGE_HEIGHT, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, null);
    checkColor(bufferedImage2x.getRGB(3 * IMAGE_WIDTH / 2, 3 * IMAGE_HEIGHT / 2), enableImageScaling);

    if (!(image instanceof MultiResolutionImage)) {
        throw new RuntimeException("Not a MultiResolutionImage");
    }

    MultiResolutionImage multiResolutionImage = (MultiResolutionImage) image;

    Image image1x = multiResolutionImage.getResolutionVariant(IMAGE_WIDTH, IMAGE_HEIGHT);
    Image image2x = multiResolutionImage.getResolutionVariant(2 * IMAGE_WIDTH, 2 * IMAGE_HEIGHT);

    if (image1x.getWidth(null) * 2 != image2x.getWidth(null)
            || image1x.getHeight(null) * 2 != image2x.getHeight(null)) {
        throw new RuntimeException("Wrong resolution variant size");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:53,代码来源:MultiResolutionImageTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InliningMode类代码示例发布时间:2022-05-22
下一篇:
Java ClassPathTemplateLocator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap