public void run(String arg) { imp = IJ.getImage(); Roi roi = imp.getRoi(); if (roi != null && !roi.isArea()) imp.killRoi(); // ignore any line selection ImageProcessor ip = imp.getProcessor(); if (!showDialog(ip)) return; if (ip.getWidth() > 1 && ip.getHeight() > 1) ip.setInterpolate(interpolate); else ip.setInterpolate(false); ip.setBackgroundValue(bgValue); imp.startTiming(); try { if (newWindow && imp.getStackSize() > 1 && processStack) createNewStack(imp, ip); else scale(ip); } catch (OutOfMemoryError o) { IJ.outOfMemory("Scale"); } IJ.showProgress(1.0); }
// Use double buffer to reduce flicker when drawing complex ROIs. // Author: Erik Meijering void paintDoubleBuffered(Graphics g) { final int srcRectWidthMag = (int) (srcRect.width * magnification); final int srcRectHeightMag = (int) (srcRect.height * magnification); if (offScreenImage == null || offScreenWidth != srcRectWidthMag || offScreenHeight != srcRectHeightMag) { offScreenImage = createImage(srcRectWidthMag, srcRectHeightMag); offScreenWidth = srcRectWidthMag; offScreenHeight = srcRectHeightMag; } Roi roi = imp.getRoi(); try { if (imageUpdated) { imageUpdated = false; imp.updateImage(); } Graphics offScreenGraphics = offScreenImage.getGraphics(); Java2.setBilinearInterpolation(offScreenGraphics, Prefs.interpolateScaledImages); Image img = imp.getImage(); if (img != null) offScreenGraphics.drawImage( img, 0, 0, srcRectWidthMag, srcRectHeightMag, srcRect.x, srcRect.y, srcRect.x + srcRect.width, srcRect.y + srcRect.height, null); if (overlay != null) drawOverlay(offScreenGraphics); if (showAllROIs) drawAllROIs(offScreenGraphics); if (roi != null) drawRoi(roi, offScreenGraphics); if (srcRect.width < imageWidth || srcRect.height < imageHeight) drawZoomIndicator(offScreenGraphics); if (IJ.debugMode) showFrameRate(offScreenGraphics); g.drawImage(offScreenImage, 0, 0, null); } catch (OutOfMemoryError e) { IJ.outOfMemory("Paint"); } }
public void paint(Graphics g) { Roi roi = imp.getRoi(); if (roi != null || showAllROIs || overlay != null) { if (roi != null) roi.updatePaste(); if (!IJ.isMacOSX() && imageWidth != 0) { paintDoubleBuffered(g); return; } } try { if (imageUpdated) { imageUpdated = false; imp.updateImage(); } Java2.setBilinearInterpolation(g, Prefs.interpolateScaledImages); Image img = imp.getImage(); if (img != null) g.drawImage( img, 0, 0, (int) (srcRect.width * magnification), (int) (srcRect.height * magnification), srcRect.x, srcRect.y, srcRect.x + srcRect.width, srcRect.y + srcRect.height, null); if (overlay != null) drawOverlay(g); if (showAllROIs) drawAllROIs(g); if (roi != null) drawRoi(roi, g); if (srcRect.width < imageWidth || srcRect.height < imageHeight) drawZoomIndicator(g); if (IJ.debugMode) showFrameRate(g); } catch (OutOfMemoryError e) { IJ.outOfMemory("Paint"); } }