(ImagePlus imp)
| 168 | } |
| 169 | |
| 170 | private void scale(ImagePlus imp) { |
| 171 | ImageProcessor ip = imp.getProcessor(); |
| 172 | if (newWindow) { |
| 173 | Rectangle r = ip.getRoi(); |
| 174 | ImagePlus imp2 = imp.createImagePlus(); |
| 175 | imp2.setProcessor(title, ip.resize(newWidth, newHeight, averageWhenDownsizing)); |
| 176 | Calibration cal = imp2.getCalibration(); |
| 177 | if (cal.scaled()) { |
| 178 | cal.pixelWidth *= 1.0/xscale; |
| 179 | cal.pixelHeight *= 1.0/yscale; |
| 180 | } |
| 181 | cal.xOrigin *= xscale; |
| 182 | cal.yOrigin *= yscale; |
| 183 | Overlay overlay = imp.getOverlay(); |
| 184 | if (overlay!=null && !imp.getHideOverlay()) { |
| 185 | overlay = overlay.duplicate(); |
| 186 | int slice = imp.getCurrentSlice(); |
| 187 | overlay.crop(slice,slice); |
| 188 | Rectangle roi = imp.getProcessor().getRoi(); |
| 189 | if (roi!=null) |
| 190 | overlay = overlay.crop(ip.getRoi()); |
| 191 | overlay = overlay.scale(xscale, yscale); |
| 192 | imp2.setOverlay(overlay); |
| 193 | } |
| 194 | imp2.show(); |
| 195 | imp.trimProcessor(); |
| 196 | imp2.trimProcessor(); |
| 197 | imp2.changes = true; |
| 198 | } else { |
| 199 | if (processStack && imp.getStackSize()>1) { |
| 200 | Undo.reset(); |
| 201 | StackProcessor sp = new StackProcessor(imp.getStack(), ip); |
| 202 | sp.scale(xscale, yscale, bgValue); |
| 203 | } else { |
| 204 | ip.snapshot(); |
| 205 | Undo.setup(Undo.FILTER, imp); |
| 206 | ip.setSnapshotCopyMode(true); |
| 207 | ip.scale(xscale, yscale); |
| 208 | ip.setSnapshotCopyMode(false); |
| 209 | } |
| 210 | imp.deleteRoi(); |
| 211 | imp.updateAndDraw(); |
| 212 | imp.changes = true; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | public static void record(ImagePlus imp, int w2, int h2, int d2, int method) { |
| 217 | if (!Recorder.scriptMode()) |
no test coverage detected