WrongParameterException
{
out = getOutputAsDataOutput();
if (out == null)
{
throw new WrongParameterException("Cannot get a DataOutput object to use for saving.");
}
PixelImage pi = getImage();
if (pi == null)
{
throw new MissingParameterException("Input image missing.");
}
if (!(pi instanceof IntegerImage))
{
throw new WrongParameterException("Input image must implement IntegerImage.");
}
IntegerImage image = (IntegerImage)pi;
width = image.getWidth();
height = image.getHeight();
setBoundsIfNecessary(width, height);
if (image instanceof RGB24Image)
{
imageType = IMAGE_TYPE_COLOR;
maxSample = 255;
save((RGB24Image)image);
}
else
if (image instanceof RGB48Image)
{
imageType = IMAGE_TYPE_COLOR;
maxSample = 65535;
save((RGB48Image)image);
}
else
if (image instanceof BilevelImage)
{
imageType = IMAGE_TYPE_BILEVEL;
maxSample = 1;
save((BilevelImage)image);
}
else
if (image instanceof Gray8Image)
{
imageType = IMAGE_TYPE_GRAY;
maxSample = 255;
save((Gray8Image)image);
}
else
if (image instanceof Gray16Image)
{
imageType = IMAGE_TYPE_GRAY;
maxSample = 65535;
save((Gray16Image)image);
}
else
{
throw new WrongParameterException("Unsupported input image type: " +
image.getClass().getName());
}
close();
}