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

PNG image is not get scaled as it should be

    Details

    • Subcomponent:
      2d
    • Introduced In Build:
      b105
    • Introduced In Version:
      7
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        Java Version: 1.7.0-b28 or 1.6.0
        Platforms: solaris-sparc10 and others

        Problems: The outsourcing company Evergreen reported our manual test DestinationImageSizeTest.java is failing, the png image should get scaled, but it doesn't.
        the other images like jpg is OK.
        Need to investigate.

        The following is the test case:
         /*
        test : DestinationImageSizeTest.java 1.0 2003/10/15
          
        summary : This testcase aims at setting a destination image through
        ImageReadParam where the destination image size is much bigger than
        the actual image. The readers must honor the size of the destination image
        properly and the returned buffered image must have the original image
        only on the top-left corner of the buff image and rest of the image
        portions must be blank. This is tested for all the image types available
        with the registry.
           
        author : Praveen Mohan (###@###.###), Java2D-SQE
        Area : ImageIO
        */

        import javasoft.clientsqe.tonga.*;
        import java.io.*;
        import java.awt.*;
        import java.awt.image.BufferedImage;
        import javax.imageio.*;
        import javax.imageio.stream.*;
        import java.net.URL;
        import java.util.Iterator;
        import java.util.Map;
        import java.text.MessageFormat;


        public class DestinationImageSizeTest extends AbstractTongaManualTest {

            private Frame frame = null;
            
            private TestProperties properties = null;
            String failMsg = "";
            Panel canvasPanel = new Panel();
            ImageCanvas imgCanvas = new ImageCanvas();
            ImageCanvas imageioCanvas = new ImageCanvas();
            
            public void init(Map map) {
                frame = new Frame("DestinationImageSizeTest");
                frame.setLocation(50, 400);
                canvasPanel.add(imgCanvas);
                canvasPanel.add(imageioCanvas);
                frame.add("Center", canvasPanel);
                frame.setVisible(true);
            }

            public void doTest(TestProperties props) {
                
                properties = props;

                String formatName = null;

                try {
                    int index = props.getIndex();

                    formatName = (String) properties.get("FormatName_" + index);
                    String fileName = DestinationImageSizeTest.class.getResource((String) properties.get("InputImage_" + index)).getFile();

                    File imgFile = new File(fileName);

                    ImageInputStream iis = ImageIO.createImageInputStream(imgFile);

                    ImageReader reader = null;

                    Iterator iter = ImageIO.getImageReaders(iis);

                    if (iter.hasNext()) {
                        reader = (ImageReader) iter.next();
                    } else {
                        failMsg = failMsg + formatName + " "
                        + (String) properties.get("ReaderNotAvailable")
                        + NEW_LINE;
                        props.setMessage(failMsg);
                        props.setStatus(false);
                        Sysout.println(formatName + " "
                                       + (String) properties.get("ReaderNotAvailable"));
                        return;
                    }
                    resetCanvas();

                    BufferedImage bimg = ImageIO.read(imgFile);

                    imgCanvas.setPreferredSize(new Dimension(250, 250));
                    Image img = bimg.getScaledInstance(250, 250, Image.SCALE_SMOOTH);

                    imgCanvas.setImage(img);
                    reader.setInput(iis);
                    int w = bimg.getWidth();
                    int h = bimg.getHeight();

                    ImageReadParam param = reader.getDefaultReadParam();

                    Iterator iterType = reader.getImageTypes(0);
                    ImageTypeSpecifier typeSpecifier = null;

                    if (iterType.hasNext()) {
                        typeSpecifier = (ImageTypeSpecifier) iterType.next();
                    }

                    param.setDestination(typeSpecifier.createBufferedImage(w+w/3, h+h/3));
                    //param.setSourceRegion(new Rectangle(0, 0, w / 2, h / 2));
                    System.out.println((String) properties.get("ImageReadMessage")
                                       + " " + formatName);

                    BufferedImage finalImage = reader.read(0, param);
                    Image finalImg = finalImage.getScaledInstance(250, 250,
                                                                  Image.SCALE_SMOOTH);

                    imageioCanvas.setPreferredSize(new Dimension(250, 250));
                    imageioCanvas.setImage(finalImg);
                    frame.pack();
                    frame.invalidate();
                    frame.validate();
                    frame.repaint();
                    System.out.println(formatName + " "
                                       + (String) properties.get("ImageReadPassMessage"));
                    System.out.println("");

                } catch (Exception e) {
                    e.printStackTrace();
                    failMsg = failMsg + (String) properties.get("ReadingException")
                    + " " + formatName + " : " + e.toString();
                    Sysout.println("Exception thrown: " + e.toString());
                    System.out.println("Exception thrown: " + e.toString());
                    System.out.println("");
                    props.setMessage(failMsg);
                    props.setStatus(false);
                }
            }

            public void destroy() {
                if (frame != null) {
                    frame.dispose();
                }
            }

            public String getTestName() {
                return "DestinationImageSizeTest";
            }
            
            public void resetCanvas() {
                imgCanvas.setImage(null);
                imageioCanvas.setImage(null);
                frame.repaint();
            }
        }

        To reproduce the problem:
        1, cd /net/sqenfs-1/export1/comp/2d/tzhang/6ur_2d_exec/2d/src/2D_ImageIOTiger
        2, set JAVA_HOME
        3, set FILTER to DestinationImageSizeTest
        4, /net/sqenfs-1/export1/comp/2d/tzhang/share/bin/gnumake/solaris-sparc/gnumake runfilter

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  bae Andrew Brygin
                  Reporter:
                  ttzhang Tao Zhang
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: