Java 类com.facebook.imagepipeline.request.Postprocessor 实例源码

项目:GitHub    文件:DefaultCacheKeyFactory.java   
@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);
}
项目:GitHub    文件:PostprocessorProducer.java   
@Override
public void produceResults(
    final Consumer<CloseableReference<CloseableImage>> consumer,
    ProducerContext context) {
  final ProducerListener listener = context.getListener();
  final Postprocessor postprocessor = context.getImageRequest().getPostprocessor();
  final PostprocessorConsumer basePostprocessorConsumer =
      new PostprocessorConsumer(consumer, listener, context.getId(), postprocessor, context);
  final Consumer<CloseableReference<CloseableImage>> postprocessorConsumer;
  if (postprocessor instanceof RepeatedPostprocessor) {
    postprocessorConsumer = new RepeatedPostprocessorConsumer(
        basePostprocessorConsumer,
        (RepeatedPostprocessor) postprocessor,
        context);
  } else {
    postprocessorConsumer = new SingleUsePostprocessorConsumer(basePostprocessorConsumer);
  }
  mInputProducer.produceResults(postprocessorConsumer, context);
}
项目:GitHub    文件:PostprocessorProducer.java   
public PostprocessorConsumer(
    Consumer<CloseableReference<CloseableImage>> consumer,
    ProducerListener listener,
    String requestId,
    Postprocessor postprocessor,
    ProducerContext producerContext) {
  super(consumer);
  mListener = listener;
  mRequestId = requestId;
  mPostprocessor = postprocessor;
  producerContext.addCallbacks(
      new BaseProducerContextCallbacks() {
        @Override
        public void onCancellationRequested() {
          maybeNotifyOnCancellation();
        }
      });
}
项目:GitHub    文件:PipelineUtil.java   
/**
 * Utility method which adds optional configuration to ImageRequest
 *
 * @param imageRequestBuilder The Builder for ImageRequest
 * @param config              The Config
 */
public static void addOptionalFeatures(ImageRequestBuilder imageRequestBuilder, Config config) {
  if (config.usePostprocessor) {
    final Postprocessor postprocessor;
    switch (config.postprocessorType) {
      case "use_slow_postprocessor":
        postprocessor = DelayPostprocessor.getMediumPostprocessor();
        break;
      case "use_fast_postprocessor":
        postprocessor = DelayPostprocessor.getFastPostprocessor();
        break;
      default:
        postprocessor = DelayPostprocessor.getMediumPostprocessor();
    }
    imageRequestBuilder.setPostprocessor(postprocessor);
  }
  if (config.rotateUsingMetaData) {
    imageRequestBuilder.setRotationOptions(RotationOptions.autoRotateAtRenderTime());
  } else {
    imageRequestBuilder
        .setRotationOptions(RotationOptions.forceRotation(config.forcedRotationAngle));
  }
}
项目:cardinalsSample    文件:FrescoManager.java   
public void display(SimpleDraweeView view, String url, Postprocessor postprocessor) {
    if (!TextUtils.isEmpty(url)) {
        Uri uri;
        if (URLUtil.isNetworkUrl(url)) {
            uri = Uri.parse(url);
        } else {
            uri = Uri.fromFile(new File(url));
        }
        ImageRequest request = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setPostprocessor(postprocessor)
                .setProgressiveRenderingEnabled(true)
                //.setResizeOptions(new ResizeOptions(100, 100))
                .setLocalThumbnailPreviewsEnabled(true)
                .setRotationOptions(RotationOptions.autoRotateAtRenderTime())
                .build();

        controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(request)
                .setOldController(view.getController())
                .build();
        view.setController(controller);

    }

}
项目:ModuleFrame    文件:DefaultCacheKeyFactory.java   
@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);
}
项目:FrescoCustomCacheKey    文件:LJCacheKeyFactory.java   
@Override
public CacheKey getPostprocessedBitmapCacheKey(ImageRequest request, Object callerContext) {
    if (request instanceof LJImageRequest) {
        LJImageRequest ljImageRequest = (LJImageRequest) request;
        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(getCacheKey(ljImageRequest), ljImageRequest
                .getResizeOptions(), ljImageRequest
                .getRotationOptions(), ljImageRequest
                .getImageDecodeOptions(), postprocessorCacheKey, postprocessorName, callerContext);
    }
    return super.getPostprocessedBitmapCacheKey(request, callerContext);
}
项目:fresco    文件:DefaultCacheKeyFactory.java   
@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);
}
项目:fresco    文件:PostprocessorProducer.java   
@Override
public void produceResults(
    final Consumer<CloseableReference<CloseableImage>> consumer,
    ProducerContext context) {
  final ProducerListener listener = context.getListener();
  final Postprocessor postprocessor = context.getImageRequest().getPostprocessor();
  final PostprocessorConsumer basePostprocessorConsumer =
      new PostprocessorConsumer(consumer, listener, context.getId(), postprocessor, context);
  final Consumer<CloseableReference<CloseableImage>> postprocessorConsumer;
  if (postprocessor instanceof RepeatedPostprocessor) {
    postprocessorConsumer = new RepeatedPostprocessorConsumer(
        basePostprocessorConsumer,
        (RepeatedPostprocessor) postprocessor,
        context);
  } else {
    postprocessorConsumer = new SingleUsePostprocessorConsumer(basePostprocessorConsumer);
  }
  mInputProducer.produceResults(postprocessorConsumer, context);
}
项目:fresco    文件:PostprocessorProducer.java   
public PostprocessorConsumer(
    Consumer<CloseableReference<CloseableImage>> consumer,
    ProducerListener listener,
    String requestId,
    Postprocessor postprocessor,
    ProducerContext producerContext) {
  super(consumer);
  mListener = listener;
  mRequestId = requestId;
  mPostprocessor = postprocessor;
  producerContext.addCallbacks(
      new BaseProducerContextCallbacks() {
        @Override
        public void onCancellationRequested() {
          maybeNotifyOnCancellation();
        }
      });
}
项目:fresco    文件:PipelineUtil.java   
/**
 * Utility method which adds optional configuration to ImageRequest
 *
 * @param imageRequestBuilder The Builder for ImageRequest
 * @param config              The Config
 */
public static void addOptionalFeatures(ImageRequestBuilder imageRequestBuilder, Config config) {
  if (config.usePostprocessor) {
    final Postprocessor postprocessor;
    switch (config.postprocessorType) {
      case "use_slow_postprocessor":
        postprocessor = DelayPostprocessor.getMediumPostprocessor();
        break;
      case "use_fast_postprocessor":
        postprocessor = DelayPostprocessor.getFastPostprocessor();
        break;
      default:
        postprocessor = DelayPostprocessor.getMediumPostprocessor();
    }
    imageRequestBuilder.setPostprocessor(postprocessor);
  }
  if (config.rotateUsingMetaData) {
    imageRequestBuilder.setRotationOptions(RotationOptions.autoRotateAtRenderTime());
  } else {
    imageRequestBuilder
        .setRotationOptions(RotationOptions.forceRotation(config.forcedRotationAngle));
  }
}
项目:GitHub    文件:PostprocessorProducer.java   
private Map<String, String> getExtraMap(
    ProducerListener listener,
    String requestId,
    Postprocessor postprocessor) {
  if (!listener.requiresExtraMap(requestId)) {
    return null;
  }
  return ImmutableMap.of(POSTPROCESSOR, postprocessor.getName());
}
项目:GitHub    文件:ImagePipelinePostProcessorFragment.java   
private void setPostprocessor(Postprocessor postprocessor) {
  final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
      .setPostprocessor(postprocessor)
      .build();

  final DraweeController draweeController = Fresco.newDraweeControllerBuilder()
      .setOldController(mDraweeMain.getController())
      .setImageRequest(imageRequest)
      .build();

  mDraweeMain.setController(draweeController);
}
项目:cardinalsSample    文件:FrescoManager.java   
public void display(SimpleDraweeView view, @DrawableRes int resId, Postprocessor postprocessor) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithResourceId(resId)
            .setPostprocessor(postprocessor).setProgressiveRenderingEnabled(true)
            .build();
    controller = Fresco.newDraweeControllerBuilder().setImageRequest(request)
            .setOldController(view.getController())
            .setAutoPlayAnimations(true)
            .build();
    view.setController(controller);
}
项目:WhiteRead    文件:TngouFragment.java   
@Override
public void convert(final BaseViewHolder holder, final TngouModel.TngouBean tngouBean, final int position) {
    super.convert(holder, tngouBean, position);

    final SimpleDraweeView mImage = holder.getView(R.id.mImage);
    final String url = RequestServiceTngou.ImageHear + tngouBean.img;

    Uri uri = Uri.parse(url);
    Postprocessor redMeshPostprocessor = new BasePostprocessor() {
        @Override
        public String getName() {
            return url;
        }

        @Override
        public void process(Bitmap bitmap) {
            if (imageHeights.get(url + "height") == null) {
                imageHeights.put(url + "height", UtilsDynamicSize.defaultDisplayWidth / 3 * bitmap.getHeight() / bitmap.getWidth());
                imageHeights.put(url + "width", UtilsDynamicSize.defaultDisplayWidth / 3);
            }

            mImage.getLayoutParams().height = imageHeights.get(url + "height");
            mImage.getLayoutParams().width = imageHeights.get(url + "width");
        }
    };

    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
            .setPostprocessor(redMeshPostprocessor)
            .build();

    PipelineDraweeController controller = (PipelineDraweeController)
            Fresco.newDraweeControllerBuilder()
                    .setImageRequest(request)
                    .setOldController(mImage.getController())
                    // other setters as you need
                    .build();
    mImage.setController(controller);
}
项目:WhiteRead    文件:MzituFragment.java   
@Override
public void convert(final BaseViewHolder holder, final MzituModel bean, final int position) {
    super.convert(holder, bean, position);

    final SimpleDraweeView mImage = holder.getView(R.id.mImage);
    final String url = bean.imagePath;

    Uri uri = Uri.parse(url);
    Postprocessor redMeshPostprocessor = new BasePostprocessor() {
        @Override
        public String getName() {
            return url;
        }

        @Override
        public void process(Bitmap bitmap) {
            if (imageHeights.get(url + "height") == null) {
                imageHeights.put(url + "height", UtilsDynamicSize.defaultDisplayWidth / 3 * bitmap.getHeight() / bitmap.getWidth());
                imageHeights.put(url + "width", UtilsDynamicSize.defaultDisplayWidth / 3);
            }

            mImage.getLayoutParams().height = imageHeights.get(url + "height");
            mImage.getLayoutParams().width = imageHeights.get(url + "width");
        }
    };

    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
            .setPostprocessor(redMeshPostprocessor)
            .build();

    PipelineDraweeController controller = (PipelineDraweeController)
            Fresco.newDraweeControllerBuilder()
                    .setImageRequest(request)
                    .setOldController(mImage.getController())
                    // other setters as you need
                    .build();
    mImage.setController(controller);
}
项目:FrescoUtils    文件:FrescoHelper.java   
private static void init(FrescoImageView imageView, int cornerRadius, boolean isCircle, boolean isAnima,
                         Point size, Postprocessor postprocessor) {
    imageView.setAnim(isAnima);
    imageView.setCornerRadius(cornerRadius);
    imageView.setFadeTime(300);
    if (isCircle)
        imageView.asCircle();
    if (postprocessor != null)
        imageView.setPostProcessor(postprocessor);
    if (size != null) {
        imageView.setResize(size);
    }
}
项目:fresco    文件:PostprocessorProducer.java   
private Map<String, String> getExtraMap(
    ProducerListener listener,
    String requestId,
    Postprocessor postprocessor) {
  if (!listener.requiresExtraMap(requestId)) {
    return null;
  }
  return ImmutableMap.of(POSTPROCESSOR, postprocessor.getName());
}
项目:fresco    文件:ImagePipelinePostProcessorFragment.java   
private void setPostprocessor(Postprocessor postprocessor) {
  final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
      .setPostprocessor(postprocessor)
      .build();

  final DraweeController draweeController = Fresco.newDraweeControllerBuilder()
      .setOldController(mDraweeMain.getController())
      .setImageRequest(imageRequest)
      .build();

  mDraweeMain.setController(draweeController);
}
项目:GitHub    文件:PostprocessedBitmapMemoryCacheProducer.java   
@Override
public void produceResults(
    final Consumer<CloseableReference<CloseableImage>> consumer,
    final ProducerContext producerContext) {

  final ProducerListener listener = producerContext.getListener();
  final String requestId = producerContext.getId();
  final ImageRequest imageRequest = producerContext.getImageRequest();
  final Object callerContext = producerContext.getCallerContext();

  // If there's no postprocessor or the postprocessor doesn't require caching, forward results.
  final Postprocessor postprocessor = imageRequest.getPostprocessor();
  if (postprocessor == null || postprocessor.getPostprocessorCacheKey() == null) {
    mInputProducer.produceResults(consumer, producerContext);
    return;
  }
  listener.onProducerStart(requestId, getProducerName());
  final CacheKey cacheKey =
      mCacheKeyFactory.getPostprocessedBitmapCacheKey(imageRequest, callerContext);
  CloseableReference<CloseableImage> cachedReference = mMemoryCache.get(cacheKey);
  if (cachedReference != null) {
    listener.onProducerFinishWithSuccess(
        requestId,
        getProducerName(),
        listener.requiresExtraMap(requestId) ? ImmutableMap.of(VALUE_FOUND, "true") : null);
    listener.onUltimateProducerReached(requestId, PRODUCER_NAME, true);
    consumer.onProgressUpdate(1.0f);
    consumer.onNewResult(cachedReference, Consumer.IS_LAST);
    cachedReference.close();
  } else {
    final boolean isRepeatedProcessor = postprocessor instanceof RepeatedPostprocessor;
    Consumer<CloseableReference<CloseableImage>> cachedConsumer = new CachedPostprocessorConsumer(
        consumer,
        cacheKey,
        isRepeatedProcessor,
        mMemoryCache);
    listener.onProducerFinishWithSuccess(
        requestId,
        getProducerName(),
        listener.requiresExtraMap(requestId) ? ImmutableMap.of(VALUE_FOUND, "false") : null);
    mInputProducer.produceResults(cachedConsumer, producerContext);
  }
}
项目:GitHub    文件:ImagePipelinePostProcessorFragment.java   
Entry(int descriptionId, Postprocessor postprocessor) {
  this.descriptionId = descriptionId;
  this.postprocessor = postprocessor;
}
项目:CustomListView    文件:FrescoImageLoaderStrategy.java   
private ImageRequest buildRequest(ImageConfig config) {
    Uri uri = buildUriByType(config);

    ImageRequestBuilder builder =   ImageRequestBuilder.newBuilderWithSource(uri);
    Postprocessor postprocessor=null;


    ResizeOptions resizeOptions = getResizeOption(config);


    builder.setPostprocessor(postprocessor)
            .setResizeOptions(resizeOptions)//缩放,在解码前修改内存中的图片大小, 配合Downsampling可以处理所有图片,否则只能处理jpg,
            // 开启Downsampling:在初始化时设置.setDownsampleEnabled(true)
            .setAutoRotateEnabled(true);




    return builder.build();
}
项目:FinalProject    文件:FrescoImageView.java   
@Override
public Postprocessor getPostProcessor() {
    return this.mPostProcessor;
}
项目:FinalProject    文件:FrescoImageView.java   
@Override
public void setPostProcessor(Postprocessor postProcessor) {
    this.mPostProcessor = postProcessor;
}
项目:FinalProject    文件:FrescoZoomImageView.java   
@Override
public Postprocessor getPostProcessor() {
    return this.mPostProcessor;
}
项目:FinalProject    文件:FrescoZoomImageView.java   
@Override
public void setPostProcessor(Postprocessor postProcessor) {
    this.mPostProcessor = postProcessor;
}
项目:ReactNativeSignatureExample    文件:ReactImageView.java   
public void maybeUpdateView() {
  if (!mIsDirty) {
    return;
  }

  boolean doResize = shouldResize(mUri);
  if (doResize && (getWidth() <= 0 || getHeight() <=0)) {
    // If need a resize and the size is not yet set, wait until the layout pass provides one
    return;
  }

  GenericDraweeHierarchy hierarchy = getHierarchy();
  hierarchy.setActualImageScaleType(mScaleType);

  if (mLoadingImageDrawable != null) {
    hierarchy.setPlaceholderImage(mLoadingImageDrawable, ScalingUtils.ScaleType.CENTER);
  }

  boolean usePostprocessorScaling =
      mScaleType != ScalingUtils.ScaleType.CENTER_CROP &&
      mScaleType != ScalingUtils.ScaleType.FOCUS_CROP;
  float hierarchyRadius = usePostprocessorScaling ? 0 : mBorderRadius;

  RoundingParams roundingParams = hierarchy.getRoundingParams();
  roundingParams.setCornersRadius(hierarchyRadius);
  roundingParams.setBorder(mBorderColor, mBorderWidth);
  if (mOverlayColor != Color.TRANSPARENT) {
      roundingParams.setOverlayColor(mOverlayColor);
  } else {
      // make sure the default rounding method is used.
      roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
  }
  hierarchy.setRoundingParams(roundingParams);
  hierarchy.setFadeDuration(
      mFadeDurationMs >= 0
          ? mFadeDurationMs
          : mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS);

  Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null;

  ResizeOptions resizeOptions = doResize ? new ResizeOptions(getWidth(), getHeight()) : null;

  ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
      .setPostprocessor(postprocessor)
      .setResizeOptions(resizeOptions)
      .setAutoRotateEnabled(true)
      .setProgressiveRenderingEnabled(mProgressiveRenderingEnabled)
      .build();

  // This builder is reused
  mDraweeControllerBuilder.reset();

  mDraweeControllerBuilder
      .setAutoPlayAnimations(true)
      .setCallerContext(mCallerContext)
      .setOldController(getController())
      .setImageRequest(imageRequest);

  if (mControllerListener != null && mControllerForTesting != null) {
    ForwardingControllerListener combinedListener = new ForwardingControllerListener();
    combinedListener.addListener(mControllerListener);
    combinedListener.addListener(mControllerForTesting);
    mDraweeControllerBuilder.setControllerListener(combinedListener);
  } else if (mControllerForTesting != null) {
    mDraweeControllerBuilder.setControllerListener(mControllerForTesting);
  } else if (mControllerListener != null) {
    mDraweeControllerBuilder.setControllerListener(mControllerListener);
  }

  setController(mDraweeControllerBuilder.build());
  mIsDirty = false;
}
项目:react-native-ibeacon-android    文件:ReactImageView.java   
public void maybeUpdateView() {
  if (!mIsDirty) {
    return;
  }

  boolean doResize = shouldResize(mUri);
  if (doResize && (getWidth() <= 0 || getHeight() <=0)) {
    // If need a resize and the size is not yet set, wait until the layout pass provides one
    return;
  }

  GenericDraweeHierarchy hierarchy = getHierarchy();
  hierarchy.setActualImageScaleType(mScaleType);

  if (mLoadingImageDrawable != null) {
    hierarchy.setPlaceholderImage(mLoadingImageDrawable, ScalingUtils.ScaleType.CENTER);
  }

  boolean usePostprocessorScaling =
      mScaleType != ScalingUtils.ScaleType.CENTER_CROP &&
      mScaleType != ScalingUtils.ScaleType.FOCUS_CROP;
  float hierarchyRadius = usePostprocessorScaling ? 0 : mBorderRadius;

  RoundingParams roundingParams = hierarchy.getRoundingParams();
  roundingParams.setCornersRadius(hierarchyRadius);
  roundingParams.setBorder(mBorderColor, mBorderWidth);
  if (mOverlayColor != Color.TRANSPARENT) {
      roundingParams.setOverlayColor(mOverlayColor);
  } else {
      // make sure the default rounding method is used.
      roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
  }
  hierarchy.setRoundingParams(roundingParams);
  hierarchy.setFadeDuration(
      mFadeDurationMs >= 0
          ? mFadeDurationMs
          : mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS);

  Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null;

  ResizeOptions resizeOptions = doResize ? new ResizeOptions(getWidth(), getHeight()) : null;

  ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
      .setPostprocessor(postprocessor)
      .setResizeOptions(resizeOptions)
      .setAutoRotateEnabled(true)
      .setProgressiveRenderingEnabled(mProgressiveRenderingEnabled)
      .build();

  // This builder is reused
  mDraweeControllerBuilder.reset();

  mDraweeControllerBuilder
      .setAutoPlayAnimations(true)
      .setCallerContext(mCallerContext)
      .setOldController(getController())
      .setImageRequest(imageRequest);

  if (mControllerListener != null && mControllerForTesting != null) {
    ForwardingControllerListener combinedListener = new ForwardingControllerListener();
    combinedListener.addListener(mControllerListener);
    combinedListener.addListener(mControllerForTesting);
    mDraweeControllerBuilder.setControllerListener(combinedListener);
  } else if (mControllerForTesting != null) {
    mDraweeControllerBuilder.setControllerListener(mControllerForTesting);
  } else if (mControllerListener != null) {
    mDraweeControllerBuilder.setControllerListener(mControllerListener);
  }

  setController(mDraweeControllerBuilder.build());
  mIsDirty = false;
}
项目:react-native-box-loaders    文件:ReactImageView.java   
public void maybeUpdateView() {
  if (!mIsDirty) {
    return;
  }

  boolean doResize = shouldResize(mUri);
  if (doResize && (getWidth() <= 0 || getHeight() <=0)) {
    // If need a resize and the size is not yet set, wait until the layout pass provides one
    return;
  }

  GenericDraweeHierarchy hierarchy = getHierarchy();
  hierarchy.setActualImageScaleType(mScaleType);

  if (mLoadingImageDrawable != null) {
    hierarchy.setPlaceholderImage(mLoadingImageDrawable, ScalingUtils.ScaleType.CENTER);
  }

  boolean usePostprocessorScaling =
      mScaleType != ScalingUtils.ScaleType.CENTER_CROP &&
      mScaleType != ScalingUtils.ScaleType.FOCUS_CROP;

  RoundingParams roundingParams = hierarchy.getRoundingParams();

  if (usePostprocessorScaling) {
    roundingParams.setCornersRadius(0);
  } else {
    cornerRadii(sComputedCornerRadii);

    roundingParams.setCornersRadii(sComputedCornerRadii[0], sComputedCornerRadii[1], sComputedCornerRadii[2], sComputedCornerRadii[3]);
  }

  roundingParams.setBorder(mBorderColor, mBorderWidth);
  if (mOverlayColor != Color.TRANSPARENT) {
      roundingParams.setOverlayColor(mOverlayColor);
  } else {
      // make sure the default rounding method is used.
      roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
  }
  hierarchy.setRoundingParams(roundingParams);
  hierarchy.setFadeDuration(
      mFadeDurationMs >= 0
          ? mFadeDurationMs
          : mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS);

  Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null;

  ResizeOptions resizeOptions = doResize ? new ResizeOptions(getWidth(), getHeight()) : null;

  ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
      .setPostprocessor(postprocessor)
      .setResizeOptions(resizeOptions)
      .setAutoRotateEnabled(true)
      .setProgressiveRenderingEnabled(mProgressiveRenderingEnabled)
      .build();

  // This builder is reused
  mDraweeControllerBuilder.reset();

  mDraweeControllerBuilder
      .setAutoPlayAnimations(true)
      .setCallerContext(mCallerContext)
      .setOldController(getController())
      .setImageRequest(imageRequest);

  if (mControllerListener != null && mControllerForTesting != null) {
    ForwardingControllerListener combinedListener = new ForwardingControllerListener();
    combinedListener.addListener(mControllerListener);
    combinedListener.addListener(mControllerForTesting);
    mDraweeControllerBuilder.setControllerListener(combinedListener);
  } else if (mControllerForTesting != null) {
    mDraweeControllerBuilder.setControllerListener(mControllerForTesting);
  } else if (mControllerListener != null) {
    mDraweeControllerBuilder.setControllerListener(mControllerListener);
  }

  setController(mDraweeControllerBuilder.build());
  mIsDirty = false;
}
项目:FrescoPlus    文件:FrescoPlusFetcher.java   
public Builder withPostprocessor(Postprocessor val) {
    postprocessor = val;
    return this;
}
项目:react-native-imagewand    文件:RNImageWand.java   
public void maybeUpdateView() {
        if (!mIsDirty) {
            return;
        }

        boolean doResize = shouldResize(mUri);
        if (doResize && (getWidth() <= 0 || getHeight() <=0)) {
            // If need a resize and the size is not yet set, wait until the layout pass provides one
            return;
        }

        GenericDraweeHierarchy hierarchy = getHierarchy();
        hierarchy.setActualImageScaleType(mScaleType);

        if (mLoadingImageDrawable != null) {
//            hierarchy.setPlaceholderImage(mLoadingImageDrawable, ScalingUtils.ScaleType.CENTER);
        }

        boolean usePostprocessorScaling =
                mScaleType != ScalingUtils.ScaleType.CENTER_CROP &&
                        mScaleType != ScalingUtils.ScaleType.FOCUS_CROP;
        float hierarchyRadius = usePostprocessorScaling ? 0 : mBorderRadius;

        RoundingParams roundingParams = hierarchy.getRoundingParams();
        roundingParams.setCornersRadius(hierarchyRadius);
        roundingParams.setBorder(mBorderColor, mBorderWidth);
        hierarchy.setRoundingParams(roundingParams);
        hierarchy.setFadeDuration(
                mFadeDurationMs >= 0
                        ? mFadeDurationMs
                        : mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS);

        Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null;
        Postprocessor redMeshPostprocessor = new redMeshPostprocessor();

        ResizeOptions resizeOptions = doResize ? new ResizeOptions(getWidth(), getHeight()) : null;

        ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
                .setPostprocessor(redMeshPostprocessor)
                .setResizeOptions(resizeOptions)
                .setAutoRotateEnabled(true)
                .setProgressiveRenderingEnabled(mProgressiveRenderingEnabled)
                .build();

        // This builder is reused
        mDraweeControllerBuilder.reset();

        mDraweeControllerBuilder
                .setAutoPlayAnimations(true)
                .setCallerContext(mCallerContext)
                .setOldController(getController())
                .setImageRequest(imageRequest);

        if (mControllerListener != null && mControllerForTesting != null) {
            ForwardingControllerListener combinedListener = new ForwardingControllerListener();
            combinedListener.addListener(mControllerListener);
            combinedListener.addListener(mControllerForTesting);
            mDraweeControllerBuilder.setControllerListener(combinedListener);
        } else if (mControllerForTesting != null) {
            mDraweeControllerBuilder.setControllerListener(mControllerForTesting);
        } else if (mControllerListener != null) {
            mDraweeControllerBuilder.setControllerListener(mControllerListener);
        }

        setController(mDraweeControllerBuilder.build());
        mIsDirty = false;
    }
