国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

自定義一個SerializableBitmap

2019-11-09 14:01:15
字體:
供稿:網(wǎng)友
java code?
12345678910111213141516171819202122232425262728293031public class SerializableBitmap implements Serializable {        PRivate static final long serialVersionUID = -5228835919664263905L;        private Bitmap bitmap;         public SerializableBitmap(Bitmap b) {            bitmap = b;        }         // Converts the Bitmap into a byte array for serialization        private void writeObject(ObjectOutputStream out) throws IOException {            ByteArrayOutputStream byteStream = new ByteArrayOutputStream();            boolean success = bitmap.compress(Bitmap.CompressFormat.PNG, 0, byteStream);            byte bitmapBytes[] = byteStream.toByteArray();            if (success)                out.write(bitmapBytes, 0, bitmapBytes.length);        }         // Deserializes a byte array representing the Bitmap and decodes it        private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {            ByteArrayOutputStream byteStream = new ByteArrayOutputStream();            int b;            while ((b = in.read()) != -1)                byteStream.write(b);            byte bitmapBytes[] = byteStream.toByteArray();            bitmap = BitmapFactory.decodeByteArray(bitmapBytes, 0, bitmapBytes.length);        }         public Bitmap getBitmap() {            return this.bitmap;        }    }
類中要使用Bitmap的時候就用SerializableBitmap,設(shè)置就是new SerializableBitmap(Bitmap bitmap),取出就是SerializableBitmap.getBitmap()
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 南昌县| 罗田县| 宣汉县| 平果县| 鹤庆县| 通渭县| 永仁县| 巴青县| 苏尼特左旗| 保康县| 林州市| 邹城市| 津南区| 阳新县| 肇庆市| 蒲城县| 陇南市| 策勒县| 西吉县| 泌阳县| 五台县| 文昌市| 徐汇区| 韩城市| 大兴区| 什邡市| 和静县| 阿拉尔市| 布拖县| 三明市| 汕头市| 玉环县| 屯门区| 南投市| 雷波县| 黑山县| 镇康县| 抚顺县| 灵川县| 宝鸡市| 宁晋县|