Bitmap与Drawable相互转化
来源:互联网 发布:淘宝刷心悦会员被骗了 编辑:程序博客网 时间:2024/06/13 10:54
/** * Bitmap转化为Drawable */public Drawable Bitmap2Drawable(Bitmap bitmap){BitmapDrawable drawable = new BitmapDrawable(bitmap);return drawable;}/** * Drawable转化为Bitmap */public Bitmap Drawable2Bitmap(Drawable drawable){BitmapDrawable bitDrawable = (BitmapDrawable)drawable;return bitDrawable.getBitmap();}
/** Bitmap转化为Pixmap */public static Pixmap ToPixmap(Bitmap bitmap){if (bitmap == null) return null;// 从Bitmap创建输出流int size = bitmap.getWidth() * bitmap.getHeight();ByteArrayOutputStream outStream = new ByteArrayOutputStream(size);bitmap.compress(Bitmap.CompressFormat.PNG, 0, outStream);// 从输出流创建Pixmapbyte[] img = outStream.toByteArray();return new Pixmap(img, 0, img.length);}
/** 从Assets目录中读取图片, fileName = "texture/0_1.jpeg" */@SuppressWarnings("unused")public static Bitmap getAssetsBitmap(String fileName){// 判断文件是否存在FileHandle handle = Gdx.files.internal(fileName);if (!handle.exists()) return null;Bitmap image = null;AssetManager manager = HlgeActivity.$this.getResources().getAssets();try{InputStream is = manager.open(fileName);image = BitmapFactory.decodeStream(is);is.close();}catch (IOException e){e.printStackTrace();}return image;}
0 0
- Bitmap与Drawable相互转化
- Android Bitmap与byte[]、Bitmap与Drawable相互转化
- Bitmap,byte[],Drawable相互转化
- Bitmap,byte[],Drawable相互转化
- Bitmap,byte[],Drawable相互转化
- Bitmap,byte[],Drawable相互转化
- android中drawable与bitmap的相互转化
- android----Bitmap / Drawable / byte[] 之间相互转化
- Android中Bitmap,byte[],Drawable相互转化
- Android中Bitmap,byte[],Drawable相互转化
- Android中Bitmap,byte[],Drawable相互转化
- Android中Bitmap,byte[],Drawable相互转化
- Android中Bitmap,byte[],Drawable相互转化
- Android中Bitmap,byte[],Drawable相互转化
- Android中Bitmap,byte[],Drawable相互转化
- Android中Bitmap,byte[],Drawable相互转化
- Android中Bitmap,byte[],Drawable相互转化
- Android中Bitmap,byte[],Drawable相互转化
- 获取app版本信息
- Self Numbers
- 顺序表的基本运算。
- Framework中的连接管理机制(原)
- 第三周 项目2 建设“顺序表”算法库
- Bitmap与Drawable相互转化
- Java面试宝典
- C++语言中函数参数传递的三种方式
- 项目3 -- 单链表的应用(1)
- Tomcat无法访问,404错误
- Linux下的有名管道(06)---使用两个管道实现两个进程之间的通信(手机模式)
- ADS7846使用心得
- 判断 Fragment 的 UI 是否可见
- 将一张图片分成多个区域设置多个超链接