보를 사용하는 방법이트맵으로 입력해줍니다. 나는 심지어는 확실하지 않을 경우 가능합니다. It's 크기를 조정하기 위한 목적입니다. 글라이드는 좋은 이미지 증진 규모입니다. 문제는 내가 있는 리소스 비트맵 이미 로드 하는 지 확인해 주시기 바랍니다. 유일한 솔루션을 찾을 수 있는 이미지를 저장을 임시 파일을 다시는 그들을 다시 활 inputStream/파일이..는 더 좋은 방법이 있을 달성하는가?
시기 바랍에 대답하기 전에..Im 에 대해 얘기하지 않는 출력에서 활...asBitmap().get()
그것을 알고 있습니다.도움이 필요 입니다.
여기 나 해결 솔루션:
Bitmap bitmapNew=null;
try {
//
ContextWrapper cw = new ContextWrapper(ctx);
File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
File file=new File(directory,"temp.jpg");
FileOutputStream fos = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 90, fos);
fos.close();
//
bitmapNew = Glide
.with(ctx)
.load(file)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.into( mActualWidth, mActualHeight - heightText)
.get();
file.delete();
} catch (Exception e) {
Logcat.e( "File not found: " + e.getMessage());
}
나는'd 을 피하기 위해 같은 이미지를 작성하여 내부 로드십시오.는 이유입니다 Im 요청이 있는 경우 방법을 같이 입력한 비트맵
감사
한 4 버전을 호출하는asBitmap()
앞에짐()
GlideApp.with(itemView.getContext())
.asBitmap()
.load(data.getImageUrl())
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {}
});
}
정말 이상한 경우,그러나 시도 할 수 있습니다. 나는'm 를 사용하여 이전과하지 않는 멋진피카소 미술
,하지만 어느 날 나는'll give 글라이드십시오.
여기에 몇 가지의 링크 당신을 도울 수 있는:
고 실제로 잔인하지만 내 생각 효율적인 방법으로 이를 해결하기:
ByteArrayOutputStream stream = new ByteArrayOutputStream();
yourBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
Glide.with(this)
.load(stream.toByteArray())
.asBitmap()
.error(R.drawable.ic_thumb_placeholder)
.transform(new CircleTransform(this))
.into(imageview);
나는'하는지 확인하는 데 도움이 됩니다,하지만 난 그것은 만들 수 있습니다 당신은 걸음 더 가까이하는 솔루션입니다.
작은 변화에 따르면 최신 버전의글라이드
. 이제 우리가 사용할 필요가제출()
로드 이미지 비트맵으로하지 않는 경우,당신은 클래스의 submit()`보다는 청취자 승't 가 호출됩니다.
여기에 들어 내가 오늘날 사용됩니다.
Glide.with(cxt)
.asBitmap().load(imageUrl)
.listener(new RequestListener<Bitmap>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object o, Target<Bitmap> target, boolean b) {
Toast.makeText(cxt,getResources().getString(R.string.unexpected_error_occurred_try_again),Toast.LENGTH_SHORT).show();
return false;
}
@Override
public boolean onResourceReady(Bitmap bitmap, Object o, Target<Bitmap> target, DataSource dataSource, boolean b) {
zoomImage.setImage(ImageSource.bitmap(bitmap));
return false;
}
}
).submit();
그것은 작업하고 난'm 비트 맵에서 듣는 것입니다.
허용되는 대답을 작품에 대한 이전 버전에 있지만,새로운 버전의 활을 사용:
RequestOptions requestOptions = new RequestOptions();
requestOptions.placeholder(android.R.drawable.waiting);
requestOptions.error(R.drawable.waiting);
Glide.with(getActivity()).apply(requestOptions).load(imageUrl).into(imageView);
여기's 다른 솔루션을 반환하는 당신이트맵을 설정으로 이미지 뷰
Glide.with(this)
.load(R.drawable.card_front) // you can pass url too
.asBitmap()
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
// you can do something with loaded bitmap here
imgView.setImageBitmap(resource);
}
});
을 사용하시기 바랍 구현에 대한 즉:
구현'com.습니다.bumptech.글라이드:글라이드:4.9.0'
Glide.with(this)
.asBitmap()
.load(item.getMarkertOverlayImage())
.into(new CustomTarget <Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition <? super Bitmap> transition) {
// you can do something with loaded bitmap here
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
대부분의 API 를's 및 방법의 활공은 이제 더 이상 사용되지 않습니다. 아래 작업을 위한 글라이드 4.9 및 최 안드로이드 10.
에 대한 이미지는 URI
Bitmap bitmap = Glide
.with(context)
.asBitmap()
.load(image_uri_or_drawable_resource_or_file_path)
.submit()
.get();
사용 활공에서 아래와 같다.gradle
implementation 'com.github.bumptech.glide:glide:4.9.0'
코 틀린,
Glide.with(this)
.asBitmap()
.load("https://...")
.addListener(object : RequestListener<Bitmap> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Bitmap>?,
isFirstResource: Boolean
): Boolean {
Toast.makeText(this@MainActivity, "failed: " + e?.printStackTrace(), Toast.LENGTH_SHORT).show()
return false
}
override fun onResourceReady(
resource: Bitmap?,
model: Any?,
target: Target<Bitmap>?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
//image is ready, you can get bitmap here
return false
}
})
.into(imageView)
무엇을 위해,가치를 기반으로 게시물 위에 내가 방법:
Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
Uri imageUri = Uri.withAppendedPath(sArtworkUri, String.valueOf(album_id));
다음 접합기:
// loading album cover using Glide library
Glide.with(mContext)
.asBitmap()
.load(imageUri)
.into(holder.thumbnail);