国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 柯坪县| 淄博市| 噶尔县| 读书| 临朐县| 布尔津县| 临城县| 兰溪市| 康马县| 长沙市| 铁岭市| 白玉县| 盘锦市| 临桂县| 濮阳县| 桃源县| 伊通| 鄂托克前旗| 仲巴县| 平果县| 柯坪县| 南乐县| 调兵山市| 偃师市| 伊川县| 曲靖市| 甘洛县| 漾濞| 天祝| 剑川县| 卓资县| 德安县| 晋城| 沈阳市| 师宗县| 阿巴嘎旗| 怀集县| 阳曲县| 武强县| 怀安县| 大港区|