开发者

How can I reduce the size of a picture I received via share intent on Android?

I want to reduce the resolution/size of a picture I received via share intent and I only have its URI. The pictures can be in different formats and I may receive several pictures at once. I used the following intent-filter:

 <intent-filter android:icon="@drawable/icon" android:label="Share">
  <action android:name="android.intent.action.SEND" />
  <action android:name="android.intent.action.SEND_MULTIPLE" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.ALTERNATIVE" />
  <category android:name="android.intent.category.SELECTED_ALTERNATIVE" />
  <data android:mimeType="image/*" />
 </intent-filter>

How can I do it?

Do I have to save the pic开发者_Go百科ture(s) to the SD card again with another name if I want to share it/them again with another app?

Thanks!


Use the Bitmap.compress(...) API.

Edit To copy and scaledown the picture. Create a new empty bitmap, use it as a place for a canvas to draw to. Draw the old bitmap on the canvas with an appropriate Scale matrix or draw the old bitmap with a destination rectangle the same dimensions as your destination bitmap (depending on the api and effect you'd like to have), then save the destination bitmap.

Or for only scaling use Bitmap.createScaledBitmap().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