use of android.graphics.drawable.BitmapDrawable in project mobile-android by photo.
the class FeatherFragment method loadAsync.
/**
* Load the incoming Image
*
* @param uri
*/
private void loadAsync(final Uri uri) {
CommonUtils.debug(TAG, "loadAsync: " + uri);
ImageView imageView = parameters.getImageView();
if (imageView != null) {
Drawable toRecycle = imageView.getDrawable();
if (toRecycle != null && toRecycle instanceof BitmapDrawable) {
if (((BitmapDrawable) imageView.getDrawable()).getBitmap() != null)
((BitmapDrawable) imageView.getDrawable()).getBitmap().recycle();
}
imageView.setImageDrawable(null);
}
setImageUri(uri);
DownloadAsync task = new DownloadAsync();
task.execute(uri);
}
use of android.graphics.drawable.BitmapDrawable in project robolectric by robolectric.
the class ShadowBitmapDrawable method mutate.
@Implementation
public Drawable mutate() {
Bitmap bitmap = realBitmapDrawable.getBitmap();
BitmapDrawable real = ReflectionHelpers.callConstructor(BitmapDrawable.class, ClassParameter.from(Bitmap.class, bitmap));
ShadowBitmapDrawable shadow = shadowOf(real);
shadow.colorFilter = this.colorFilter;
shadow.drawableCreateFromStreamSource = drawableCreateFromStreamSource;
return real;
}
use of android.graphics.drawable.BitmapDrawable in project robolectric by robolectric.
the class ShadowLayoutInflaterTest method testImageViewSrcIsSet.
@Test
public void testImageViewSrcIsSet() throws Exception {
int layoutResId = context.getResources().getIdentifier("main", "layout", TEST_PACKAGE);
View mediaView = LayoutInflater.from(context).inflate(layoutResId, null);
ImageView imageView = (ImageView) mediaView.findViewById(R.id.image);
BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
assertThat(shadowOf(drawable.getBitmap()).getCreatedFromResId()).isEqualTo(R.drawable.an_image);
}
use of android.graphics.drawable.BitmapDrawable in project robolectric by robolectric.
the class ShadowLayoutInflaterTest method testImageViewSrcIsSetFromMipmap.
@Test
public void testImageViewSrcIsSetFromMipmap() throws Exception {
int layoutResId = context.getResources().getIdentifier("main", "layout", TEST_PACKAGE);
View mediaView = LayoutInflater.from(context).inflate(layoutResId, null);
ImageView imageView = (ImageView) mediaView.findViewById(R.id.mipmapImage);
BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
assertThat(shadowOf(drawable.getBitmap()).getCreatedFromResId()).isEqualTo(R.mipmap.robolectric);
}
use of android.graphics.drawable.BitmapDrawable in project Libraries-for-Android-Developers by eoecn.
the class PicCutDemoActivity method setPicToView.
/**
* ����ü�֮���ͼƬ����
*
* @param picdata
*/
private void setPicToView(Intent picdata) {
Bundle extras = picdata.getExtras();
if (extras != null) {
Bitmap photo = extras.getParcelable("data");
Drawable drawable = new BitmapDrawable(photo);
/**
* ����ע�͵ķ����ǽ��ü�֮���ͼƬ��Base64Coder���ַ���ʽ�� ������������QQͷ���ϴ����õķ������������
*/
ByteArrayOutputStream stream = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.JPEG, 60, stream);
byte[] b = stream.toByteArray();
/*
* ByteArrayOutputStream stream = new ByteArrayOutputStream();
* photo.compress(Bitmap.CompressFormat.JPEG, 60, stream); byte[] b
* = stream.toByteArray(); // ��ͼƬ�����ַ�����ʽ�洢����
*
* tp = new String(Base64Coder.encodeLines(b));
* ����ط���ҿ���д�¸��������ϴ�ͼƬ��ʵ�֣�ֱ�Ӱ�tpֱ���ϴ��Ϳ����ˣ� ����������ķ����Ƿ������DZߵ����ˣ����
*
* ������ص��ķ����������ݻ�����Base64Coder����ʽ�Ļ������������·�ʽת�� Ϊ���ǿ����õ�ͼƬ���;�OK��...���
* Bitmap dBitmap = BitmapFactory.decodeFile(tp); Drawable drawable
* = new BitmapDrawable(dBitmap);
*/
ib.setBackgroundDrawable(drawable);
iv.setBackgroundDrawable(drawable);
}
}
Aggregations