Search in sources :

Example 96 with BitmapDrawable

use of android.graphics.drawable.BitmapDrawable in project Klyph by jonathangerbaud.

the class UserSettingsFragment method processImageResponse.

private void processImageResponse(String id, ImageResponse response) {
    if (response != null) {
        Bitmap bitmap = response.getBitmap();
        if (bitmap != null) {
            BitmapDrawable drawable = new BitmapDrawable(UserSettingsFragment.this.getResources(), bitmap);
            drawable.setBounds(0, 0, getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width), getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height));
            userProfilePic = drawable;
            userProfilePicID = id;
            connectedStateLabel.setCompoundDrawables(null, drawable, null, null);
            connectedStateLabel.setTag(response.getRequest().getImageUri());
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 97 with BitmapDrawable

use of android.graphics.drawable.BitmapDrawable in project Talon-for-Twitter by klinker24.

the class PhotoFragment method shareImage.

public void shareImage() {
    if (picture == null) {
        return;
    }
    Bitmap bitmap = ((BitmapDrawable) picture.getDrawable()).getBitmap();
    // create the intent
    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    sharingIntent.setType("image/*");
    // add the bitmap uri to the intent
    Uri uri = getImageUri(activity, bitmap);
    sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
    // start the chooser
    startActivity(Intent.createChooser(sharingIntent, getString(R.string.menu_share) + ": "));
}
Also used : Bitmap(android.graphics.Bitmap) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) CacheableBitmapDrawable(uk.co.senab.bitmapcache.CacheableBitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Uri(android.net.Uri)

Example 98 with BitmapDrawable

use of android.graphics.drawable.BitmapDrawable in project Talon-for-Twitter by klinker24.

the class ImageUtils method loadCircleImage.

public static void loadCircleImage(Context context, final ImageView iv, String url, BitmapLruCache mCache) {
    BitmapDrawable wrapper = null;
    if (url != null) {
        wrapper = mCache.getFromMemoryCache(url);
    }
    if (null != wrapper && iv.getVisibility() != View.GONE) {
        // The cache has it, so just display it
        Log.v("talon_image_cache", "got image from cache");
        iv.setImageDrawable(wrapper);
        Animation fadeInAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_in);
        iv.startAnimation(fadeInAnimation);
    } else if (url != null) {
        // Memory Cache doesn't have the URL, do threaded request...
        iv.setImageDrawable(null);
        ImageUrlCircleAsyncTask mCurrentTask = new ImageUrlCircleAsyncTask(context, iv, mCache, false);
        try {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                SDK11.executeOnThreadPool(mCurrentTask, url);
            } else {
                mCurrentTask.execute(url);
            }
        } catch (RejectedExecutionException e) {
        // This shouldn't happen, but might.
        }
    }
}
Also used : Animation(android.view.animation.Animation) CacheableBitmapDrawable(uk.co.senab.bitmapcache.CacheableBitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 99 with BitmapDrawable

use of android.graphics.drawable.BitmapDrawable in project SmartAndroidSource by jaychou2012.

the class DarkImageButton method createPressDrawable.

public Drawable createPressDrawable(Drawable d) {
    Bitmap bitmap = ((BitmapDrawable) d).getBitmap().copy(Bitmap.Config.ARGB_8888, true);
    Paint paint = new Paint();
    paint.setColor(0x60000000);
    RectF rect = new RectF(0, 0, bitmap.getWidth(), bitmap.getHeight());
    new Canvas(bitmap).drawRoundRect(rect, 4, 4, paint);
    return new BitmapDrawable(bitmap);
}
Also used : RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 100 with BitmapDrawable

use of android.graphics.drawable.BitmapDrawable in project ImagePicker by jeasonlzy.

the class CropImageView method getCropBitmap.

/**
     * @param expectWidth     期望的宽度
     * @param exceptHeight    期望的高度
     * @param isSaveRectangle 是否按矩形区域保存图片
     * @return 裁剪后的Bitmap
     */
public Bitmap getCropBitmap(int expectWidth, int exceptHeight, boolean isSaveRectangle) {
    if (expectWidth <= 0 || exceptHeight < 0)
        return null;
    Bitmap srcBitmap = ((BitmapDrawable) getDrawable()).getBitmap();
    //最好用level,因为角度可能不是90的整数
    srcBitmap = rotate(srcBitmap, sumRotateLevel * 90);
    return makeCropBitmap(srcBitmap, mFocusRect, getImageMatrixRect(), expectWidth, exceptHeight, isSaveRectangle);
}
Also used : Bitmap(android.graphics.Bitmap) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

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