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

Method writeRGBImage

ij/src/main/java/ij/io/ImageWriter.java:223–242  ·  view source on GitHub ↗
(OutputStream out, int[] pixels)

Source from the content-addressed store, hash-verified

221 }
222
223 void writeRGBImage(OutputStream out, int[] pixels) throws IOException {
224 long bytesWritten = 0L;
225 long size = 3L*fi.width*fi.height;
226 int count = fi.width*24;
227 byte[] buffer = new byte[count];
228 while (bytesWritten<size) {
229 if ((bytesWritten+count)>size)
230 count = (int)(size-bytesWritten);
231 int j = (int)(bytesWritten/3L);
232 for (int i=0; i<count; i+=3) {
233 buffer[i] = (byte)(pixels[j]>>16); //red
234 buffer[i+1] = (byte)(pixels[j]>>8); //green
235 buffer[i+2] = (byte)pixels[j]; //blue
236 j++;
237 }
238 out.write(buffer, 0, count);
239 bytesWritten += count;
240 showProgress((double)bytesWritten/size);
241 }
242 }
243
244 void writeRGBStack(OutputStream out, Object[] stack) throws IOException {
245 showProgressBar = false;

Callers 3

writeRGBStackMethod · 0.95
writeRGBVirtualStackMethod · 0.95
writeMethod · 0.95

Calls 2

showProgressMethod · 0.95
writeMethod · 0.65

Tested by

no test coverage detected