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

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

自定義一個SerializableBitmap

2019-11-09 14:53:26
字體:
供稿:網(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ā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 房产| 陇南市| 哈密市| 丁青县| 广丰县| 剑阁县| 株洲县| 盐山县| 乐安县| 孝昌县| 闽侯县| 永年县| 香河县| 雅安市| 东乌珠穆沁旗| 楚雄市| 广昌县| 府谷县| 闵行区| 肇源县| 甘南县| 石渠县| 盐亭县| 探索| 大丰市| 通辽市| 江永县| 临桂县| 瑞安市| 安泽县| 三穗县| 开原市| 平利县| 遂昌县| 万山特区| 瑞安市| 巨野县| 个旧市| 锦屏县| 大余县| 凤台县|