0

私は以下によって撮影された画像をスケーリングしようとしています:

robot.createScreenCapture(new Rectangle(x,y,area.getWidth(),area.getHeight())

しかし、トリミングした後、jLabel (高さ:165px、幅:214) に入れると、引き伸ばされて歪んでしまいます。一時フォルダーに保存されている画像は問題ありません。コードは次のとおりです。

  public void cropImage(){

        try {
        //Execute when button is pressed  
                //Point pt = resizer.getLocation();  
               // this.setVisible(false);
                Robot robot= new Robot();

               Point pt = this.resizer.getLocationOnScreen();

               // int x = ((int)this.getLocation().getX()+1)+(int)pt.getX()+1;
               // int y = ((int)this.getLocation().getY()+1)+(int)pt.getY()+1;

                int x = (int)pt.getX()+1;
                int y = (int)pt.getY()+1;
                System.out.println("----------------------------");
                System.out.println(" X : "+x +" Y : "+ y);
                System.out.println("----------------------------");
                System.out.println(" Width : "+area.getWidth() +" Height : "+ getHeight());

                BufferedImage img = robot.createScreenCapture(new Rectangle(x,y,getWidth(),area.getHeight()));
                String saveFilePath = Common.getTempPath()+Common.getSeparator()+"temp.jpg";
                File save_path=new File(saveFilePath); 
                ImageIO.write(img, "JPG", save_path);

                emf.createInsideElements(saveFilePath);
                emf.repaint();
                emf.pack();
                this.dispose();

        } catch (AWTException ex) {
             Logger.getLogger(ResizableComponent.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
             Logger.getLogger(ResizableComponent.class.getName()).log(Level.SEVERE, null, ex);
        } 


  }
4

0 に答える 0