(String title, int width, int height, int slices, int options)
| 131 | } |
| 132 | |
| 133 | public static ImagePlus createByteImage(String title, int width, int height, int slices, int options) { |
| 134 | int fill = getFill(options); |
| 135 | int size = getSize(width, height); |
| 136 | if (size<0) return null; |
| 137 | byte[] pixels = new byte[size]; |
| 138 | ImageProcessor ip = new ByteProcessor(width, height, pixels, null); |
| 139 | switch (fill) { |
| 140 | case FILL_WHITE: |
| 141 | for (int i=0; i<width*height; i++) |
| 142 | pixels[i] = (byte)255; |
| 143 | break; |
| 144 | case FILL_BLACK: |
| 145 | break; |
| 146 | case FILL_RAMP: |
| 147 | byte[] ramp = new byte[width]; |
| 148 | for (int i=0; i<width; i++) |
| 149 | ramp[i] = (byte)((i*256.0)/width); |
| 150 | int offset; |
| 151 | for (int y=0; y<height; y++) { |
| 152 | offset = y*width; |
| 153 | for (int x=0; x<width; x++) |
| 154 | pixels[offset++] = ramp[x]; |
| 155 | } |
| 156 | break; |
| 157 | case FILL_NOISE: |
| 158 | fillNoiseByte(ip); |
| 159 | break; |
| 160 | } |
| 161 | ImagePlus imp = new ImagePlus(title, ip); |
| 162 | if (slices>1) { |
| 163 | boolean ok = createStack(imp, ip, slices, GRAY8, options); |
| 164 | if (!ok) imp = null; |
| 165 | } |
| 166 | return imp; |
| 167 | } |
| 168 | |
| 169 | private static void fillNoiseByte(ImageProcessor ip) { |
| 170 | ip.add(127); |
no test coverage detected