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

Method writeBitmap

ij/src/main/java/ij/plugin/BMP_Writer.java:152–183  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

150 * Each scan line must be padded to an even 4-byte boundary.
151 */
152 private void writeBitmap () throws Exception {
153 int value;
154 int i;
155 int pad;
156 byte rgb [] = new byte [3];
157 if(biBitCount==24)
158 pad = 4 - ((biWidth * 3) % 4);
159 else
160 pad = 4 - ((biWidth) % 4);
161 if (pad == 4) // <==== Bug correction
162 pad = 0; // <==== Bug correction
163
164 int counter=0;
165 for(int row = biHeight; row>0; row--) {
166 if (row%20==0)
167 IJ.showProgress((double)(biHeight-row)/biHeight);
168 for(int col = 0; col<biWidth; col++) {
169 if(biBitCount==24) {
170 value = intBitmap [(row-1)*biWidth + col ];
171 rgb [0] = (byte) (value & 0xFF);
172 rgb [1] = (byte) ((value >> 8) & 0xFF);
173 rgb [2] = (byte) ((value >> 16) & 0xFF);
174 bfo.write(rgb);
175 } else
176 bfo.write(byteBitmap [(row-1)*biWidth + col ]);
177 ++counter;
178 }
179 for (i = 1; i <= pad; i++)
180 bfo.write (0x00);
181 counter += pad;
182 }
183 }
184
185
186 /*

Callers 1

saveMethod · 0.95

Calls 2

showProgressMethod · 0.95
writeMethod · 0.65

Tested by

no test coverage detected