()
| 398 | } |
| 399 | |
| 400 | boolean showDialog() { |
| 401 | if (staticType<GRAY8|| staticType>RGB) |
| 402 | staticType = GRAY8; |
| 403 | if (staticFillWith<OLD_FILL_WHITE||staticFillWith>FILL_NOISE) |
| 404 | staticFillWith = FILL_WHITE; |
| 405 | GenericDialog gd = new GenericDialog("New Image..."); |
| 406 | gd.addStringField("Name:", name, 12); |
| 407 | gd.addChoice("Type:", types, types[staticType]); |
| 408 | gd.addChoice("Fill with:", fill, fill[staticFillWith]); |
| 409 | gd.addNumericField("Width:", staticWidth, 0, 5, "pixels"); |
| 410 | gd.addNumericField("Height:", staticHeight, 0, 5, "pixels"); |
| 411 | gd.addNumericField("Slices:", staticSlices, 0, 5, ""); |
| 412 | gd.showDialog(); |
| 413 | if (gd.wasCanceled()) |
| 414 | return false; |
| 415 | name = gd.getNextString(); |
| 416 | String s = gd.getNextChoice(); |
| 417 | if (s.startsWith("8")) |
| 418 | gtype = GRAY8; |
| 419 | else if (s.startsWith("16")) |
| 420 | gtype = GRAY16; |
| 421 | else if (s.endsWith("RGB") || s.endsWith("rgb")) |
| 422 | gtype = RGB; |
| 423 | else |
| 424 | gtype = GRAY32; |
| 425 | gfill = gd.getNextChoiceIndex(); |
| 426 | gwidth = (int)gd.getNextNumber(); |
| 427 | gheight = (int)gd.getNextNumber(); |
| 428 | gslices = (int)gd.getNextNumber(); |
| 429 | if (gslices<1) gslices = 1; |
| 430 | if (gwidth<1 || gheight<1) { |
| 431 | IJ.error("New Image", "Width and height must be >0"); |
| 432 | return false; |
| 433 | } else { |
| 434 | if (!IJ.isMacro()) { |
| 435 | staticWidth = gwidth; |
| 436 | staticHeight = gheight; |
| 437 | staticSlices = gslices; |
| 438 | staticType = gtype; |
| 439 | staticFillWith = gfill; |
| 440 | } |
| 441 | return true; |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | void openImage() { |
| 446 | if (!showDialog()) |
no test coverage detected