79297580

Date: 2024-12-20 14:50:55
Score: 1
Natty:
Report link

Thank you very, very much to @Holger.

Now I learned: Do NOT set the System scaling options!!!

The offending code could be fixed with:

public void paintComponent(Graphics g)
   {
      super.paintComponent(g);
      if (ApplicationImages.getImage() != null)
      {
         float factorWidth = 1536 / 1280F; // here is the fix
         float factorHeight = 960 / 859F; // here is the fix
         if (factorWidth < factorHeight)
         {
            int width = (int) (1280F * factorHeight);
            int x = getParent().getWidth() / 2 - width / 2;
            g.drawImage(
                  ApplicationImages.getImage().getScaledInstance(width,
                    getParent().getHeight(), BufferedImage.SCALE_SMOOTH),
              x, 0, this);
         }
         else
         {
            int height = (int) (859F * factorWidth);
            int y = getParent().getHeight() / 2 - height / 2;
            g.drawImage(ApplicationImages.getImage().getScaledInstance(
              getParent().getWidth(), height, BufferedImage.SCALE_SMOOTH),
              0, y, this);
         }
      }
   }
Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @Holger
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: dragoness