国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 融水| 郧西县| 梁河县| 岚皋县| 昌都县| 五原县| 隆化县| 玛曲县| 来安县| 泽库县| 无锡市| 青岛市| 巴东县| 赞皇县| 浮梁县| 青龙| 游戏| 江城| 合作市| 武定县| 龙里县| 蒲江县| 冷水江市| 东山县| 西畴县| 龙井市| 鸡泽县| 桐庐县| 云浮市| 客服| 盘山县| 舒城县| 孟津县| 垣曲县| 望都县| 青铜峡市| 伊宁市| 兴宁市| 鄂温| 海晏县| 施甸县|