for (String url : imgUrls) { images.add(ImageIO.read(newURL(url))); }
// read all images into one multiresolution image MultiResolutionImagemultiResolutionImage= newBaseMultiResolutionImage(images.toArray(newImage[0]));
// get all variants of images List<Image> variants = multiResolutionImage.getResolutionVariants();
System.out.println("Total number of images: " + variants.size());
for (Image img : variants) { System.out.println(img); }
// get a resolution-specific image variant for each indicated size Imagevariant1= multiResolutionImage.getResolutionVariant(156, 45); System.out.printf("\nImage for destination[%d,%d]: [%d,%d]", 156, 45, variant1.getWidth(null), variant1.getHeight(null));
$ javac MultiResolutionTester.java && java MultiResolutionTester Total number of images: 3 BufferedImage@c267ef4: type = 6 ColorModel: #pixelBits = 32 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@32eff876 transparency = 3 has alpha = true isAlphaPre = false ByteInterleavedRaster: width = 32 height = 32 #numDataElements 4 dataOff[0] = 3 BufferedImage@9f116cc: type = 6 ColorModel: #pixelBits = 32 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@32eff876 transparency = 3 has alpha = true isAlphaPre = false ByteInterleavedRaster: width = 64 height = 64 #numDataElements 4 dataOff[0] = 3 BufferedImage@12468a38: type = 6 ColorModel: #pixelBits = 32 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@32eff876 transparency = 3 has alpha = true isAlphaPre = false ByteInterleavedRaster: width = 128 height = 128 #numDataElements 4 dataOff[0] = 3
Image for destination[156,45]: [128,128] Image for destination[311,89]: [128,128] Image for destination[622,178]: [128,128] Image for destination[300,300]: [128,128]