1,有弧度图片样式
fresco=加载自定义弧度图片样式。这就涉及到刚才介绍的DraweeHierarchy,其有一个属性是setRoundingParams(roundingParams); 参数就是图片的弧度,可以自己进行定义:
/**
* rounded corner params
* fromCornersRadius(float radius) 设置圆角半径
* fromCornersRadii(float[] radii) 分别设置左上角、右上角、左下角、右下角圆角半径
* fromCornersRadii(float topLeft, float topRight, float bottomRight, float bottomLeft) 分别设置左上角、右上角、左下角、右下角圆角半径
* setCornersRadius(float radius) 设置圆角半径
* setCornersRadii(float[] radii) 分别设置左上角、右上角、左下角、右下角圆角半径
* setCornersRadii(float topLeft, float topRight, float bottomRight, float bottomLeft) 分别设置左上角、右上角、左下角、右下角圆角半径
*/
public static RoundingParams getRoundingParams() {
RoundingParams roundingParams = RoundingParams.fromCornersRadius(30);
// roundingParams.asCircle();//圆形
// roundingParams.setBorder(color, width);//fresco:roundingBorderWidth="2dp"边框 fresco:roundingBorderColor="@color/border_color"
// roundingParams.setCornersRadii(radii);//半径
// roundingParams.setCornersRadii(topLeft, topRight, bottomRight, bottomLeft)//fresco:roundTopLeft="true" fresco:roundTopRight="false" fresco:roundBottomLeft="false" fresco:roundBottomRight="true"
// roundingParams. setCornersRadius(radius);//fresco:roundedCornerRadius="1dp"圆角
// roundingParams.setOverlayColor(overlayColor);//fresco:roundWithOverlayColor="@color/corner_color"
// roundingParams.setRoundAsCircle(roundAsCircle);//圆
// roundingParams.setRoundingMethod(roundingMethod);
// fresco:progressBarAutoRotateInterval="1000"自动旋转间隔
// 或用 fromCornersRadii 以及 asCircle 方法
return roundingParams;
}
如果图片是圆形就直接可以设置RoundingParams.asCircle();
以上roundingParams参数都是设置在DraweeHierarchy中,draweeHierarchy.setRoundingParams(roundingParams);这样就很方便加载多种样式的图片了。
2,图片解码
public static ImageDecodeOptions getImageDecodeOptions() {
ImageDecodeOptions decodeOptions = ImageDecodeOptions.newBuilder()
// .setBackgroundColor(Color.TRANSPARENT)//图片的背景颜色
// .setDecodeAllFrames(decodeAllFrames)//解码所有帧
// .setDecodePreviewFrame(decodePreviewFrame)//解码预览框
// .setForceOldAnimationCode(forceOldAnimationCode)//使用以前动画
// .setFrom(options)//使用已经存在的图像解码
// .setMinDecodeIntervalMs(intervalMs)//最小解码间隔(分位单位)
.setUseLastFrameForPreview(true)//使用最后一帧进行预览
.build();
return decodeOptions;
}