android开发路-bitmap转缓存输入流BufferedInputStream
来源:互联网 发布:mac无主之地2没有繁体 编辑:程序博客网 时间:2024/06/05 15:59
我们往服务器上传图片时往往要对一个图片对象进行输入输出流的转化
ByteArrayOutputStream baos = new ByteArrayOutputStream();//compress方法是把一个位图写到一个OutputStream中,参数一是位图对象,二是格式,三是压缩的质量,四是输出流newimage.compress(Bitmap.CompressFormat.JPEG, 100, baos);//输出流转成输入流InputStream inputimage = new ByteArrayInputStream(baos.toByteArray());final BufferedInputStream inputImage = new BufferedInputStream(inputimage)
Drawable转Bitmap的两种方法:
一:
private Bitmap bitmap;private void drawableToBitamp(Drawable drawable) { int w = drawable.getIntrinsicWidth(); int h = drawable.getIntrinsicHeight(); System.out.println("Drawable转Bitmap"); Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565; bitmap = Bitmap.createBitmap(w,h,config); //注意,下面三行代码要用到,否在在View或者surfaceview里的canvas.drawBitmap会看不到图 Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, w, h); drawable.draw(canvas); }二:
private Bitmap bitmap;private void drawableToBitamp(Drawable drawable) { BitmapDrawable bd = (BitmapDrawable) drawable; bitmap = bd.getBitmap(); }
0 0
- android开发路-bitmap转缓存输入流BufferedInputStream
- Android 缓存流(BufferedInputStream和BufferedOutputStream)
- android 缓存Bitmap - 开发文档翻译
- BufferedInputStream(缓冲输入流)详解
- android 缓存Bitmap
- android 缓存Bitmap
- Android Bitmap 缓存
- android缓存Bitmap
- Android Bitmap 缓存策略
- Android 缓存大量 bitmap
- android bitmap 缓存 处理
- IO流-BufferedInputStream输入缓冲流
- BufferedInputStream(缓冲输入流) 示例
- android bitmap 怎么使用缓存?
- android bitmap 缓存工具类
- android bitmap缓存机制(上)
- android bitmap缓存机制(下)
- android: 缓存异步加载Bitmap
- android设计概述
- Content Security Policy介绍
- 【Java】读取其下所有文件夹与文件的路径
- 鼠标放在物体上,就弹出属性框
- JAVA 极速WEB+ORM框架 JFinal
- android开发路-bitmap转缓存输入流BufferedInputStream
- VC++获得微秒级时间的方法与技巧探讨
- hibernate关联映射
- bootstrap 模态窗口点击图层不关闭写法
- 关于后盾网yii框架的学习小结(1)--yii模块的安装
- Android电话短信拦截项目总结之 SQLite数据库简介和使用
- hdu 奥运(矩阵快速幂+等比数列快速求和+数论)
- php web项目环境搭建
- 自定义动态属性标签