项目:FrescoUtils    文件:LoadOption.java   
public LoadOption setPostprocessor(Postprocessor postprocessor) {
    this.postprocessor = postprocessor;
    return this;
}
项目:FrescoUtils    文件:FrescoHelper.java   
public static void loadFrescoImage(FrescoImageView imageView, String uri, int defaultImg, boolean loadLocalPath, Postprocessor postprocessor) {
    loadFrescoImage(imageView, uri, defaultImg, 0, false, loadLocalPath, true, null, postprocessor);
}
项目:FrescoUtils    文件:FrescoHelper.java   
public static void loadFrescoImage(FrescoImageView imageView, String uri, int defaultImg, boolean loadLocalPath, Point point, Postprocessor postprocessor) {
    loadFrescoImage(imageView, uri, defaultImg, 0, false, loadLocalPath, true, point, postprocessor);
}
项目:FrescoUtils    文件:FrescoHelper.java   
public static void loadFrescoImage(FrescoImageView imageView, String uri, int defaultImg, int radius, boolean loadLocalPath, Point point, Postprocessor postprocessor) {
    loadFrescoImage(imageView, uri, defaultImg, radius, false, loadLocalPath, true, point, postprocessor);
}
项目:FrescoUtils    文件:FrescoImageView.java   
@Override
public Postprocessor getPostProcessor() {
    return this.mPostProcessor;
}
项目:FrescoUtils    文件:FrescoImageView.java   
@Override
public void setPostProcessor(Postprocessor postProcessor) {
    this.mPostProcessor = postProcessor;
}
项目:FrescoUtils    文件:FrescoZoomImageView.java   
@Override
public Postprocessor getPostProcessor() {
    return this.mPostProcessor;
}
项目:FrescoUtils    文件:FrescoZoomImageView.java   
@Override
public void setPostProcessor(Postprocessor postProcessor) {
    this.mPostProcessor = postProcessor;
}
项目:zSMTH-Android    文件:WrapContentDraweeView.java   
@Override public void setImageURI(Uri uri, Object callerContext) {
  // http://frescolib.org/docs/modifying-image.html
  // this post process will do two things: 1. resize if image width is too large; 2. split if image height is too large
  Postprocessor postProcessor = new BasePostprocessor() {
    @Override public String getName() {
      return "SplitLongImagePostProcessor";
    }

    @Override public CloseableReference<Bitmap> process(Bitmap sourceBitmap, PlatformBitmapFactory bitmapFactory) {
      CloseableReference<Bitmap> bitmapRef = null;

      try {
        // resize image if its width is too large: > windowWidth * 1.5
        double ratio = 1.0;
        if (sourceBitmap.getWidth() >= WindowWidth * 1.5) {
          ratio = (double) WindowWidth / sourceBitmap.getWidth();
        }
        bitmapRef = bitmapFactory.createBitmap((int) (sourceBitmap.getWidth() * ratio), (int) (sourceBitmap.getHeight() * ratio));

        Bitmap destBitmap = bitmapRef.get();
        Canvas canvas = new Canvas(destBitmap);
        Rect destRect = new Rect(0, 0, destBitmap.getWidth(), destBitmap.getHeight());
        canvas.drawBitmap(sourceBitmap, null, destRect, paint);

        // split images if its height is too large: > OpenGL max Height
        try {
          int imageTotalHeight = destBitmap.getHeight();
          double imageAspectRatio = destBitmap.getWidth() / (double) WindowWidth;
          int imageMaxAllowedHeight;
          if (imageAspectRatio < 1) {
            imageMaxAllowedHeight = (int) (ImageUtils.getMaxHeight() * imageAspectRatio) - 5;
          } else {
            imageMaxAllowedHeight = ImageUtils.getMaxHeight() - 5;
          }
          int imageCount = getTimes(imageTotalHeight, imageMaxAllowedHeight);
          //                        Log.d(TAG, "process: h = " + imageTotalHeight + " w = " + destBitmap.getWidth() + " allowed: " + imageMaxAllowedHeight + " count: " + imageCount);
          if (imageCount > 1) {
            bmps = new ArrayList<Bitmap>();
            Rect bsrc = new Rect();

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            destBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            InputStream isBm = new ByteArrayInputStream(baos.toByteArray());
            BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(isBm, true);
            for (int i = 0; i < imageCount; i++) {
              bsrc.left = 0;
              bsrc.top = i * imageMaxAllowedHeight;
              bsrc.right = destBitmap.getWidth();
              bsrc.bottom = Math.min(bsrc.top + imageMaxAllowedHeight, imageTotalHeight);
              Bitmap bmp = decoder.decodeRegion(bsrc, null);
              bmps.add(bmp);
            }
          }
        } catch (Exception e) {
          Log.e(TAG, Log.getStackTraceString(e));
        }
        return CloseableReference.cloneOrNull(bitmapRef);
      } finally {
        CloseableReference.closeSafely(bitmapRef);
      }
    }
  };

  ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setAutoRotateEnabled(true)
      // this will reduce image's size if it's wider than screen width
      //                .setResizeOptions(new ResizeOptions(WindowWidth, Integer.MAX_VALUE))
      .setPostprocessor(postProcessor).build();

  DraweeController controller = ((PipelineDraweeControllerBuilder) getControllerBuilder()).setImageRequest(request)
      .setControllerListener(listener)
      .setCallerContext(callerContext)
      .setAutoPlayAnimations(true)
      .setOldController(getController())
      .build();
  setController(controller);
}