Search in sources :

Example 76 with BitmapDrawable

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);
}
Also used : Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 77 with BitmapDrawable

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;
}
Also used : Bitmap(android.graphics.Bitmap) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Implementation(org.robolectric.annotation.Implementation)

Example 78 with BitmapDrawable

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);
}
Also used : ImageView(android.widget.ImageView) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) CustomView(org.robolectric.android.CustomView) TextView(android.widget.TextView) CustomStateView(org.robolectric.android.CustomStateView) ListView(android.widget.ListView) Test(org.junit.Test)

Example 79 with BitmapDrawable

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);
}
Also used : ImageView(android.widget.ImageView) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) CustomView(org.robolectric.android.CustomView) TextView(android.widget.TextView) CustomStateView(org.robolectric.android.CustomStateView) ListView(android.widget.ListView) Test(org.junit.Test)

Example 80 with BitmapDrawable

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);
    }
}
Also used : Bitmap(android.graphics.Bitmap) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

BitmapDrawable (android.graphics.drawable.BitmapDrawable)640 Bitmap (android.graphics.Bitmap)426 Drawable (android.graphics.drawable.Drawable)187 Canvas (android.graphics.Canvas)182 Paint (android.graphics.Paint)110 Rect (android.graphics.Rect)77 View (android.view.View)77 ImageView (android.widget.ImageView)63 ColorDrawable (android.graphics.drawable.ColorDrawable)59 TextView (android.widget.TextView)51 IOException (java.io.IOException)40 Resources (android.content.res.Resources)35 LayerDrawable (android.graphics.drawable.LayerDrawable)33 AnimationDrawable (android.graphics.drawable.AnimationDrawable)30 File (java.io.File)27 Test (org.junit.Test)24 Matrix (android.graphics.Matrix)23 Intent (android.content.Intent)22 StateListDrawable (android.graphics.drawable.StateListDrawable)22 InputStream (java.io.InputStream)22