Java 类com.facebook.drawee.drawable.ScalingUtils.ScaleType 实例源码

项目:GitHub    文件:DraweeRoundedCornersFragment.java   
private void changeDraweeViewScaleType(
    SimpleDraweeView draweeView,
    ScaleType scaleType,
    @Nullable PointF focusPoint) {
  final GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
  hierarchy.setActualImageScaleType(scaleType);
  hierarchy.setActualImageFocusPoint(focusPoint != null ? focusPoint : new PointF(0.5f, 0.5f));

  final RoundingParams roundingParams = Preconditions.checkNotNull(hierarchy.getRoundingParams());
  if (BITMAP_ONLY_SCALETYPES.contains(scaleType)) {
    roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
  } else {
    roundingParams.setOverlayColor(mWindowBackgroundColor);
  }
  hierarchy.setRoundingParams(roundingParams);
}
项目:fresco    文件:DraweeRoundedCornersFragment.java   
private void changeDraweeViewScaleType(
    SimpleDraweeView draweeView,
    ScaleType scaleType,
    @Nullable PointF focusPoint) {
  final GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
  hierarchy.setActualImageScaleType(scaleType);
  hierarchy.setActualImageFocusPoint(focusPoint != null ? focusPoint : new PointF(0.5f, 0.5f));

  final RoundingParams roundingParams = Preconditions.checkNotNull(hierarchy.getRoundingParams());
  if (BITMAP_ONLY_SCALETYPES.contains(scaleType)) {
    roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
  } else {
    roundingParams.setOverlayColor(mWindowBackgroundColor);
  }
  hierarchy.setRoundingParams(roundingParams);
}
项目:GitHub    文件:PipelineDraweeController.java   
private void maybeUpdateDebugOverlay(@Nullable CloseableImage image) {
  if (!mDrawDebugOverlay) {
    return;
  }
  Drawable controllerOverlay = getControllerOverlay();

  if (controllerOverlay == null) {
    controllerOverlay = new DebugControllerOverlayDrawable();
    setControllerOverlay(controllerOverlay);
  }

  if (controllerOverlay instanceof DebugControllerOverlayDrawable) {
    DebugControllerOverlayDrawable debugOverlay =
        (DebugControllerOverlayDrawable) controllerOverlay;
    debugOverlay.setControllerId(getId());

    final DraweeHierarchy draweeHierarchy = getHierarchy();
    ScaleType scaleType = null;
    if (draweeHierarchy != null) {
      final ScaleTypeDrawable scaleTypeDrawable =
          ScalingUtils.getActiveScaleTypeDrawable(draweeHierarchy.getTopLevelDrawable());
      scaleType = scaleTypeDrawable != null ? scaleTypeDrawable.getScaleType() : null;
    }
    debugOverlay.setScaleType(scaleType);

    if (image != null) {
      debugOverlay.setDimensions(image.getWidth(), image.getHeight());
      debugOverlay.setImageSize(image.getSizeInBytes());
    } else {
      debugOverlay.reset();
    }
  }
}
项目:RNLearn_Project1    文件:RCTImageView.java   
@ReactProp(name = ViewProps.RESIZE_MODE)
public void setResizeMode(@Nullable String resizeMode) {
  ScaleType scaleType = ImageResizeMode.toScaleType(resizeMode);
  if (mDrawImage.getScaleType() != scaleType) {
    getMutableDrawImage().setScaleType(scaleType);
  }
}
项目:RNLearn_Project1    文件:RCTImageView.java   
@ReactProp(name = ViewProps.RESIZE_MODE)
public void setResizeMode(@Nullable String resizeMode) {
  ScaleType scaleType = ImageResizeMode.toScaleType(resizeMode);
  if (mDrawImage.getScaleType() != scaleType) {
    getMutableDrawImage().setScaleType(scaleType);
  }
}
项目:Li-MVPArms    文件:FrescoHelper.java   
/**
 * 图像选项类
 * @param resources Resources
 * @param isCircle 是否圆圈
 */
public static GenericDraweeHierarchy getImageViewHierarchy(Resources resources, boolean isCircle) {
    GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(resources);
    builder.setFailureImage(resources.getDrawable(R.drawable.defalut_avatar), ScaleType.FIT_XY);
    builder.setPlaceholderImage(resources.getDrawable(R.drawable.defalut_avatar));
    builder.setFadeDuration(300);
    if (isCircle) {
        RoundingParams circleParams = RoundingParams.asCircle();
        circleParams.setBorder(R.color.black_avart_magin, 1.0f);
        circleParams.setRoundAsCircle(true);
        builder.setRoundingParams(circleParams);
    }
    return builder.build();
}
项目:fresco    文件:PipelineDraweeController.java   
private void maybeUpdateDebugOverlay(@Nullable CloseableImage image) {
  if (!mDrawDebugOverlay) {
    return;
  }
  Drawable controllerOverlay = getControllerOverlay();

  if (controllerOverlay == null) {
    controllerOverlay = new DebugControllerOverlayDrawable();
    setControllerOverlay(controllerOverlay);
  }

  if (controllerOverlay instanceof DebugControllerOverlayDrawable) {
    DebugControllerOverlayDrawable debugOverlay =
        (DebugControllerOverlayDrawable) controllerOverlay;
    debugOverlay.setControllerId(getId());

    final DraweeHierarchy draweeHierarchy = getHierarchy();
    ScaleType scaleType = null;
    if (draweeHierarchy != null) {
      final ScaleTypeDrawable scaleTypeDrawable =
          ScalingUtils.getActiveScaleTypeDrawable(draweeHierarchy.getTopLevelDrawable());
      scaleType = scaleTypeDrawable != null ? scaleTypeDrawable.getScaleType() : null;
    }
    debugOverlay.setScaleType(scaleType);

    if (image != null) {
      debugOverlay.setDimensions(image.getWidth(), image.getHeight());
      debugOverlay.setImageSize(image.getSizeInBytes());
    } else {
      debugOverlay.reset();
    }
  }
}
项目:GitHub    文件:DebugControllerOverlayDrawable.java   
public void setScaleType(ScaleType scaleType) {
  mScaleType = scaleType;
}
项目:GitHub    文件:DebugControllerOverlayDrawable.java   
@VisibleForTesting
int determineOverlayColor(
    int imageWidth,
    int imageHeight,
    @Nullable ScaleType scaleType) {
  int visibleDrawnAreaWidth = getBounds().width();
  int visibleDrawnAreaHeight = getBounds().height();

  if (visibleDrawnAreaWidth <= 0 ||
      visibleDrawnAreaHeight <= 0 ||
      imageWidth <= 0 ||
      imageHeight <= 0) {
    return OVERLAY_COLOR_IMAGE_NOT_OK;
  }

  if (scaleType != null) {
    // Apply optional scale type in order to get boundaries of the actual area to be filled
    mRect.left = mRect.top = 0;
    mRect.right = visibleDrawnAreaWidth;
    mRect.bottom = visibleDrawnAreaHeight;

    mMatrix.reset();

    // We can ignore the focus point as it has no influence on the scale, but only the translation
    scaleType.getTransform(mMatrix, mRect, imageWidth, imageHeight, 0f, 0f);

    mRectF.left = mRectF.top = 0;
    mRectF.right = imageWidth;
    mRectF.bottom = imageHeight;

    mMatrix.mapRect(mRectF);

    final int drawnAreaWidth = (int) mRectF.width();
    final int drawnAreaHeight = (int) mRectF.height();

    visibleDrawnAreaWidth = Math.min(visibleDrawnAreaWidth, drawnAreaWidth);
    visibleDrawnAreaHeight = Math.min(visibleDrawnAreaHeight, drawnAreaHeight);
  }

  // Update the thresholds for the overlay color
  float scaledImageWidthThresholdOk = visibleDrawnAreaWidth * IMAGE_SIZE_THRESHOLD_OK;
  float scaledImageWidthThresholdNotOk = visibleDrawnAreaWidth * IMAGE_SIZE_THRESHOLD_NOT_OK;
  float scaledImageHeightThresholdOk = visibleDrawnAreaHeight * IMAGE_SIZE_THRESHOLD_OK;
  float scaledImageHeightThresholdNotOk = visibleDrawnAreaHeight * IMAGE_SIZE_THRESHOLD_NOT_OK;

  // Calculate the dimension differences
  int absWidthDifference = Math.abs(imageWidth - visibleDrawnAreaWidth);
  int absHeightDifference = Math.abs(imageHeight - visibleDrawnAreaHeight);

  // Return corresponding color
  if (absWidthDifference < scaledImageWidthThresholdOk &&
      absHeightDifference < scaledImageHeightThresholdOk) {
    return OVERLAY_COLOR_IMAGE_OK;
  } else if (absWidthDifference < scaledImageWidthThresholdNotOk &&
      absHeightDifference < scaledImageHeightThresholdNotOk) {
    return OVERLAY_COLOR_IMAGE_ALMOST_OK;
  }
  return OVERLAY_COLOR_IMAGE_NOT_OK;
}
项目:GitHub    文件:DraweeScaleTypeFragment.java   
private void changeMainDraweeScaleType(ScaleType scaleType, @Nullable PointF focusPoint) {
  final GenericDraweeHierarchy hierarchy = mDraweeMain.getHierarchy();
  hierarchy.setActualImageScaleType(scaleType);
  hierarchy.setActualImageFocusPoint(focusPoint != null ? focusPoint : new PointF(0.5f, 0.5f));
}
项目:RNLearn_Project1    文件:DrawImageWithDrawee.java   
@Override
public void setScaleType(ScaleType scaleType) {
  mScaleType = scaleType;
}
项目:RNLearn_Project1    文件:DrawImageWithDrawee.java   
@Override
public ScaleType getScaleType() {
  return mScaleType;
}
项目:RNLearn_Project1    文件:DrawImageWithDrawee.java   
@Override
public void setScaleType(ScaleType scaleType) {
  mScaleType = scaleType;
}
项目:RNLearn_Project1    文件:DrawImageWithDrawee.java   
@Override
public ScaleType getScaleType() {
  return mScaleType;
}
项目:fresco    文件:DebugControllerOverlayDrawable.java   
public void setScaleType(ScaleType scaleType) {
  mScaleType = scaleType;
}
项目:fresco    文件:DebugControllerOverlayDrawable.java   
@VisibleForTesting
int determineOverlayColor(
    int imageWidth,
    int imageHeight,
    @Nullable ScaleType scaleType) {
  int visibleDrawnAreaWidth = getBounds().width();
  int visibleDrawnAreaHeight = getBounds().height();

  if (visibleDrawnAreaWidth <= 0 ||
      visibleDrawnAreaHeight <= 0 ||
      imageWidth <= 0 ||
      imageHeight <= 0) {
    return OVERLAY_COLOR_IMAGE_NOT_OK;
  }

  if (scaleType != null) {
    // Apply optional scale type in order to get boundaries of the actual area to be filled
    mRect.left = mRect.top = 0;
    mRect.right = visibleDrawnAreaWidth;
    mRect.bottom = visibleDrawnAreaHeight;

    mMatrix.reset();

    // We can ignore the focus point as it has no influence on the scale, but only the translation
    scaleType.getTransform(mMatrix, mRect, imageWidth, imageHeight, 0f, 0f);

    mRectF.left = mRectF.top = 0;
    mRectF.right = imageWidth;
    mRectF.bottom = imageHeight;

    mMatrix.mapRect(mRectF);

    final int drawnAreaWidth = (int) mRectF.width();
    final int drawnAreaHeight = (int) mRectF.height();

    visibleDrawnAreaWidth = Math.min(visibleDrawnAreaWidth, drawnAreaWidth);
    visibleDrawnAreaHeight = Math.min(visibleDrawnAreaHeight, drawnAreaHeight);
  }

  // Update the thresholds for the overlay color
  float scaledImageWidthThresholdOk = visibleDrawnAreaWidth * IMAGE_SIZE_THRESHOLD_OK;
  float scaledImageWidthThresholdNotOk = visibleDrawnAreaWidth * IMAGE_SIZE_THRESHOLD_NOT_OK;
  float scaledImageHeightThresholdOk = visibleDrawnAreaHeight * IMAGE_SIZE_THRESHOLD_OK;
  float scaledImageHeightThresholdNotOk = visibleDrawnAreaHeight * IMAGE_SIZE_THRESHOLD_NOT_OK;

  // Calculate the dimension differences
  int absWidthDifference = Math.abs(imageWidth - visibleDrawnAreaWidth);
  int absHeightDifference = Math.abs(imageHeight - visibleDrawnAreaHeight);

  // Return corresponding color
  if (absWidthDifference < scaledImageWidthThresholdOk &&
      absHeightDifference < scaledImageHeightThresholdOk) {
    return OVERLAY_COLOR_IMAGE_OK;
  } else if (absWidthDifference < scaledImageWidthThresholdNotOk &&
      absHeightDifference < scaledImageHeightThresholdNotOk) {
    return OVERLAY_COLOR_IMAGE_ALMOST_OK;
  }
  return OVERLAY_COLOR_IMAGE_NOT_OK;
}
项目:fresco    文件:DraweeScaleTypeFragment.java   
private void changeMainDraweeScaleType(ScaleType scaleType, @Nullable PointF focusPoint) {
  final GenericDraweeHierarchy hierarchy = mDraweeMain.getHierarchy();
  hierarchy.setActualImageScaleType(scaleType);
  hierarchy.setActualImageFocusPoint(focusPoint != null ? focusPoint : new PointF(0.5f, 0.5f));
}
项目:RNLearn_Project1    文件:DrawImage.java   
/**
 * Assigns a scale type to draw to the image with.
 */
void setScaleType(ScaleType scaleType);
项目:RNLearn_Project1    文件:DrawImage.java   
/**
 * Returns a scale type to draw to the image with.
 */
ScaleType getScaleType();
项目:RNLearn_Project1    文件:DrawImage.java   
/**
 * Assigns a scale type to draw to the image with.
 */
void setScaleType(ScaleType scaleType);
项目:RNLearn_Project1    文件:DrawImage.java   
/**
 * Returns a scale type to draw to the image with.
 */
ScaleType getScaleType();