原文:http://wuxiaolong.me/2015/08/10/Drawable-to-Bitmap/ Drawable互转Bitmap Drawable转Bitmap 1234 Resources res = getResources();Drawable drawable = res.getDrawable(R.drawable.myimage);BitmapDrawable bd = (BitmapDrawable) d;Bitmap bm = bd.getBitmap(); 123…
在我们经常应用开发中,经常用到将drawable和string相互转化.注意这情况最好用于小图片入icon等. public synchronized Drawable byteToDrawable(String icon) { byte[] img=Base64.decode(icon.getBytes(), Base64.DEFAULT); Bitmap bitmap; if (img != null) { bitmap = BitmapFactory.decodeByteArray(img…
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 用于缩放bitmap以及将bitmap保存成图片到SD卡中 效果图 代码分析 bitmapZoomByHeight(Bitmap srcBitmap, float newHeight): 根据指定的高度进行缩放(src是bitmap) bitmapZoomByHeight(Drawable drawable, float newHeight) :根据指定的高度进行缩放(src是drawable) bitmapZoomByScal…
BitMap 抛砖引玉 首先,我们思考一个问题:如何在3亿个整数(0~2亿)中判断某一个数是否存在?现在只有一台机器,内存只有500M 这个问题像不像我们之前提到过的一个在0-10个数中,判断某一个数是否存在的问题呢?当时我们采取的做法是,建立一个长度是11的数组,下标从0开始,如果1存在则data[1] = 1,数字作为数组的下标,若该数字存在则在data[数字] = 1,将其赋值为1.那么我们这个是否可以这么做呢? 明显不行.为什么呢?因为我们如果判断2亿个数字是否存在,建立一个2亿长度的数…
String --> InputStreamByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); InputStream --> StringString inputStream2String(InputStream is){   BufferedReader in = new BufferedReader(new InputStreamReader(is));   StringBuffer buffer…
1.String –> InputStream InputStrem is = new ByteArrayInputStream(str.getBytes()); 或者 ByteArrayInputStream stream= new ByteArrayInputStream(str.getBytes()); 2.InputStream–>String inputStream input; StringBuffer out = new StringBuffer(); byte[] b = ne…
近期遇到了如标题这种错误,再次记录解决方法.本文參考帖子: http://bbs.csdn.net/topics/390196217 出现此bug的原因是在内存回收上.里面用Bitamp的代码为: top=(ImageView)view.findViewById(R.id.top); bitmap=ImgBitmap.comeFromRes(getResources(), R.drawable. top); top.setImageBitmap(bitmap); bottom=(ImageVie…
1.InputStreamReader 是字节流通向字符流的桥梁:它使用指定的 charset 读取字节并将其解码为字符 InputStreamReader(InputStream in, String charsetName) 2.OutputStreamWriter 是字符流通向字节流的桥梁:可使用指定的 charset 将要写入流中的字符编码成字节.它使用的字符集可以由名称指定或显式给定,否则将接受平台默认的字符集. OutputStreamWriter(OutputStream out,…
近期在做和图片相关显示的出现了一个问题,整理一下思路.分享出来给大家參考一下: Exception Type:java.lang.RuntimeException java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@XXXXX at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1282) at andr…
近期遇到了如标题这种错误,再次记录解决方法.本文參考帖子: http://bbs.csdn.net/topics/390196217 出现此bug的原因是在内存回收上.里面用Bitamp的代码为: top=(ImageView)view.findViewById(R.id.top); bitmap=ImgBitmap.comeFromRes(getResources(), R.drawable. top); top.setImageBitmap(bitmap); bottom=(ImageVie…