Fresco, yuvarlak görüntüler ve yuvarlak köşeler için yerleşik desteğe sahiptir, ancak elmas veya paralelkenar vb. Gibi diğer şekillere ne dersiniz?Android Fresco: Farklı türde resim şekilleri çizme
Standart ImageView ile, BitmapShader kullanan özel çekilebilir bağlantı ile yapılması basittir.
public class MaskDrawable extends Drawable {
private Paint mPaint;
private Path mPath;
private int mSlopeHeight;
public MaskDrawable(Bitmap bitmap, int slopeHeight) {
BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setShader(shader);
mSlopeHeight = slopeHeight;
mPath = new Path();
}
@Override
public void draw(Canvas canvas) {
Rect bounds = getBounds();
mPath.moveTo(0, 0);
mPath.lineTo(0, bounds.bottom);
mPath.lineTo(bounds.right, bounds.bottom - mSlopeHeight);
mPath.lineTo(bounds.right, 0);
canvas.drawPath(mPath, mPaint);
}
Fresco ile, ben görüntünün Bitmap gerektiğini yapmak için: Örneğin, aşağıdaki özel Drawable görüntü Bitmap ve bu resim gibi bir bir ImageView görünmesi için bir eğim yüksekliği alır ama bunu nasıl yapacağımı bilmiyorum. Bitmap'i doğrudan ImagePipeline'dan alabildiğimi okudum, fakat bununla birlikte gelen çok sayıda tuhaflık var. Bir durumda, döndürülmüş Bitmap kısa ömürlüdür ve diğer durumda, bana açık olmayan bir noktada serbest bırakmam gereken bir CloseableReference elde etmek için ekranda kullanılmamalıdır. Bunu henüz denemedim ve biri yerine bit ve bayt ben bir çalışma çözüm sağlayabilir acaba
ImagePipeline imagePipeline = Fresco.getImagePipeline();
ImageRequest imageRequest = ImageRequestBuilder
.newBuilderWithSource(uri)
.setRequestPriority(Priority.HIGH)
.setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH)
.build();
DataSource<CloseableReference<CloseableBitmap>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, getContext());
DataSubscriber<CloseableReference<CloseableBitmap>> dataSubscriber =
new BaseDataSubscriber<CloseableReference<CloseableBitmap>>() {
@Override
protected void onNewResultImpl(DataSource<CloseableReference<CloseableBitmap>> dataSource) {
mBitmapRef = dataSource.getResult();
// Get the bitmap here and use it in my custom drawable?
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableBitmap>> dataSource) {
}
};
dataSource.subscribe(dataSubscriber, UiThreadImmediateExecutorService.getInstance());
: Ne net gördük bugüne kadar Bitmap almak için buna benzer bir koddur farklı yerlerden bugüne kadar toplandı. Doğru yapılmalı ya da ilk önce Fresco'yu kullanma fikrini döven hafızaları kolayca akıtabiliyorum.
Başkalarının bu soruna çarpması durumunda somut çözüm uygulamasına sahip olmak için cevabı güncelledim. –