protected double getThumbnailDownsampleFactor(int maxWidth, int maxHeight) { if (maxWidth <= 0) { if (maxHeight <= 0) { maxWidth = 1024; maxHeight = 1024; } else { maxWidth = Integer.MAX_VALUE; } } else { if (maxHeight <= 0) { maxHeight = Integer.MAX_VALUE; } } double xDownsample = (double)getWidth() / maxWidth; double yDownsample = (double)getHeight() / maxHeight; double downsample = Math.max(xDownsample, yDownsample); if (downsample < 1) downsample = 1; return downsample; }
@Override public T getBufferedThumbnail(int maxWidth, int maxHeight, int zPosition) { double downsample = getThumbnailDownsampleFactor(maxWidth, maxHeight); return readBufferedImage( RegionRequest.createInstance(getPath(), downsample, 0, 0, getWidth(), getHeight(), zPosition, 0)); }