Resize a large bitmap file to scaled output file on Android

前端 未结 21 1499
执念已碎
执念已碎 2020-11-22 05:51

I have a large bitmap (say 3888x2592) in a file. Now, I want to resize that bitmap to 800x533 and save it to another file. I normally would scale the bitmap by calling

21条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 06:29

    To scale the image the "correct" way, without skipping any pixels, you'd have to hook into the image decoder to perform the down-sampling row by row. Android (and the Skia library that underlies it) provides no such hooks, so you'd have to roll your own. Assuming you're talking jpeg images, your best bet would be to use libjpeg directly, in C.

    Given the complexities involved, using the two-step subsample-then-rescale is probably best for image-preview type apps.

提交回复
热议问题