Search in sources :

Example 11 with BitmapDrawable

use of android.graphics.drawable.BitmapDrawable in project kickmaterial by byoutline.

the class CircleTransition method getStartView.

private View getStartView(ViewGroup sceneRoot, TransitionValues startValues, int[] sceneRootLoc, int[] startLoc) {
    Bitmap startImage = (Bitmap) startValues.values.get(PROPERTY_IMAGE);
    Drawable startBackground = new BitmapDrawable(startImage);
    final View startView = addViewToOverlay(sceneRoot, startImage.getWidth(), startImage.getHeight(), startBackground);
    int startTranslationX = startLoc[0] - sceneRootLoc[0];
    int startTranslationY = startLoc[1] - sceneRootLoc[1];
    startView.setTranslationX(startTranslationX);
    startView.setTranslationY(startTranslationY);
    return startView;
}
Also used : Bitmap(android.graphics.Bitmap) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) View(android.view.View)

Example 12 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)

Example 13 with BitmapDrawable

use of android.graphics.drawable.BitmapDrawable in project android-app by eoecn.

the class PopupWindowUtil method showActionWindow.

public void showActionWindow(View parent, Context context, List<T> tabs) {
    // final RingtoneclipModel currentData = model;
    // final int res_id = currentData.getId();
    int[] location = new int[2];
    int popWidth = context.getResources().getDimensionPixelOffset(R.dimen.popupWindow_width);
    parent.getLocationOnScreen(location);
    View view = getView(context, tabs);
    popupWindow = new PopupWindow(view, popWidth, // new
    LayoutParams.WRAP_CONTENT);
    // PopupWindow(view,
    // popWidth,
    // LayoutParams.WRAP_CONTENT);
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    // 显示的位置为:屏幕的最右端
    int xPos = (int) (windowManager.getDefaultDisplay().getWidth() - popupWindow.getWidth() - context.getResources().getDimension(R.dimen.popupWindow_margin));
    // popupWindow.showAsDropDown(parent, -10,0);
    popupWindow.showAtLocation(parent, Gravity.NO_GRAVITY, xPos, location[1] + parent.getHeight() - 20);
}
Also used : PopupWindow(android.widget.PopupWindow) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) View(android.view.View) WindowManager(android.view.WindowManager)

Example 14 with BitmapDrawable

use of android.graphics.drawable.BitmapDrawable in project DragSortRecycler by emileb.

the class DragSortRecycler method createFloatingBitmap.

private BitmapDrawable createFloatingBitmap(View v) {
    floatingItemStatingBounds = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
    floatingItemBounds = new Rect(floatingItemStatingBounds);
    Bitmap bitmap = Bitmap.createBitmap(floatingItemStatingBounds.width(), floatingItemStatingBounds.height(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    v.draw(canvas);
    BitmapDrawable retDrawable = new BitmapDrawable(v.getResources(), bitmap);
    retDrawable.setBounds(floatingItemBounds);
    return retDrawable;
}
Also used : Rect(android.graphics.Rect) Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 15 with BitmapDrawable

use of android.graphics.drawable.BitmapDrawable in project Libraries-for-Android-Developers by eoecn.

the class IcsProgressBar method tileify.

/**
     * Converts a drawable to a tiled version of itself. It will recursively
     * traverse layer and state list drawables.
     */
private Drawable tileify(Drawable drawable, boolean clip) {
    if (drawable instanceof LayerDrawable) {
        LayerDrawable background = (LayerDrawable) drawable;
        final int N = background.getNumberOfLayers();
        Drawable[] outDrawables = new Drawable[N];
        for (int i = 0; i < N; i++) {
            int id = background.getId(i);
            outDrawables[i] = tileify(background.getDrawable(i), (id == android.R.id.progress || id == android.R.id.secondaryProgress));
        }
        LayerDrawable newBg = new LayerDrawable(outDrawables);
        for (int i = 0; i < N; i++) {
            newBg.setId(i, background.getId(i));
        }
        return newBg;
    } else /* else if (drawable instanceof StateListDrawable) {
            StateListDrawable in = (StateListDrawable) drawable;
            StateListDrawable out = new StateListDrawable();
            int numStates = in.getStateCount();
            for (int i = 0; i < numStates; i++) {
                out.addState(in.getStateSet(i), tileify(in.getStateDrawable(i), clip));
            }
            return out;

        }*/
    if (drawable instanceof BitmapDrawable) {
        final Bitmap tileBitmap = ((BitmapDrawable) drawable).getBitmap();
        if (mSampleTile == null) {
            mSampleTile = tileBitmap;
        }
        final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());
        final BitmapShader bitmapShader = new BitmapShader(tileBitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
        shapeDrawable.getPaint().setShader(bitmapShader);
        return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL) : shapeDrawable;
    }
    return drawable;
}
Also used : Bitmap(android.graphics.Bitmap) LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable) ClipDrawable(android.graphics.drawable.ClipDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapShader(android.graphics.BitmapShader) ClipDrawable(android.graphics.drawable.ClipDrawable)

Aggregations

BitmapDrawable (android.graphics.drawable.BitmapDrawable)617 Bitmap (android.graphics.Bitmap)413 Drawable (android.graphics.drawable.Drawable)185 Canvas (android.graphics.Canvas)176 Paint (android.graphics.Paint)107 Rect (android.graphics.Rect)76 View (android.view.View)74 ColorDrawable (android.graphics.drawable.ColorDrawable)58 ImageView (android.widget.ImageView)58 TextView (android.widget.TextView)49 IOException (java.io.IOException)39 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 Intent (android.content.Intent)23 Matrix (android.graphics.Matrix)22 StateListDrawable (android.graphics.drawable.StateListDrawable)22 InputStream (java.io.InputStream)22