Hi all,
I have a problem.
I could not find this problem in FAQs or in other place.

The result of AffineTransform to the ARGB image with
an interpolation is different from the expected one.

A test program and three PNG files are attached.

[tsrc.png] is the input image.
[tout.png] is the resultant image of resizing with TYPE_BILINEAR.
[texpect.png] is the expected result.

[tout.png] contains gray edge while all should be white.
(Please browse PNG image with the image browser
 which can show ARGB image correctly)

My JDK version is 1.2.2.
Is the problem solved in JDK 1.3 or later release ?
Is this the bug or some restriction of the function ?
Is there any work-around for this ?
I appreciate any advice.

---- <Test program> ----
package test;

/**
 * Interpolation test code.
 */
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
public class InterpolationTest {
/**
 */
static BufferedImage createTestImage(int width, int height) {
 BufferedImage bi = new BufferedImage(width, height,
    BufferedImage.TYPE_INT_ARGB);
 Graphics2D g2 = bi.createGraphics();
 Color outer = new Color(0, 0, 0, 0);
 Color inner = new Color(255, 255, 255, 255);

 g2.setColor(outer);
 g2.fillRect(0, 0, width, height);

 g2.setColor(inner);
 g2.fillRect(width/4, height/4, width/2, height/2);

 return bi;
}
/**
 */
static BufferedImage resize(BufferedImage bi,
  double scaleX, double scaleY, int interpolation) {
 AffineTransform at =
   AffineTransform.getScaleInstance(scaleX, scaleY);
 AffineTransformOp ato =
   new AffineTransformOp(at, interpolation);
 return ato.filter(bi, null);
}
/**
 */
public static void main(String[] args) {
 BufferedImage src = createTestImage(200, 200);
 BufferedImage result = resize(src, 2.0, 2.0,
   AffineTransformOp.TYPE_BILINEAR);
/*
// saveToPng(src, "tsrc.png");
// saveToPng(result, "tout.png");
*/
}
}
---- <End of Test program> ----

------------------------------------------------------------
Hitoshi Sato, Yamato Software Laboratory, IBM Japan.
e-mail: [EMAIL PROTECTED]

PNG image

PNG image

PNG image

Reply via email to