android - How can get an image from an image view? -
i trying image put image view. approach:
// image in image view bytearrayoutputstream outputstream = new bytearrayoutputstream(); bitmap mybitmap = mimageview.getdrawingcache(); mybitmap.compress(compressformat.png, 0, outputstream); then want insert database:
mdbhelper.createreminder(outputstream); the databaseadapter looks this:
public long createreminder(bytearrayoutputstream outputstream) { contentvalues initialvalues = new contentvalues(); initialvalues.put(key_image, outputstream.tobytearray()); return mdb.insert(database_table, null, initialvalues); } when tried app crashed. think statements somehow faulty. ideas???
drawable drawable = mimageview.getdrawable(); if (drawable instanceof bitmapdrawable) { bitmapdrawable bitmapdrawable = (bitmapdrawable) drawable; bitmap bitmap = bitmapdrawable.getbitmap(); }
Comments
Post a Comment