Commit 02602c0f authored by kirandjiska's avatar kirandjiska

Implementing getMatchingImage function for the zoom box panel

parent 0a5cf28b
......@@ -1621,10 +1621,20 @@ public class ConstraintsSelectionDialog extends JInternalFrame implements Zoomab
float zoomOrigin = zoom*mZoomRate ;
// BufferedImage subImage = this.getDisplayedImage().getSubimage(x, y, width, height);
BufferedImage subImage = this.getOriginalImage().getSubimage(xo, yo, widthOrigin, heightOrigin);
int widthSubImage=widthOrigin;
int heightSubImage=heightOrigin;
return subImage.getScaledInstance((int) (widthOrigin * zoomOrigin), (int) (heightOrigin *zoomOrigin ), Image.SCALE_SMOOTH);
// manage integer precision rounding problem
if(widthSubImage + xo > this.getOriginalImage().getWidth()) {
widthSubImage=this.getOriginalImage().getWidth() - xo;
}
if(heightSubImage + yo > this.getOriginalImage().getHeight()) {
heightSubImage=this.getOriginalImage().getHeight() - yo;
}
BufferedImage subImage = this.getOriginalImage().getSubimage(xo, yo, widthSubImage, heightSubImage);
return subImage.getScaledInstance((int) (widthSubImage * zoomOrigin), (int) (heightSubImage * zoomOrigin ), Image.SCALE_SMOOTH);
}
public BufferedImage getOriginalImage() {
......
......@@ -20,7 +20,7 @@ public interface Zoomable {
public BufferedImage getDisplayedImage();
/**
* Return the corresponding area from the source image with
* Return the corresponding area from the source image from
* displayed image relative coordinates
*
* @param x
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment