Java 9 Multi-Resolution Images
Java
215
java9
12
multi-resolution
1
images
1
Male avatar

loveprogramming viết ngày 19/05/2021

https://grokonez.com/java/java-9/java-9-multi-resolution-images
Java 9 Multi-Resolution Images

In this tutorial, we will introduce Java 9 Multi-Resolution Images, a new API that allows a set of images with different resolutions (width and height) to be encapsulated into only one single image.

I. Basic operations

The new API which is defined in the java.awt.image package can help us:

  • Encapsulate many images with different resolutions into an image as its variants.
  • Get all variants in the image.
  • Get a resolution-specific image variant - the best variant to represent the logical image at the indicated size based on a given DPI metric.

Now take a look at MultiResolutionImage with 2 importants methods getResolutionVariant() that returns an Image and getResolutionVariants() that returns a list of Images:


package java.awt.image;

public interface MultiResolutionImage {

    Image getResolutionVariant(double destImageWidth, double destImageHeight);
    public List getResolutionVariants();
}

Then, we have an abstract class that implements MultiResolutionImage:


public abstract class AbstractMultiResolutionImage extends java.awt.Image
        implements MultiResolutionImage {

    @Override
    public int getWidth(ImageObserver observer) {
        return getBaseImage().getWidth(observer);
    }

    @Override
    public int getHeight(ImageObserver observer) {
        return getBaseImage().getHeight(observer);
    }

    @Override
    public ImageProducer getSource() {
        return getBaseImage().getSource();
    }

    @Override
    public Graphics getGraphics() {
        throw new UnsupportedOperationException("getGraphics() not supported"
                + " on Multi-Resolution Images");
    }

    @Override
    public Object getProperty(String name, ImageObserver observer) {
        return getBaseImage().getProperty(name, observer);
    }

    protected abstract Image getBaseImage();
}

This abstract AbstractMultiResolutionImage class provides default implementations of several Image methods. We can create our own custom class by extending it to implement the interface.

More at:

https://grokonez.com/java/java-9/java-9-multi-resolution-images
Java 9 Multi-Resolution Images

Bình luận


White
{{ comment.user.name }}
Bỏ hay Hay
{{comment.like_count}}
Male avatar
{{ comment_error }}
Hủy
   

Hiển thị thử

Chỉnh sửa

Male avatar

loveprogramming

545 bài viết.
97 người follow
Kipalog
{{userFollowed ? 'Following' : 'Follow'}}
Cùng một tác giả
Male avatar
1 0
Tutorial Link: (Link) (Ảnh) Django is a Pythonbased free and opensource web framework that follows the modeltemplateview architectural pattern. A...
loveprogramming viết 1 năm trước
1 0
Male avatar
1 0
https://loizenai.com/angular11nodejspostgresqlcrudexample/ Angular 11 Node.js PostgreSQL Crud Example (Ảnh) Tutorial: “Angular 11 Node.js Postg...
loveprogramming viết 11 tháng trước
1 0
Male avatar
1 0
Angular Spring Boot jwt Authentication Example Github https://loizenai.com/angularspringbootjwt/ (Ảnh) Tutorial: ” Angular Spring Boot jwt Authe...
loveprogramming viết 11 tháng trước
1 0
{{like_count}}

kipalog

{{ comment_count }}

bình luận

{{liked ? "Đã kipalog" : "Kipalog"}}


Male avatar
{{userFollowed ? 'Following' : 'Follow'}}
545 bài viết.
97 người follow

 Đầu mục bài viết

Vẫn còn nữa! x

Kipalog vẫn còn rất nhiều bài viết hay và chủ đề thú vị chờ bạn khám phá!