if (image == null) {
return;
}
if (resource.isEmbedded()) {
ImageSettings embeddedSettings = jxlDocument.getEmbeddedImageSettings();
BufferedImage embeddedImage;
if (ClientConfiguration.getDefault().isUseMultiImage()) {
embeddedImage = ImageConverter.rescale(image, embeddedSettings.getMaxWidth(),
embeddedSettings.getMaxHeight());
addCompositeImage(resource, embeddedImage, embeddedSettings, false);
} else {
embeddedImage = ImageConverter.rescale(image, embeddedSettings.getBitDepth(),
embeddedSettings.getMaxWidth(),
embeddedSettings.getMaxHeight());
Bitmap bitmap = ImageConverter.convert(embeddedImage, embeddedSettings.getBitDepth());
ImageRecord imageRecord = resource.createImageRecord(bitmap, false);
pluckerDocument.addRecord(imageRecord);
}
if (!embeddedSettings.isIncludeAlternate() ||
((image.getWidth() <= embeddedImage.getWidth()) &&
(image.getHeight() <= embeddedImage.getHeight()))) {
return;
}
}
if ((jxlDocument.isIncludeStandaloneImages())) {
// TODO: Improve heuristic for determining whether to include an alternate image.
ImageSettings standaloneSettings = jxlDocument.getStandaloneImageSettings();
if (ClientConfiguration.getDefault().isUseMultiImage()) {
BufferedImage standaloneImage = ImageConverter.rescale(image, standaloneSettings.getMaxWidth(),
standaloneSettings.getMaxHeight());
addCompositeImage(resource, standaloneImage, standaloneSettings, resource.isEmbedded());
} else {
BufferedImage standaloneImage = ImageConverter.rescale(image, standaloneSettings.getMaxWidth(),
standaloneSettings.getMaxHeight());
int width = standaloneImage.getWidth();
int height = standaloneImage.getHeight();
int targetBitDepth = standaloneSettings.getBitDepth();
int maxPossiblebitDepth = 0;
if ((maxPossiblebitDepth == 0) && (targetBitDepth >= 8)) {
if ((width * height) <= 60000) {
maxPossiblebitDepth = 8;
}