setZoomFactor(1.5); setScrollPosition(new Point(500, 500)); //lets say this will display the center of the image.
//CODE FOR ZOOMING AND POSITIONING public void setZoomFactor(double zoomFactor) { if(IMAGE_FOUND && image != null && this._zoomFactor != zoomFactor) { this._zoomFactor = zoomFactor; width = originalWidth; height = originalHeight; double newwidth = width * zoomFactor; double newheight = height * zoomFactor; if(newwidth > 3 && newheight > 3) { disposeImage(); image = ImageUtil.scale((BufferedImage) origImage, newwidth, newheight, _antiAlias); garbageCollect(); } jLabel1.setIcon(new ImageIcon(image)); garbageCollect(); } } public void setScrollPosition(Point position) { setScrollX(position.x); setScrollY(position.y); } public int getScrollX() { return jScrollPane1.getHorizontalScrollBar().getValue(); } public void setScrollX(int scroll) { jScrollPane1.getHorizontalScrollBar().setValue(scroll); } private void garbageCollect() { Runtime.getRuntime().gc(); System.gc(); } private void disposeImage() { if(image != null) image.flush(); image = null; jLabel1.setIcon(null); garbageCollect(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)