本文整理汇总了Java中com.facebook.imagepipeline.request.ImageRequest.getResizeOptions方法的典型用法代码示例。如果您正苦于以下问题:Java ImageRequest.getResizeOptions方法的具体用法?Java ImageRequest.getResizeOptions怎么用?Java ImageRequest.getResizeOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.imagepipeline.request.ImageRequest
的用法示例。
在下文中一共展示了ImageRequest.getResizeOptions方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPostprocessedBitmapCacheKey
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
@Override
public CacheKey getPostprocessedBitmapCacheKey(ImageRequest request, Object callerContext) {
final Postprocessor postprocessor = request.getPostprocessor();
final CacheKey postprocessorCacheKey;
final String postprocessorName;
if (postprocessor != null) {
postprocessorCacheKey = postprocessor.getPostprocessorCacheKey();
postprocessorName = postprocessor.getClass().getName();
} else {
postprocessorCacheKey = null;
postprocessorName = null;
}
return new BitmapMemoryCacheKey(
getCacheKeySourceUri(request.getSourceUri()).toString(),
request.getResizeOptions(),
request.getRotationOptions(),
request.getImageDecodeOptions(),
postprocessorCacheKey,
postprocessorName,
callerContext);
}
示例2: getPostprocessedBitmapCacheKey
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
@Override
public CacheKey getPostprocessedBitmapCacheKey(ImageRequest request, Object callerContext) {
final Postprocessor postprocessor = request.getPostprocessor();
final CacheKey postprocessorCacheKey;
final String postprocessorName;
if (postprocessor != null) {
postprocessorCacheKey = postprocessor.getPostprocessorCacheKey();
postprocessorName = postprocessor.getClass().getName();
} else {
postprocessorCacheKey = null;
postprocessorName = null;
}
return new BitmapMemoryCacheKey(
getCacheKeySourceUri(request.getSourceUri()),
request.getResizeOptions(),
request.getRotationOptions(),
request.getImageDecodeOptions(),
postprocessorCacheKey,
postprocessorName,
callerContext);
}
示例3: getBitmapCacheKey
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
@Override
public CacheKey getBitmapCacheKey(ImageRequest request, Object callerContext) {
return new BitmapMemoryCacheKey(
getCacheKeySourceUri(request.getSourceUri()).toString(),
request.getResizeOptions(),
request.getRotationOptions(),
request.getImageDecodeOptions(),
null,
null,
callerContext);
}
示例4: getExtraMap
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
private Map<String, String> getExtraMap(
EncodedImage encodedImage,
ImageRequest imageRequest,
int numerator,
int downsampleNumerator,
int softwareNumerator,
int rotationAngle) {
if (!mProducerContext.getListener().requiresExtraMap(mProducerContext.getId())) {
return null;
}
String originalSize = encodedImage.getWidth() + "x" + encodedImage.getHeight();
String requestedSize;
if (imageRequest.getResizeOptions() != null) {
requestedSize =
imageRequest.getResizeOptions().width + "x" + imageRequest.getResizeOptions().height;
} else {
requestedSize = "Unspecified";
}
String fraction = numerator > 0 ? numerator + "/8" : "";
final Map<String, String> map = new HashMap<>();
map.put(ORIGINAL_SIZE_KEY, originalSize);
map.put(REQUESTED_SIZE_KEY, requestedSize);
map.put(FRACTION_KEY, fraction);
map.put(JobScheduler.QUEUE_TIME_KEY, String.valueOf(mJobScheduler.getQueuedTime()));
map.put(DOWNSAMPLE_ENUMERATOR_KEY, Integer.toString(downsampleNumerator));
map.put(SOFTWARE_ENUMERATOR_KEY, Integer.toString(softwareNumerator));
map.put(ROTATION_ANGLE_KEY, Integer.toString(rotationAngle));
return ImmutableMap.copyOf(map);
}
示例5: getSoftwareNumerator
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
private static int getSoftwareNumerator(
ImageRequest imageRequest,
EncodedImage encodedImage,
boolean resizingEnabled) {
if (!resizingEnabled) {
return JpegTranscoder.SCALE_DENOMINATOR;
}
final ResizeOptions resizeOptions = imageRequest.getResizeOptions();
if (resizeOptions == null) {
return JpegTranscoder.SCALE_DENOMINATOR;
}
final int rotationAngle = getRotationAngle(imageRequest.getRotationOptions(), encodedImage);
int exifOrientation = ExifInterface.ORIENTATION_UNDEFINED;
if (INVERTED_EXIF_ORIENTATIONS.contains(encodedImage.getExifOrientation())) {
exifOrientation =
getForceRotatedInvertedExifOrientation(imageRequest.getRotationOptions(), encodedImage);
}
final boolean swapDimensions =
rotationAngle == 90
|| rotationAngle == 270
|| exifOrientation == ExifInterface.ORIENTATION_TRANSPOSE
|| exifOrientation == ExifInterface.ORIENTATION_TRANSVERSE;
final int widthAfterRotation = swapDimensions ? encodedImage.getHeight() :
encodedImage.getWidth();
final int heightAfterRotation = swapDimensions ? encodedImage.getWidth() :
encodedImage.getHeight();
float ratio = determineResizeRatio(resizeOptions, widthAfterRotation, heightAfterRotation);
int numerator = roundNumerator(ratio, resizeOptions.roundUpFraction);
if (numerator > MAX_JPEG_SCALE_NUMERATOR) {
return MAX_JPEG_SCALE_NUMERATOR;
}
return (numerator < 1) ? 1 : numerator;
}
示例6: determineSampleSize
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
/**
* Get the factor between the dimensions of the encodedImage (actual image) and the ones of the
* imageRequest (requested size).
*
* @param imageRequest the request containing the requested dimensions
* @param encodedImage the encoded image with the actual dimensions
* @return
*/
public static int determineSampleSize(ImageRequest imageRequest, EncodedImage encodedImage) {
if (!EncodedImage.isMetaDataAvailable(encodedImage)) {
return DEFAULT_SAMPLE_SIZE;
}
float ratio = determineDownsampleRatio(imageRequest, encodedImage);
int sampleSize;
if (encodedImage.getImageFormat() == DefaultImageFormats.JPEG) {
sampleSize = ratioToSampleSizeJPEG(ratio);
} else {
sampleSize = ratioToSampleSize(ratio);
}
// Check the case when the dimension of the downsampled image is still larger than the max
// possible dimension for an image.
int maxDimension = Math.max(encodedImage.getHeight(), encodedImage.getWidth());
final ResizeOptions resizeOptions = imageRequest.getResizeOptions();
final float maxBitmapSize = resizeOptions != null
? resizeOptions.maxBitmapSize
: BitmapUtil.MAX_BITMAP_SIZE;
while (maxDimension / sampleSize > maxBitmapSize) {
if (encodedImage.getImageFormat() == DefaultImageFormats.JPEG) {
sampleSize *= 2;
} else {
sampleSize++;
}
}
return sampleSize;
}
示例7: determineDownsampleRatio
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
@VisibleForTesting
static float determineDownsampleRatio(
ImageRequest imageRequest, EncodedImage encodedImage) {
Preconditions.checkArgument(EncodedImage.isMetaDataAvailable(encodedImage));
final ResizeOptions resizeOptions = imageRequest.getResizeOptions();
if (resizeOptions == null || resizeOptions.height <= 0 || resizeOptions.width <= 0
|| encodedImage.getWidth() == 0 || encodedImage.getHeight() == 0) {
return 1.0f;
}
final int rotationAngle = getRotationAngle(imageRequest, encodedImage);
final boolean swapDimensions = rotationAngle == 90 || rotationAngle == 270;
final int widthAfterRotation = swapDimensions ?
encodedImage.getHeight() : encodedImage.getWidth();
final int heightAfterRotation = swapDimensions ?
encodedImage.getWidth() : encodedImage.getHeight();
final float widthRatio = ((float) resizeOptions.width) / widthAfterRotation;
final float heightRatio = ((float) resizeOptions.height) / heightAfterRotation;
float ratio = Math.max(widthRatio, heightRatio);
FLog.v(
"DownsampleUtil",
"Downsample - Specified size: %dx%d, image size: %dx%d " +
"ratio: %.1f x %.1f, ratio: %.3f for %s",
resizeOptions.width,
resizeOptions.height,
widthAfterRotation,
heightAfterRotation,
widthRatio,
heightRatio,
ratio,
imageRequest.getSourceUri().toString());
return ratio;
}
示例8: fetchEncodedImage
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
/**
* Submits a request for execution and returns a DataSource representing the pending encoded
* image(s).
*
* <p> The ResizeOptions in the imageRequest will be ignored for this fetch
*
* <p>The returned DataSource must be closed once the client has finished with it.
*
* @param imageRequest the request to submit
* @return a DataSource representing the pending encoded image(s)
*/
public DataSource<CloseableReference<PooledByteBuffer>> fetchEncodedImage(
ImageRequest imageRequest,
Object callerContext) {
Preconditions.checkNotNull(imageRequest.getSourceUri());
try {
Producer<CloseableReference<PooledByteBuffer>> producerSequence =
mProducerSequenceFactory.getEncodedImageProducerSequence(imageRequest);
// The resize options are used to determine whether images are going to be downsampled during
// decode or not. For the case where the image has to be downsampled and it's a local image it
// will be kept as a FileInputStream until decoding instead of reading it in memory. Since
// this method returns an encoded image, it should always be read into memory. Therefore, the
// resize options are ignored to avoid treating the image as if it was to be downsampled
// during decode.
if (imageRequest.getResizeOptions() != null) {
imageRequest = ImageRequestBuilder.fromRequest(imageRequest)
.setResizeOptions(null)
.build();
}
return submitFetchRequest(
producerSequence,
imageRequest,
ImageRequest.RequestLevel.FULL_FETCH,
callerContext);
} catch (Exception exception) {
return DataSources.immediateFailedDataSource(exception);
}
}
示例9: getBitmapCacheKey
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
@Override
public CacheKey getBitmapCacheKey(ImageRequest request, Object callerContext) {
return new BitmapMemoryCacheKey(
getCacheKeySourceUri(request.getSourceUri()),
request.getResizeOptions(),
request.getRotationOptions(),
request.getImageDecodeOptions(),
null,
null,
callerContext);
}
示例10: produceResults
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
public void produceResults(
final Consumer<EncodedImage> consumer,
final ProducerContext producerContext) {
final ImageRequest imageRequest = producerContext.getImageRequest();
final ResizeOptions resizeOptions = imageRequest.getResizeOptions();
final MediaVariations mediaVariations = imageRequest.getMediaVariations();
if (!imageRequest.isDiskCacheEnabled() ||
resizeOptions == null ||
resizeOptions.height <= 0 ||
resizeOptions.width <= 0 ||
imageRequest.getBytesRange() != null) {
startInputProducerWithExistingConsumer(consumer, producerContext);
return;
}
if (mediaVariations == null) {
startInputProducerWithExistingConsumer(consumer, producerContext);
return;
}
producerContext.getListener().onProducerStart(producerContext.getId(), PRODUCER_NAME);
final AtomicBoolean isCancelled = new AtomicBoolean(false);
if (mediaVariations.getVariantsCount() > 0) {
chooseFromVariants(
consumer,
producerContext,
imageRequest,
mediaVariations,
resizeOptions,
isCancelled);
} else {
MediaVariations.Builder mediaVariationsBuilder =
MediaVariations.newBuilderForMediaId(mediaVariations.getMediaId())
.setForceRequestForSpecifiedUri(mediaVariations.shouldForceRequestForSpecifiedUri())
.setSource(MediaVariations.SOURCE_INDEX_DB);
Task<MediaVariations> indexedMediaVariationsTask =
mMediaVariationsIndex.getCachedVariants(
mediaVariations.getMediaId(), mediaVariationsBuilder);
indexedMediaVariationsTask.continueWith(
new Continuation<MediaVariations, Object>() {
@Override
public Object then(Task<MediaVariations> task) throws Exception {
if (task.isCancelled() || task.isFaulted()) {
return task;
} else {
try {
if (task.getResult() == null) {
startInputProducerWithWrappedConsumer(
consumer, producerContext, mediaVariations.getMediaId());
return null;
} else {
return chooseFromVariants(
consumer,
producerContext,
imageRequest,
task.getResult(),
resizeOptions,
isCancelled);
}
} catch (Exception e) {
return null;
}
}
}
});
}
subscribeTaskForRequestCancellation(isCancelled, producerContext);
}