android一个安卓的图片压缩开源库

描述:

android一个安卓的图片压缩开源库

应用截图:

图片压缩

源码介绍:

compressedImage = new Compressor.Builder(this)
            .setMaxWidth(640)
            .setMaxHeight(480)
            .setQuality(75)
            .setCompressFormat(Bitmap.CompressFormat.WEBP)
            .setDestinationDirectoryPath(Environment.getExternalStoragePublicDirectory(
              Environment.DIRECTORY_PICTURES).getAbsolutePath())
            .build()
            .compressToFile(actualImage);
Compressor.getDefault(this)
        .compressToFileAsObservable(actualImage)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(new Action1<File>() {
            @Override
            public void call(File file) {
                compressedImage = file;
            }
        }, new Action1<Throwable>() {
            @Override
            public void call(Throwable throwable) {
                showError(throwable.getMessage());
            }
        });

 

源码下载:https://github.com/zetbaitsu/Compressor

未经允许不得转载:安度博客 » android一个安卓的图片压缩开源库

赞 (0)
分享到:更多 ()

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址