public EncodedImage adaptImage( EncodedImage downloadedImage, EncodedImage placeholderImage) { if (downloadedImage.getWidth() != placeholderImage.getWidth() || downloadedImage.getHeight() != placeholderImage.getHeight()) { throw new RuntimeException("Invalid image size"); } return downloadedImage; }
public EncodedImage adaptImage( EncodedImage downloadedImage, EncodedImage placeholderImage) { if (downloadedImage.getWidth() != placeholderImage.getWidth() || downloadedImage.getHeight() != placeholderImage.getHeight()) { return downloadedImage.scaledEncoded( placeholderImage.getWidth(), placeholderImage.getHeight()); } return downloadedImage; }
public EncodedImage adaptImage(EncodedImage downloadedImage, EncodedImage placeholderImage) { if (downloadedImage.getWidth() != placeholderImage.getWidth() || downloadedImage.getHeight() != placeholderImage.getHeight()) { Image tmp = downloadedImage .getInternal() .scaledLargerRatio(placeholderImage.getWidth(), placeholderImage.getHeight()); if (tmp.getWidth() > placeholderImage.getWidth()) { int diff = tmp.getWidth() - placeholderImage.getWidth(); int x = diff / 2; tmp = tmp.subImage( x, 0, Math.min(placeholderImage.getWidth(), tmp.getWidth()), Math.min(placeholderImage.getHeight(), tmp.getHeight()), true); } else { if (tmp.getHeight() > placeholderImage.getHeight()) { int diff = tmp.getHeight() - placeholderImage.getHeight(); int y = diff / 2; tmp = tmp.subImage( 0, y, Math.min(placeholderImage.getWidth(), tmp.getWidth()), Math.min(placeholderImage.getHeight(), tmp.getHeight()), true); } } tmp = postProcess(tmp); return EncodedImage.createFromImage(tmp, tmp.isOpaque()); } return downloadedImage; }
private URLImage( EncodedImage placeholder, String url, ImageAdapter adapter, String storageFile, String fileSystemFile) { super(placeholder.getWidth(), placeholder.getHeight()); this.placeholder = placeholder; this.url = url; this.adapter = adapter; this.storageFile = storageFile; this.fileSystemFile = fileSystemFile; }