android bitmap转image

来源:互联网 发布:淘宝上比较靠谱的代购 编辑:程序博客网 时间:2024/05/17 13:10
                Bitmap bm = BitmapFactory.decodeFile(lis.get(position).toString());

                BitmapDrawable drawable = new BitmapDrawable(bm);


// 加载资源里的图片
    private void generateBitmaps() {

        mBitmaps.clear();
        int[] ids = { R.drawable.center_children, R.drawable.center_boya,
                R.drawable.center_store, R.drawable.center_youpeng,
                R.drawable.center_yu };

        for (int id : ids) {
            
            Bitmap bitmap = createReflectedBitmapById(id);
            if (null != bitmap) {
                BitmapDrawable drawable = new BitmapDrawable(bitmap);
                drawable.setAntiAlias(true);

                mBitmaps.add(drawable);
            }
        }

    }

    private Bitmap createReflectedBitmapById(int resId) {
        Drawable drawable = getResources().getDrawable(resId);
        if (drawable instanceof BitmapDrawable) {

            Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
            // Bitmap reflectedBitmap =
            // BitmapUtil.createReflectedBitmap(bitmap);

            return bitmap;
        }

        return null;
    }


原创粉丝点击