/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The Java Image IO plugin writer for encoding a binary RenderedImage into
* a WBMP format.
*
* The encoding process may clip, subsample using the parameters
* specified in the <code>ImageWriteParam</code>.
*
* @see com.sun.media.imageio.plugins.WBMPImageWriteParam
*/
/** The output stream to write into */
// Get the number of bits required to represent an int.
int numBits = 32;
int mask = 0x80000000;
numBits--;
mask >>>= 1;
}
return numBits;
}
// Convert an int value to WBMP multi-byte format.
for(int b = 0; b <= maxIndex; b++) {
if(b != maxIndex) {
multiBytes[b] |= (byte)0x80;
}
}
return multiBytes;
}
/** Constructs <code>WBMPImageWriter</code> based on the provided
* <code>ImageWriterSpi</code>.
*/
super(originator);
}
if (!(output instanceof ImageOutputStream))
} else
}
return null;
}
return meta;
}
return null;
}
return null;
}
public boolean canWriteRasters() {
return true;
}
}
}
if (writeRaster) {
} else {
}
if (sourceRegion == null)
else
if (sourceRegion.isEmpty())
// If the data are not formatted nominally then reformat.
!(sampleModel instanceof MultiPixelPackedSampleModel) ||
destSM =
w, h, 1,
w + 7 >> 3, 0);
}
else {
for (int i = 0, x = sourceRegion.x;
i <w; i++, x +=scaleX) {
}
k += w + 7 >> 3;
}
inputRaster = ras;
}
}
// If the data are not formatted nominally then reformat.
inputRaster.getMinY()));
}
// Check whether the image is white-is-zero.
boolean isWhiteZero = false;
}
// Get the line stride, bytes per row, and data array.
int lineStride =
// Write WBMP header.
// Write the data.
// Write the entire image.
processImageProgress(100.0F);
} else {
// Write the image row-by-row.
int offset = 0;
if(!isWhiteZero) {
// Black-is-zero
if (abortRequested())
break;
offset += lineStride;
}
} else {
// White-is-zero: need to invert data.
byte[] inverted = new byte[bytesPerRow];
if (abortRequested())
break;
}
offset += lineStride;
}
}
}
if (abortRequested())
else {
}
}
public void reset() {
super.reset();
}
}
}