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

Major buffered image render speed regression

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.1.2, 5.0, 6
    • Fix Version/s: 6
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
      2d
    • Resolved In Build:
      mustang
    • CPU:
      x86
    • OS:
      windows_2000, windows_xp

      Backports

        Description



        Name: rmT116609 Date: 07/13/2004


        FULL PRODUCT VERSION :
        java version "1.5.0-beta3"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b57)
        Java HotSpot(TM) Client VM (build 1.5.0-beta3-b57, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [Version 5.1.2600]

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Nvidia Geforce 2 GTS

        A DESCRIPTION OF THE PROBLEM :
        painting TYPE_3BYTE_BGR bufferedImages onto a JPanel extremely slow. Painfully slow compared with 1.4.2. and even 1.5 beta 1

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Simply paint any TYPE_3BYTE_BGR BufferedImage onto a JPanel adding a scale affine to the graphics in paintComponent. Attach a JSlider to the scale value in the affine.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Sliding the JSlider causes the image zoom in and out on the panel. Using 1.4.2 this is silky smooth.
        ACTUAL -
        The zoom change is extremely jerky and slow on 1.5 beta 3

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public class ImageTest extends JFrame
        {
            AffineTransform Trns;
            BufferedImage Img;

            JSlider VwZmSlider;
            JPanel PaintPanel;

            protected void setZoom(double newZoom)
            {
                Trns.setToScale(newZoom, newZoom);
            }

            public ImageTest()
            {
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                Trns = new AffineTransform();
                Img = new BufferedImage(500, 500, BufferedImage.TYPE_3BYTE_BGR);

                PaintPanel = new JPanel()
                {
                    protected void paintComponent(Graphics g)
                    {
                        super.paintComponent(g);
                        Graphics2D g2d = (Graphics2D)g;

                        g2d.transform(Trns);
                        g2d.drawImage(Img, 0, 0, this);
                    }
                };

                Dimension Size = new Dimension(500, 500);
                PaintPanel.setPreferredSize(Size);
                PaintPanel.setMinimumSize(Size);
                PaintPanel.setMaximumSize(Size);

                VwZmSlider = new JSlider(0, 100, 50);
                VwZmSlider.addChangeListener(new ChangeListener()
                {
                    public void stateChanged(ChangeEvent changeEvent)
                    {
                        int val = VwZmSlider.getValue();
                        switch (val)
                        {
                            case 0:
                                setZoom(0.1);
                                break;

                            case 15:
                                setZoom(0.5);
                                break;

                            case 30:
                                setZoom(0.75);
                                break;

                            case 50:
                                setZoom(1.0);
                                break;

                            case 70:
                                setZoom(1.5);
                                break;

                            case 85:
                                setZoom(2.0);
                                break;

                            case 100:
                                setZoom(3.0);
                                break;

                            default:
                                if (val > 0 && val < 15)
                                {
                                    setZoom(((0.39 / 14.0) * (val - 1)) + 0.1);
                                }
                                else if (val > 15 && val < 30)
                                {
                                    setZoom(((0.24 / 14.0) * (val - 15)) + 0.5);
                                }
                                else if (val > 30 && val < 50)
                                {
                                    setZoom(((0.24 / 19.0) * (val - 30)) + 0.75);
                                }
                                else if (val > 50 && val < 70)
                                {
                                    setZoom(((0.49 / 19.0) * (val - 50)) + 1.0);
                                }
                                else if (val > 70 && val < 85)
                                {
                                    setZoom(((0.49 / 14.0) * (val - 70)) + 1.5);
                                }
                                else
                                {
                                    setZoom(((0.99 / 14.0) * (val - 85)) + 2.0);
                                }
                                break;
                        }
                        PaintPanel.repaint();
                    }
                });

                JPanel FillPanel = new JPanel();
                FillPanel.setLayout(new BorderLayout());

                FillPanel.add(PaintPanel, BorderLayout.CENTER);
                FillPanel.add(VwZmSlider, BorderLayout.SOUTH);

                getContentPane().add(FillPanel);
                pack();
                show();
            }

            public static void main(String[] args)
            {
                new ImageTest();
            }
        }
        ---------- END SOURCE ----------
        (Incident Review ID: 285594)
        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  flar Jim Graham
                  Reporter:
                  rmandalasunw Ranjith Mandala (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: