byte[],bitmap,drawable之间的相互转换
Byte[]转Bitmap
BitmapFactory.decodeByteArray(data, 0, data.length);
Bitmap转Byte[]
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data2 = baos.toByteArray();
可以选择图片格式,这里是JPEG,可以用PNG
Bitmap转Drawable
Bitmap bm=xxx; //xxx根据你的情况获取
BitmapDrawable bd=BitmapDrawable(bm);
Drawable转Bitmap
Drawable d=xxx; //xxx根据自己的情况获取drawable
BitmapDrawable bd = (BitmapDrawable) d;
Bitmap bm = bd.getBitmap();
参考自:
http://blog.csdn.net/yelbosh/article/details/7916988
byte[],bitmap,drawable之间的相互转换的更多相关文章
- android开发之Bitmap 、byte[] 、 Drawable之间的相互转换
一.相关概念 1.Drawable就是一个可画的对象,其可能是一张位图(BitmapDrawable),也可能是一个图形(ShapeDrawable),还有可能是一个图层(LayerDrawable) ...
- Android中Bitmap, Drawable, Byte,ID之间的转化
Android中Bitmap, Drawable, Byte,ID之间的转化 1. Bitmap 转化为 byte ByteArrayOutputStream out = new ByteArray ...
- Android Bitmap与DrawAble与byte[]与InputStream之间的转换工具类【转】
package com.soai.imdemo; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; ...
- Byte[]、Image、Bitmap 之间的相互转换
原文:Byte[].Image.Bitmap 之间的相互转换 /// <summary> /// 将图片Image转换成Byte[] /// </summ ...
- Android中Bitmap, Drawable, Byte之间的转化
1. Bitmap 转化为 byte ByteArrayOutputStream out = new ByteArrayOutputStream(); bitmap.compress(Bitmap. ...
- Bitmap byte[] InputStream Drawable 互转
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStrea ...
- Android Bitmap Drawable byte[] InputStream 相互转换方法
用android处理图片的时候,由于得到的资源不一样,所以经常要在各种格式中相互转化,以下介绍了 Bitmap Drawable byte[] InputStream 之间的转换方法: import ...
- Android图片二进制与Bitmap、Drawable之间的转换
Android图片二进制与Bitmap.Drawable之间的转换 Java代码 public byte[] getBitmapByte(Bitmap bitmap){ ByteArray ...
- Byte[]、Image、Bitmap_之间的相互转换
1.将图片Image转换成Byte[] /// <summary> /// 将图片Image转换成Byte[] /// </summary> ...
随机推荐
- hadoop2.6.4的HA集群搭建超详细步骤
hadoop2.0已经发布了稳定版本了,增加了很多特性,比如HDFS HA.YARN等.最新的hadoop-2.6.4又增加了YARN HA 注意:apache提供的hadoop-2.6.4的安装包是 ...
- Stable Match
稳定婚姻问题 主要就是处理两个数组 boy[i][j] 存放第i个男的第j喜欢的女的 存的是女的编号!! girl[i][j] 存放 第i个女的对第j个男的的好感度 存的是值 然后只要 ...
- 002.KVM环境部署
一 环境准备 1.1 查看是否支持虚拟化 [root@kvm-host ~]# grep -E 'vmx|svm' /proc/cpuinfo 注意:intel为vmx,amd为svm. 1.2 确定 ...
- 浅谈Spring的AOP实现-代理机制
说起Spring的AOP(Aspect-Oriented Programming)面向切面编程大家都很熟悉(Spring不是这次博文的重点),但是我先提出几个问题,看看同学们是否了解,如果了解的话可以 ...
- Android- SharedPreferences 使用详解
Android-SharedPreferences 使用详解 参考 https://developer.android.google.cn/reference/android/content/Shar ...
- POP3_收取QQ邮箱邮件的问题
今天纠结了一天的时间,使用pop3协议收取qq邮箱中邮件时,因为一个特别坑爹的问题重新写n次,最后发现是因为qq邮箱设置了独立邮箱密码,必须的用独立邮箱密码登陆才行,/(ㄒoㄒ)/~~!!!! 但今天 ...
- Git 修复 bug 切换分支时,如何保存修改过的代码(即如何保存现场)?
工作除了开发最新的版本之外还要对原来的版本做例行的维护,修修补补.于是有了在两个分支之间游走切换的问题,最新改版的代码在分支 new 上,旧版本的代码在分支 old 上,我在 new 上开发了一半,忽 ...
- stat,fstate,lstat函数
#include <sys/stat.h> int stat (const char *restrict pathname,struct stat* restrict buf) int f ...
- [Winform]js与webbrowser交互
摘要 目前项目中采用的方式是内嵌浏览器的方式,打开本地或者互联网上的h5页面.在开发之前做了一下调研.目前常用的在C#封装的浏览器内核中,Chromium 内核封装有Xilium.Cefglue.Ce ...
- VS2008 LINK : fatal error LNK1104: cannot open file 'atls.lib'错误解决方案
用VS 2008编写ATL的64位应用程序时,提示链接错误:VS2008 LINK : fatal error LNK1104: cannot open file 'atls.lib' 问题原因 VS ...