if ((jfxx == null)
|| (jfxx.code == THUMB_PALETTE)) {
writeJFXXSegment(index, thumb, ios, writer); // default
} else {
// Expand to RGB
BufferedImage thumbRGB =
((IndexColorModel) cm).convertToIntDiscrete
(thumb.getRaster(), false);
jfxx.setThumbnail(thumbRGB);
writer.thumbnailStarted(index);
jfxx.write(ios, writer); // Handles clipping if needed
writer.thumbnailComplete();
}
} else if (cs.getType() == ColorSpace.TYPE_RGB) {
if (jfxx == null) {
if (onlyOne) {
write(ios, thumb, writer); // As part of the header
} else {
writeJFXXSegment(index, thumb, ios, writer); // default
}
} else {
// If this is the only one, write the header first
if (onlyOne) {
write(ios, writer);
}
if (jfxx.code == THUMB_PALETTE) {
writeJFXXSegment(index, thumb, ios, writer); // default
writer.warningOccurred
(JPEGImageWriter.WARNING_NO_RGB_THUMB_AS_INDEXED);
} else {
jfxx.setThumbnail(thumb);
writer.thumbnailStarted(index);
jfxx.write(ios, writer); // Handles clipping if needed
writer.thumbnailComplete();
}
}
} else if (cs.getType() == ColorSpace.TYPE_GRAY) {
if (jfxx == null) {
if (onlyOne) {
BufferedImage thumbRGB = expandGrayThumb(thumb);
write(ios, thumbRGB, writer); // As part of the header
} else {
writeJFXXSegment(index, thumb, ios, writer); // default
}
} else {
// If this is the only one, write the header first
if (onlyOne) {
write(ios, writer);
}
if (jfxx.code == THUMB_RGB) {
BufferedImage thumbRGB = expandGrayThumb(thumb);
writeJFXXSegment(index, thumbRGB, ios, writer);
} else if (jfxx.code == THUMB_JPEG) {
jfxx.setThumbnail(thumb);
writer.thumbnailStarted(index);
jfxx.write(ios, writer); // Handles clipping if needed