现在的位置: 首页 > 综合 > 正文

android bitmap转image

2018年09月15日 ⁄ 综合 ⁄ 共 976字 ⁄ 字号 评论关闭

                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;
    }

抱歉!评论已关闭.