/*
*
* 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() {
// Toolkit Benchmarks
"format", "Image Format",
0x0);
new ToolkitCreateImage();
// 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 ImageIORead();
// ImageReader Options
"ImageReader Benchmarks");
"ImageReader Options");
"seekForwardOnly",
"Seek Forward Only",
"ignoreMetadata",
"Ignore Metadata",
"installListener",
"Install Progress Listener",
// ImageReader Tests
"ImageReader Tests");
new ImageReaderRead();
new ImageReaderGetImageMetadata();
}
}
private static void initIIOReadFormats() {
while (readerspis.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 {
}
}
}
{
}
}
boolean seekForwardOnly;
boolean ignoreMetadata;
}
// REMIND: add option for non-opaque images
if (testType == TEST_IMAGEREADER) {
try {
} catch (IOException e) {
e.printStackTrace();
}
new ReadProgressListener());
}
}
// 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 if (testType == TEST_TOOLKIT) {
} else { // testType == TEST_JPEGCODEC
format = "jpeg";
}
initInput();
}
}
}
}
}
}
public ToolkitCreateImage() {
super(toolkitTestRoot,
"createImage",
"Toolkit.createImage()");
// Toolkit handles FILE, URL, and ARRAY, but
// not FILECHANNEL
return (t.getType() != INPUT_FILECHANNEL);
}
});
addDependencies(toolkitOptRoot, true);
}
}
switch (inputType) {
case INPUT_FILE:
do {
try {
} catch (Exception e) {
e.printStackTrace();
}
} while (--numReps >= 0);
break;
case INPUT_URL:
do {
try {
} catch (Exception e) {
e.printStackTrace();
}
} while (--numReps >= 0);
break;
case INPUT_ARRAY:
do {
try {
} catch (Exception e) {
e.printStackTrace();
}
} while (--numReps >= 0);
break;
default:
throw new IllegalArgumentException("Invalid input type");
}
}
}
public ImageIORead() {
super(imageioTestRoot,
"imageioRead",
"ImageIO.read()");
// ImageIO.read() handles FILE, URL, and ARRAY, but
// not FILECHANNEL (well, I suppose we could create
// an ImageInputStream from a FileChannel source,
// but that's not a common use case; FileChannel is
// better handled by the ImageReader tests below)
return (t.getType() != INPUT_FILECHANNEL);
}
});
addDependencies(imageioOptRoot, true);
}
}
switch (inputType) {
case INPUT_FILE:
do {
try {
} catch (Exception e) {
e.printStackTrace();
}
} while (--numReps >= 0);
break;
case INPUT_URL:
do {
try {
} catch (Exception e) {
e.printStackTrace();
}
} while (--numReps >= 0);
break;
case INPUT_ARRAY:
do {
try {
new ByteArrayInputStream((byte[])input);
new BufferedInputStream(bais);
} catch (Exception e) {
e.printStackTrace();
}
} while (--numReps >= 0);
break;
default:
throw new IllegalArgumentException("Invalid input type");
}
}
}
public ImageReaderRead() {
super(imageReaderTestRoot,
"read",
"ImageReader.read()");
addDependencies(imageioGeneralOptRoot, true);
addDependencies(imageioOptRoot, true);
addDependencies(imageReaderOptRoot, true);
}
}
do {
try {
} catch (IOException e) {
e.printStackTrace();
}
} while (--numReps >= 0);
}
}
public ImageReaderGetImageMetadata() {
super(imageReaderTestRoot,
"getImageMetadata",
"ImageReader.getImageMetadata()");
addDependencies(imageioGeneralOptRoot, true);
addDependencies(imageioOptRoot, true);
addDependencies(imageReaderOptRoot, true);
}
// override units since this test doesn't read "pixels"
return ctx;
}
do {
try {
} catch (IOException e) {
e.printStackTrace();
}
} while (--numReps >= 0);
}
}
private static class ReadProgressListener
implements IIOReadProgressListener
{
int imageIndex, int thumbnailIndex) {}
float percentageDone) {}
}
}