[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: [OpenJDK 2D-Dev] [9] Review request for 8152309 Seamless way of using image filters with multi-r
From:       Jim Graham <james.graham () oracle ! com>
Date:       2016-04-26 22:08:01
Message-ID: d43e55b9-9674-99d2-53e5-546d804e7a38 () oracle ! com
[Download RAW message or body]

This all snowballed pretty far and wide.  The original fix to Swing 
icons was trivial in comparison.  In retrospect it might be better to 
simply offer the helper method from the original bug fix as a Toolkit 
solution and force applications to adopt it when dealing with MR sources:

http://cr.openjdk.java.net/~alexsch/8151303/webrev.00/

We can revisit this solution in the future if we get a lot of push from 
the community, but it seems like a lot of complications to add to the 
code for this small set of use cases...

			...jim

On 4/5/16 7:30 AM, Alexander Scherbatiy wrote:
>
> Hello,
>
> Could you review the fix:
>   bug: https://bugs.openjdk.java.net/browse/JDK-8152309
>   webrev: http://cr.openjdk.java.net/~alexsch/8152309/webrev.00
>
>
>   The purpose of the fix is to allow to apply an image filter for a
> multi-resolution image to get new multi-resolution image so the code
> below works without changes:
>     ----------
>     Image mrImage = getMultiResolutionImage();
>     ImageProducer mriProducer = new
> FilteredImageSource(mrImage.getSource(), new CropImageFilter(x, y, w, h));
>     Image filteredMRImage =
> Toolkit.getDefaultToolkit().createImage(mriProducer);
>     ----------
>
>
>   The Image producer needs to be updated to contain a set of
> resolution-variant image producers. It can be done introducing a new
> MultiResolution[Image]Producer interface. However, the
> FilteredImageSource which takes an original image producer as a
> constructor argument needs to be declared as
> MultiResolution[Image]Producer even for ordinary image producers.
> I chose to add the getRVProducers() method directly to the ImageProducer
> interface.
>
> The option to add a method which request a resolution variant producer
> for the given image size (getRVProducer(width, height) ) seems is not
> possible because the result multi-resolution image can be loaded by a
> MediaTracker which can load only finite number of resolution variants.
>
> Applying an image filter to resolution-variant producers requires to
> scale filters which use fixed image size (like CropImageFilter and
> ReplicateScaleFilter).
> There should be a way to get a scaled filter using the original one. The
> resolution variant image producer need to provide necessary scale
> factors for the used filter.
> To do that getScaledFilterInstance(scaleX, scaleY) method is added to
> the ImageFilter and public ResolutionVariantItem class which can hold
> image or image producer with associated scale factors is introduced.
>
> There is an interesting problem in SunGraphics2D where a
> multi-resolution image size is requested. To do that it is necessary to
> have an image observer which needs to redirect calls to the base image
> observer. The resolution variant observer needs to know scale factors to
> recalculate given [x, y, width, height] values. The scale factors are
> provided by toolkit multi-resolution image but for non toolkit
> multi-resolution images they need to be  calculated dividing a rv-image
> size to base image size. It looks like a closed loop when to know scale
> factors it needs to get a rv-image size but for this it is necessary to
> use an image observer which requires scale factors.
> The current fix just divides rv-image size to base image size for non
> toolkit multi-resolution images to get scale factors .
>
>   Thanks,
>   Alexandr.
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic