Adds an image in the form of a pixel array to the end of the stack.
(String sliceLabel, Object pixels)
| 60 | |
| 61 | /** Adds an image in the form of a pixel array to the end of the stack. */ |
| 62 | public void addSlice(String sliceLabel, Object pixels) { |
| 63 | if (pixels==null) |
| 64 | throw new IllegalArgumentException("'pixels' is null!"); |
| 65 | if (!pixels.getClass().isArray()) |
| 66 | throw new IllegalArgumentException("'pixels' is not an array"); |
| 67 | int size = stack.length; |
| 68 | nSlices++; |
| 69 | if (nSlices>=size) { |
| 70 | Object[] tmp1 = new Object[size*2]; |
| 71 | System.arraycopy(stack, 0, tmp1, 0, size); |
| 72 | stack = tmp1; |
| 73 | String[] tmp2 = new String[size*2]; |
| 74 | System.arraycopy(label, 0, tmp2, 0, size); |
| 75 | label = tmp2; |
| 76 | } |
| 77 | stack[nSlices-1] = pixels; |
| 78 | this.label[nSlices-1] = sliceLabel; |
| 79 | if (this.bitDepth==0) |
| 80 | setBitDepth(pixels); |
| 81 | } |
| 82 | |
| 83 | private void setBitDepth(Object pixels) { |
| 84 | if (pixels==null) |
no test coverage detected