title: How to crop resize image in Java?
body: <p>When I set the image with actual size onto a panel and cropping using mouse it's working fine but when I resize image onto panel and cropping it's getting wrong cropping image. How to crop resize image using mouse?</p>
  
  <pre><code>  int x = Math.min(p1.x, p2.x);
    int y = Math.min(p1.y, p2.y);
    int w = Math.abs(p1.x - p2.x);
    int h = Math.abs(p1.y - p2.y);
    BufferedImage dest = image.getSubimage(x,y,w,h)
  </code></pre>