(String title, int width, int height, int slices, int options)
| 212 | } |
| 213 | |
| 214 | public static ImagePlus createIntImage(String title, int width, int height, int slices, int options) { |
| 215 | int fill = getFill(options); |
| 216 | int size = getSize(width, height); |
| 217 | if (size<0) return null; |
| 218 | int[] pixels = new int[size]; |
| 219 | IntProcessor ip = new IntProcessor(width, height, pixels); |
| 220 | switch (fill) { |
| 221 | case FILL_RAMP: |
| 222 | int[] ramp = new int[width]; |
| 223 | double inc = ((double)Integer.MAX_VALUE - (double)Integer.MIN_VALUE)/width; |
| 224 | for (int i=0; i<width; i++) { |
| 225 | ramp[i] = (int)((double)Integer.MIN_VALUE + i*inc); |
| 226 | } |
| 227 | for (int y=0; y<height; y++) { |
| 228 | int offset = y*width; |
| 229 | for (int x=0; x<width; x++) |
| 230 | pixels[offset++] = ramp[x]; |
| 231 | } |
| 232 | break; |
| 233 | |
| 234 | case FILL_NOISE: |
| 235 | fillNoiseInt(new IntProcessor(width,height,(int[])pixels)); |
| 236 | break; |
| 237 | } |
| 238 | ImagePlus imp = new ImagePlus(title, ip); |
| 239 | if (slices>1) { |
| 240 | boolean ok = createStack(imp, ip, slices, RGB, options); |
| 241 | if (!ok) imp = null; |
| 242 | } |
| 243 | return imp; |
| 244 | } |
| 245 | |
| 246 | private static void fillNoiseRGB(ColorProcessor ip, boolean sp) { |
| 247 | int width = ip.getWidth(); |
no test coverage detected