Android how to create runtime thumbnail

后端 未结 9 971
别那么骄傲
别那么骄傲 2020-11-27 09:59

I have a large sized image. At runtime, I want to read the image from storage and scale it so that its weight and size gets reduced and I can use it as a thumbnail. When a u

9条回答
  •  旧巷少年郎
    2020-11-27 10:43

    I found an easy way to do this

    Bitmap thumbnail = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(mPath),200,200)
    

    Syntax

    Bitmap thumbnail = ThumbnailUtils.extractThumbnail(Bitmap source,int width,int height)
    

    OR

    use Picasso dependancy

    compile 'com.squareup.picasso:picasso:2.5.2'

    Picasso.with(context)
        .load("file:///android_asset/DvpvklR.png")
        .resize(50, 50)
        .into(imageView2);
    

    Reference Picasso

提交回复
热议问题