|
Quick Lists
|
|
Bug ID:
|
4720195
|
|
Votes
|
1
|
|
Synopsis
|
Resulting image from RenderableOp.createScaledRendering has incorrect dimensions
|
|
Category
|
jai:implementation
|
|
Reported Against
|
1.1.1_01
|
|
Release Fixed
|
|
|
State
|
6-Fix Understood,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
|
|
Submit Date
|
24-JUL-2002
|
|
Description
|
Bug as reported by customer, Ste McLeod < xxxxx@xxxxx > :
Below is my example code. Running the code results in the output "width=121 height=90", ie the width has been increased by 1.
The width of the scaled image seems to vary depending on the size of the source image. A 800x600 image results in width=121 (ie wrong), a 799x600 image results in width=120 (ie okay). My guess is some kind of rounding problem somewhere.
Many thanks for any light anyone can shed on this,
Ste
public static void main(String[] args) throws Exception {
String file = "test.bmp";
int width = 120;
int height = 90;
// Load the source BMP
PlanarImage source = JAI.create("fileload", file);
// Get renderable image
ParameterBlock pb = new ParameterBlock();
pb.addSource(source).add(null).add(null).add(null).add(null).add(null);
RenderableImage ren = JAI.createRenderable("renderable", pb);
// Create scaled version - should be 120x90 pixels
PlanarImage scaled = (PlanarImage) ren.createScaledRendering(width, height, null);
System.out.println("width=" + scaled.getWidth() + " height=" + scaled.getHeight());
}
xxxxx@xxxxx 2002-11-18
See new test case attached.
|
|
Work Around
|
N/A
|
|
Evaluation
|
Bug as reported. This is occuring due to loss of precision caused by using floating point representation (as opposed to Rational) of the scale factors. In this case the user is asking for a 800x600 image to be scaled down to 120x90. The aspect ratio is calculated as 800 / 600, which is 4/3, when represented in a float this is 1.333334, which causes later calculations to slightly overshoot 120, taking ceil of which leads to 121. The code sections affected are the RenderableOp.createScaledRendering, MultiResolutionRenderableImage constructor and createRendering methods. Since this spans multiple classes with pre-defined public APIs, the solution to this problem is not obvious and requires more investigation.
xxxxx@xxxxx 2003-02-26
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |