MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / createRGBImage

Method createRGBImage

ij/src/main/java/ij/gui/NewImage.java:174–212  ·  view source on GitHub ↗
(String title, int width, int height, int slices, int options)

Source from the content-addressed store, hash-verified

172 }
173
174 public static ImagePlus createRGBImage(String title, int width, int height, int slices, int options) {
175 int fill = getFill(options);
176 int size = getSize(width, height);
177 if (size<0) return null;
178 int[] pixels = new int[size];
179 ColorProcessor ip = new ColorProcessor(width, height, pixels);
180 switch (fill) {
181 case FILL_WHITE:
182 for (int i=0; i<width*height; i++)
183 pixels[i] = -1;
184 break;
185 case FILL_BLACK:
186 for (int i=0; i<width*height; i++)
187 pixels[i] = 0xff000000;
188 break;
189 case FILL_RAMP:
190 int r,g,b,offset;
191 int[] ramp = new int[width];
192 for (int i=0; i<width; i++) {
193 r = g = b = (byte)((i*256.0)/width);
194 ramp[i] = 0xff000000 | ((r<<16)&0xff0000) | ((g<<8)&0xff00) | (b&0xff);
195 }
196 for (int y=0; y<height; y++) {
197 offset = y*width;
198 for (int x=0; x<width; x++)
199 pixels[offset++] = ramp[x];
200 }
201 break;
202 case FILL_NOISE:
203 fillNoiseRGB(ip, true);
204 break;
205 }
206 ImagePlus imp = new ImagePlus(title, ip);
207 if (slices>1) {
208 boolean ok = createStack(imp, ip, slices, RGB, options);
209 if (!ok) imp = null;
210 }
211 return imp;
212 }
213
214 public static ImagePlus createIntImage(String title, int width, int height, int slices, int options) {
215 int fill = getFill(options);

Callers 4

HistogramWindowMethod · 0.95
createImageMethod · 0.95
HistogramPlotMethod · 0.95
saveToImageJImageMethod · 0.95

Calls 4

getFillMethod · 0.95
getSizeMethod · 0.95
fillNoiseRGBMethod · 0.95
createStackMethod · 0.95

Tested by

no test coverage detected