Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8046010

JEP 251: Multi-Resolution Images

    Details

    • Author:
      Alexander Scherbatiy, Jim Graham
    • JEP Type:
      Feature
    • Exposure:
      Open
    • Subcomponent:
      2d
    • Scope:
      SE
    • Discussion:
      2d dash dev at openjdk dot java dot net
    • Effort:
      M
    • Duration:
      M
    • Alert Status:
       Green
    • Alert Reason:
      Completed
    • JEP Number:
      251

      Description

      Summary

      Define a multi-resolution image API so that images with resolution variants can easily be manipulated and displayed.

      Description

      The new API, to be defined in the java.awt.image package, will allow a set of images with different resolutions to be encapsulated into a single multi-resolution image.

      The basic operations on a multi-resolution image are:

      • Retrieve a resolution-specific image variant based on a given DPI metric and set of image transformations, and

      • Retrieve all of the variants in the image.

      Aside from these operations a multi-resolution image will otherwise behave in the same way as an ordinary image. The java.awt.Graphics class will retrieve the necessary variant from a multi-resolution image based upon the current display DPI metric and any applied transformations.

      Proposed API sketch:

      package java.awt.image;
      
      /**
       * This interface is designed to provide a set of images at various resolutions.
       *
       * The {@code MultiResolutionImage} interface should be implemented by any
       * class whose instances are intended to provide image resolution variants
       * according to the given image width and height.
       *
       * @since 1.9
       */
      public interface MultiResolutionImage {
      
          /**
           * Gets a specific image that is the best variant to represent
           * this logical image at the indicated size.
           *
           * @param destImageWidth the width of the destination image, in pixels.
           * @param destImageHeight the height of the destination image, in pixels.
           * @return image resolution variant.
           *
           * @since 1.9
           */
          Image getResolutionVariant(float destImageWidth, float destImageHeight);
      
          /**
           * Gets a readable list of all resolution variants.
           * Note that many implementations might return an unmodifiable list.
           *
           * @return list of resolution variants.
           * @since 1.9
           */
          public List<Image> getResolutionVariants();
      }

      Alternatives

      In the current Java 2D API there is no way to detect if a high-resolution display is being used. At the very least, the DPI scale factor must be provided. Developers could use the scale factor to draw an image with the necessary resolution, but that can be very tedious.

      Testing

      The new API will need to be tested on Mac OS X with a Retina display and on Windows with a HiDPI display.

      The following scenarios can be tested:

      • Create a multi-resolution image from a set of images,

      • Create a multi-resolution image from images on the file system that follow the usual scaling naming conventions,

      • Create a multi-resolution image based on another multi-resolution image, and

      • Draw multi-resolution images with different DPI metrics and applied transform.

        Issue Links

          Activity

          Hide
          alexsch Alexander Scherbatiy (Inactive) added a comment -
          Here are two proposed solutions:
            MultiResolutionImage interface is introduced:
              http://cr.openjdk.java.net/~alexsch/8029339/webrev.05

            Resolution variants are added directly to the Image:
             http://cr.openjdk.java.net/~alexsch/8029339/list/webrev.00

          For more details see discussion: http://mail.openjdk.java.net/pipermail/awt-dev/2014-August/008371.html
          Show
          alexsch Alexander Scherbatiy (Inactive) added a comment - Here are two proposed solutions:   MultiResolutionImage interface is introduced:      http://cr.openjdk.java.net/~alexsch/8029339/webrev.05   Resolution variants are added directly to the Image:     http://cr.openjdk.java.net/~alexsch/8029339/list/webrev.00 For more details see discussion: http://mail.openjdk.java.net/pipermail/awt-dev/2014-August/008371.html
          Hide
          vdyakov Victor Dyakov added a comment -
          taking 2 weeks to get SQE plan before moving on Proposed To Target and review for Targeted state
          Show
          vdyakov Victor Dyakov added a comment - taking 2 weeks to get SQE plan before moving on Proposed To Target and review for Targeted state
          Hide
          mr Mark Reinhold added a comment -
          Before proposing to target this JEP, please update it with at least a
          sketch of the proposed API changes so that people know what to look for
          when this becomes available in a build. You don't need as much detail
          as in the Javadoc, but it should be enough for developers who already
          know this area to get started.
          Show
          mr Mark Reinhold added a comment - Before proposing to target this JEP, please update it with at least a sketch of the proposed API changes so that people know what to look for when this becomes available in a build. You don't need as much detail as in the Javadoc, but it should be enough for developers who already know this area to get started.
          Hide
          alexsch Alexander Scherbatiy (Inactive) added a comment -
          Proposed API sketch is added.
          Show
          alexsch Alexander Scherbatiy (Inactive) added a comment - Proposed API sketch is added.
          Hide
          alexsch Alexander Scherbatiy (Inactive) added a comment -
          The fix has been pushed to jdk9-client repository: http://hg.openjdk.java.net/jdk9/client/jdk/rev/7869179af058
          Show
          alexsch Alexander Scherbatiy (Inactive) added a comment - The fix has been pushed to jdk9-client repository: http://hg.openjdk.java.net/jdk9/client/jdk/rev/7869179af058
          Hide
          vdyakov Victor Dyakov added a comment -
          Due date is adjusted by SQE request to complete test development
          Show
          vdyakov Victor Dyakov added a comment - Due date is adjusted by SQE request to complete test development
          Hide
          vdyakov Victor Dyakov added a comment -
          Test development Done. Pending the latest pool of tests to review and push.
          Show
          vdyakov Victor Dyakov added a comment - Test development Done. Pending the latest pool of tests to review and push.

            People

            • Assignee:
              alexsch Alexander Scherbatiy (Inactive)
              Reporter:
              alexsch Alexander Scherbatiy (Inactive)
              Owner:
              Alexander Scherbatiy (Inactive)
              Reviewed By:
              Jim Graham, Philip Race
              Endorsed By:
              Kevin Rushforth
            • Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved:
                Integration Due: