/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
import j2dbench.TestEnvironment;
public static void init() {
// Image I/O Benchmarks
if (hasImageIO) {
// Image I/O Options
"Image I/O Options");
"format", "Image Format",
0x0);
// Image I/O Tests
"Image I/O Tests");
new ImageIOWrite();
// ImageWriter Options
"ImageWriter Benchmarks");
"ImageWriter Options");
"installListener",
"Install Progress Listener",
// ImageWriter Tests
"ImageWriter Tests");
new ImageWriterWrite();
}
}
private static void initIIOWriteFormats() {
while (writerspis.hasNext()) {
// REMIND: there could be more than one non-core plugin for
// a particular format, as is the case for JPEG2000 in the JAI
// IIO Tools package, so we should support that somehow
}
} else {
}
}
}
{
}
}
}
// REMIND: add option for non-opaque images
if (testType == TEST_IMAGEWRITER) {
try {
} catch (IOException e) {
e.printStackTrace();
}
new WriteProgressListener());
}
}
// REMIND: this is a hack to create an image that the
// WBMPImageWriter can handle (a better approach
// would involve checking the ImageTypeSpecifier
// of the writer's default image param)
g.dispose();
}
} else { // testType == TEST_JPEGCODEC
format = "jpeg";
}
initOutput();
}
}
}
}
}
}
public ImageIOWrite() {
super(imageioTestRoot,
"imageioWrite",
"ImageIO.write()");
// ImageIO.write() handles FILE and ARRAY, but
// not FILECHANNEL (well, I suppose we could create
// an ImageOutputStream from a FileChannel source,
// but that's not a common use case; FileChannel is
// better handled by the ImageWriter tests below)
return (t.getType() != OUTPUT_FILECHANNEL);
}
});
addDependencies(imageioOptRoot, true);
}
}
switch (outputType) {
case OUTPUT_FILE:
do {
try {
} catch (Exception e) {
e.printStackTrace();
}
} while (--numReps >= 0);
break;
case OUTPUT_ARRAY:
do {
try {
new ByteArrayOutputStream();
new BufferedOutputStream(baos);
} catch (Exception e) {
e.printStackTrace();
}
} while (--numReps >= 0);
break;
default:
throw new IllegalArgumentException("Invalid output type");
}
}
}
public ImageWriterWrite() {
super(imageWriterTestRoot,
"write",
"ImageWriter.write()");
addDependencies(imageioGeneralOptRoot, true);
addDependencies(imageioOptRoot, true);
addDependencies(imageWriterOptRoot, true);
}
}
do {
try {
} catch (IOException e) {
e.printStackTrace();
}
} while (--numReps >= 0);
}
}
private static class WriteProgressListener
implements IIOWriteProgressListener
{
float percentageDone) {}
int imageIndex, int thumbnailIndex) {}
float percentageDone) {}
}
}