成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

AndroidTiny集成圖片壓縮框架的使用

為了簡化對圖片壓縮的調(diào)用,提供最簡潔與合理的api壓縮邏輯,對于壓縮為Bitmap根據(jù)屏幕分辨率動態(tài)適配最佳大小,對于壓縮為File優(yōu)化底層libjpeg的壓縮,整個圖片壓縮過程全在壓縮線程池中異步壓縮,結(jié)束后分發(fā)回UI線程。

創(chuàng)新互聯(lián)建站是一家從事企業(yè)網(wǎng)站建設(shè)、網(wǎng)站制作、成都網(wǎng)站設(shè)計、行業(yè)門戶網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計制作的專業(yè)的建站公司,擁有經(jīng)驗豐富的網(wǎng)站建設(shè)工程師和網(wǎng)頁設(shè)計人員,具備各種規(guī)模與類型網(wǎng)站建設(shè)的實力,在網(wǎng)站建設(shè)領(lǐng)域樹立了自己獨特的設(shè)計風(fēng)格。自公司成立以來曾獨立設(shè)計制作的站點近1000家。

支持的壓縮類型

Tiny圖片壓縮框架支持的壓縮數(shù)據(jù)源類型:

1、Bytes
2、File
3、Bitmap
4、Stream
5、Resource
6、Uri(network、file、content)

Tiny支持單個數(shù)據(jù)源壓縮以及批量壓縮,支持的壓縮類型:

1、數(shù)據(jù)源—>壓縮為Bitmap
2、數(shù)據(jù)源—>壓縮為File
3、數(shù)據(jù)源—>壓縮為File并返回壓縮后的Bitmap
4、批量數(shù)據(jù)源—>批量壓縮為Bitmap
5、批量數(shù)據(jù)源—>批量壓縮為File
6、批量數(shù)據(jù)源—>批量壓縮為File并返回壓縮后Bitmap

壓縮參數(shù)

Tiny.BitmapCompressOptions

Bitmap壓縮參數(shù)可配置三個:

1、width
2、height
3、Bitmap.Config

如果不配置,Tiny內(nèi)部會根據(jù)屏幕動態(tài)適配以及默認(rèn)使用ARGB_8888

Tiny.FileCompressOptions

File壓縮參數(shù)可配置四個:

1、quality-壓縮質(zhì)量,默認(rèn)為76
2、isKeepSampling-是否保持原數(shù)據(jù)源圖片的寬高
3、fileSize-壓縮后文件大小
4、outfile-壓縮后文件存儲路徑

如果不配置,Tiny內(nèi)部會根據(jù)默認(rèn)壓縮質(zhì)量進(jìn)行壓縮,壓縮后文件默認(rèn)存儲在:ExternalStorage/Android/data/${packageName}/tiny/目錄下

Tiny項目地址: https://github.com/tianyingzhong/Tiny

Tiny與微信朋友圈的壓縮率比較

下面是使用Tiny圖片壓縮庫進(jìn)行壓縮的效果對比示例:

圖片信息TinyWechat
6.66MB (3500x2156)151KB (1280x788)135KB (1280x789)
4.28MB (4160x3120)219KB (1280x960)195KB (1280x960)
2.60MB (4032x3024)193KB (1280x960))173KB (1280x960)
372KB (500x500)38.67KB (500x500)34.05KB (500x500)
236KB (960x1280)127KB (960x1280)118KB (960x1280)

壓縮為Bitmap

Tiny.BitmapCompressOptions options = new Tiny.BitmapCompressOptions();
Tiny.getInstance().source("").asBitmap().withOptions(options).compress(new BitmapCallback() {
  @Override
  public void callback(boolean isSuccess, Bitmap bitmap) {
    //return the compressed bitmap object
  }
});

壓縮為File 

 Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();
Tiny.getInstance().source("").asFile().withOptions(options).compress(new FileCallback() {
  @Override
  public void callback(boolean isSuccess, String outfile) {
    //return the compressed file path
  }
});

壓縮為File并返回Bitmap

 Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();
Tiny.getInstance().source("").asFile().withOptions(options).compress(new FileWithBitmapCallback() {
  @Override
  public void callback(boolean isSuccess, Bitmap bitmap, String outfile) {
    //return the compressed file path and bitmap object
  }
});

批量壓縮為Bitmap

 Tiny.BitmapCompressOptions options = new Tiny.BitmapCompressOptions();
Tiny.getInstance().source("").batchAsBitmap().withOptions(options).batchCompress(new BitmapBatchCallback() {
  @Override
  public void callback(boolean isSuccess, Bitmap[] bitmaps) {
    //return the batch compressed bitmap object
  }
});

批量壓縮為File

 Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();
Tiny.getInstance().source("").batchAsFile().withOptions(options).batchCompress(new FileBatchCallback() {
  @Override
  public void callback(boolean isSuccess, String[] outfile) {
    //return the batch compressed file path
  }
});

批量壓縮為File并返回Bitmap

 Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();
Tiny.getInstance().source("").batchAsFile().withOptions(options).batchCompress(new FileWithBitmapBatchCallback() {
  @Override
  public void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile) {
    //return the batch compressed file path and bitmap object
  }
});

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

網(wǎng)頁標(biāo)題:AndroidTiny集成圖片壓縮框架的使用
轉(zhuǎn)載源于:http://jinyejixie.com/article48/iepohp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化網(wǎng)站設(shè)計公司、移動網(wǎng)站建設(shè)、網(wǎng)站內(nèi)鏈網(wǎng)頁設(shè)計公司、品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)
茶陵县| 外汇| 聊城市| 兴海县| 德惠市| 潜山县| 万州区| 安义县| 安义县| 沐川县| 拉萨市| 皋兰县| 修文县| 台安县| 射洪县| 邮箱| 自治县| 长沙县| 丰宁| 山东省| 田阳县| 栾城县| 扶沟县| 余庆县| 鲜城| 威海市| 象州县| 阜平县| 杭锦旗| 凤山市| 庄河市| 霍州市| 南安市| 玉山县| 扶余县| 望城县| 韶山市| 延吉市| 克东县| 白水县| 泸定县|