I am making a project in swing. In which i want to crop image using mouse onto a panel . My image size is very large so when i fit image onto a panel and cropping it then i am getting blur image.
And when i use resize image coordinate and cropping from original image then i am getting wrong cropping image . so i want to fixed image onto a panel and crop image should be perfect.
How can i do this? i am using this 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);
int x1 = (int) Math.round(x * xScale);
int y1 = (int) Math.round (y * yScale);
int w1= (int) Math.round(w * xScale);
int h1= (int) Math.round(h * yScale);
BufferedImage dest = image.getSubimage(x1,y1,w1,h1);