绋嬪簭鎬ц兘浼樺寲涔嬬綉缁滀紶杈撲笌鏁版嵁瀛樺偍浼樺寲锛堜簲锛変笅

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了绋嬪簭鎬ц兘浼樺寲涔嬬綉缁滀紶杈撲笌鏁版嵁瀛樺偍浼樺寲锛堜簲锛変笅相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/bae' title='bae'>bae   鐩綍   ali   puts   鍘嬬缉   鍥剧墖鏍煎紡   encode   绛夌骇   detail   

闃块噷P7绉诲姩浜掕仈缃戞灦鏋勫笀杩涢樁瑙嗛锛堟瘡鏃ユ洿鏂颁腑锛夊厤璐瑰涔犺鐐瑰嚮锛?a href="https://links.jianshu.com/go?to=https%3A%2F%2Fspace.bilibili.com%2F474380680" data-cke-saved-href="https://links.jianshu.com/go?to=https%3A%2F%2Fspace.bilibili.com%2F474380680">https://space.bilibili.com/474380680

鏈瘒鏂囩珷灏嗙户缁粠7Z鏋侀檺鍘嬬缉鍜學ebP浣跨敤鏉ヤ粙缁嶇綉缁滀紶杈撲笌鏁版嵁瀛樺偍浼樺寲:

涓€銆?Z鏋侀檺鍘嬬缉

涓€浜涙枃浠惰繃澶ф垨鑰呮槸瀹归噺澶ぇ浜嗭紝鍗犵敤纭洏澶绌洪棿浜嗐€傛鍒诲彲浠ヤ娇鐢ㄥ帇缂╄蒋浠惰繘琛屽帇缂╋紝璁╁畠鐨勪綋绉彉灏忎簡銆傚叾涓瀬闄愬帇缂╁彲浠ヨ鏂囦欢澶规垨鑰呮槸鏂囦欢锛屽帇缂╃殑鏈€灏忋€傞偅涔堝浣曚娇鐢ㄨ繖涓瀬闄愬帇缂╁姛鑳界殑銆?/p>

 

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 

 

 

1銆佷綘瑕佸埌缃戜笂涓嬭浇杩欎釜鍘嬬缉鐨勭▼搴忥紝鐐瑰嚮瀹冿紝鐐瑰嚮銆恑nstall銆戙€?/p>

 

 

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 

 

 

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 


2銆佹鍒昏蒋浠朵細瀹夎鍒扮數鑴戯紝鎵惧埌闇€瑕佸帇缂╃殑鏂囦欢浠ュ強鏂囦欢澶广€?/p>

 

 

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 

 

 

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 

 

 

3銆佸彸閿枃浠舵垨鑰呮枃浠跺す閫夋嫨杩欎釜7z锛岄€夋嫨鍘嬬缉鍖咃紝鐐瑰嚮杩欎釜鍘嬬缉绛夌骇杩欓噷銆?/p>

 

 

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 

 

 

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 


4銆侀€夋嫨杩欎釜鏋侀檺鍘嬬缉锛岀劧鍚庡帇缂╃畻娉曢€夋嫨銆怢ZMA2銆戙€?/p>

 

 

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 

 

 

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 


5銆佺劧鍚庣偣鍑昏繖涓‘瀹氾紝杞欢灏嗕細浠ユ瀬闄愬帇缂╃殑鏂瑰紡杩涜鍘嬬缉鐨勩€傚帇缂╁悗鐨勬枃浠舵槑鏄惧彉灏忎簡鐨勩€?/p>

 

 

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 

 

 

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 

 

浜屻€乄ebP浣跨敤 鍥剧墖浼樺寲

2.1銆佷粈涔堟槸 WebP锛?/h2>

WebP锛堝彂闊?weppy锛岄」鐩富椤碉級锛屾槸涓€绉嶆敮鎸佹湁鎹熷帇缂╁拰鏃犳崯鍘嬬缉鐨勫浘鐗囨枃浠舵牸寮忥紝娲剧敓鑷浘鍍忕紪鐮佹牸寮?VP8銆傛牴鎹?Google 鐨勬祴璇曪紝鏃犳崯鍘嬬缉鍚庣殑 WebP 姣?PNG 鏂囦欢灏戜簡 45锛?鐨勬枃浠跺ぇ灏忥紝鍗充娇杩欎簺 PNG 鏂囦欢缁忚繃鍏朵粬鍘嬬缉宸ュ叿鍘嬬缉涔嬪悗锛學ebP 杩樻槸鍙互鍑忓皯 28锛呯殑鏂囦欢澶у皬銆?/p>

2.2銆佸綋涓婣ndroid鍥剧墖浼樺寲涔媁ebP鐨勫繀鐒堕€夋嫨

瀵逛簬涓€涓ソ鐨凙PP锛屽綋鐒舵槸瓒婂皬瓒婂ソ锛岀劧鑰岋紝鍦ˋPP涓浘鐗囧氨鍗犳嵁浜嗗緢澶х殑涓€閮ㄥ垎浣撶Н锛屾墍浠ュ浘鐗囩殑浼樺寲鏄紑鍙戜汉鍛樺繀椤昏鍋氱殑浜嬫儏锛岃€屽師鏈夊浘鐗囩殑png銆乯peg銆丟IF绛夋牸寮忕殑浼樺寲宸茬粡杈惧埌浜嗘瀬鑷达紝鎵€浠ュ彧寰楀彟瀵诲嚭璺紝鍥犳鏈変簡WebP銆傜敱浜嶹ebP鐨勭壒鎬э紝濡傛灉鎶奧ebP杩愮敤鍒癆PP涓皢浼氫娇鎴戜滑鐨凙PP浣撶Н澶у皬寰楀埌寰堝ぇ绋嬪害鐨勭缉灏忥紝APP涔熶細寰楀埌涓€涓川鐨勫彉鍖栵紝鎵€浠ワ紝WebP鍦ˋPP涓殑浣跨敤灏嗘槸鐩墠鎴戜滑鍥剧墖浼樺寲鐨勪笉浜岄€夋嫨銆?/p>

2.3銆乄ebP鐨勮浆鎹?/h2>

WebP鐨勮浆鎹細WebP涓庡叾浠栧父鐢ㄧ殑鍥剧墖鏍煎紡涔嬮棿鏄彲浠ョ浉浜掕浆鎹㈢殑锛寃ebp杞崲宸ュ叿鏈夛細XnConvet锛屾櫤鍥撅紝ISparta.

2.4銆乄ebP鐨勫吋瀹规€?/h2>

WebP鐨勫吋瀹规€э細4.2.1+ 瀵逛簬webp鐨刣ecode銆乪ncode鏄畬鍏ㄦ敮鎸佺殑锛堝寘鍚崐閫忔槑鐨剋ebp鍥撅級瀵逛簬4.0+ 鍒?4.2.1 锛屽彧鏀寔瀹屽叏涓嶉€忔槑鐨刣ecode銆乪ncode鐨剋ebp鍥撅紝4.0 浠ヤ笅锛屽簲璇ユ槸榛樿涓嶆敮鎸亀ebp鐨勶紙缂栫爜瑙g爜锛夈€?/p>

2.5銆丄ndroid涓媁ebP鐨勪娇鐢?/h2>

鎯冲湪APP涓娇鐢╓ebP锛岄鍏堟垜浠氨寰楄В鍐冲畠鐨勫吋瀹规€ч棶棰樸€傛楠ゅ涓嬶細

1銆佹坊鍔爓ebp鐨勬敮鎸侊紝鍔犺浇so鏂囦欢锛屾坊鍔爈ibwebp.jia鍖?/strong>

(1)鑾峰彇so鏂囦欢鍜宭ibwebp.jia鍖咃細鍙互浠?a href="https://links.jianshu.com/go?to=https%3A%2F%2Fgithub.com%2FEverythingMe%2Fwebp-android" data-cke-saved-href="https://links.jianshu.com/go?to=https%3A%2F%2Fgithub.com%2FEverythingMe%2Fwebp-android">https://github.com/EverythingMe/webp-android涓嬭浇瑙f瀽搴擄紝鐒跺悗ndk-build寰楀埌so鏂囦欢銆傚悓鏃朵篃鑳藉湪瑙f瀽搴撻噷闈㈠緱鍒發ibwebp.jia鍖呫€?/p>

(2)寰楀埌so鏂囦欢鍜宭ibwebp.jia鍚庢嫹鍒伴」鐩殑app鐨刲ibs鐩綍涓嬨€?/p>

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 

(3)鍦╝ppbuild娣诲姞渚濊禆銆?/p>

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 

娣诲姞鎴愬姛鍚庡湪app鐩綍涓嬩細鐢熸垚杩欐牱鐨勪竴涓枃浠躲€?/p>

 
鎶€鏈浘鐗? class=鎶€鏈浘鐗? class=?
 

鑷 so鏂囦欢娣诲姞渚濊禆鎴愬姛銆?/p>

2銆佺浜屾锛屾坊鍔燱ebpUtils鏂囦欢锛岄噷闈㈡湁閫氳繃so鍖呮潵澶勭悊webp鏂囦欢鎴愪负byte鏁扮粍鐨勬柟娉曘€?/strong>

鎴戜滑鍙互閫氳繃浠ヤ笅鏂规硶鏉ヨВ鍐冲吋瀹规€ч棶棰橈紙4.2.1浠ヤ笅鐗堟湰涔熷彲浠ユ樉绀簑ebp鏍煎紡鍥剧墖锛屽寘鎷崐閫忔槑鍥剧墖锛夈€?/p>

鍏抽敭浠g爜锛?/p>

**public class **WebPDecoder {
    **private static **WebPDecoder *instance *= **null**;

    **private **WebPDecoder() {
        System.*loadLibrary*(**"webp_evme"**);
    }

    **public static **WebPDecoder getInstance() {
        **if **(*instance*==**null**) {
            **synchronized **(WebPDecoder.**class**) {
                **if **(*instance*==**null**) {
                    *instance *= **new **WebPDecoder();
                }
            }
        }

        **return ***instance*;
    }

    **public **BitmapdecodeWebP(**byte**[] encoded) {
        **return **decodeWebP(encoded,0,0);
    }

    **public **BitmapwebpToBitmap(InputStream is) {
        Bitmap bitmap = **null**;
        **if **(Build.VERSION.***SDK_INT***< Build.VERSION_CODES.***JELLY_BEAN_MR1***) {
            bitmap = WebPDecoder.*getInstance*().decodeWebP(*streamToBytes*(is));
        } **else **{
            bitmap = BitmapFactory.*decodeStream*(is);
        }
        **return **bitmap;
    }

    **private static byte**[] streamToBytes(InputStream is) {
        ByteArrayOutputStream os = **new **ByteArrayOutputStream(1024);
        **byte**[]buffer = **new byte**[1024];
        **int **len;
        **try **{
            **while **((len= is.read(buffer)) >=0) {
                os.write(buffer, 0, len);
            }
        } **catch **(java.io.IOExceptione) {
        }
        **return **os.toByteArray();
    }
鎶€鏈浘鐗? class=

3銆侀」鐩噷鍦ㄩ渶瑕佺殑鍦版柟鐩存帴璋冪敤

final ImageView imageView = (ImageView) findViewById(R.id.imageView);
try {
    imageView.setImageBitmap(WebPDecoder.getInstance().webpToBitmap(getAssets().open("aa.webp")));
} catch (IOException e) {
    e.printStackTrace();
}
鎶€鏈浘鐗? class=

鍙傝€冿細https://blog.csdn.net/qq_34075348/article/details/78750974
https://jingyan.baidu.com/article/93f9803f4b6055e0e46f55b1.html

闃块噷P7绉诲姩浜掕仈缃戞灦鏋勫笀杩涢樁瑙嗛锛堟瘡鏃ユ洿鏂颁腑锛夊厤璐瑰涔犺鐐瑰嚮锛?a href="https://links.jianshu.com/go?to=https%3A%2F%2Fspace.bilibili.com%2F474380680" data-cke-saved-href="https://links.jianshu.com/go?to=https%3A%2F%2Fspace.bilibili.com%2F474380680">https://space.bilibili.com/474380680

以上是关于绋嬪簭鎬ц兘浼樺寲涔嬬綉缁滀紶杈撲笌鏁版嵁瀛樺偍浼樺寲锛堜簲锛変笅的主要内容,如果未能解决你的问题,请参考以下文章

MyCat瀹炵幇鏁版嵁搴撲笌鏁版嵁搴撲箣闂寸殑璇诲啓鍒嗙

for寰幆瀹炴垬鎬ц兘浼樺寲

銆岀畻娉曚笌鏁版嵁缁撴瀯銆嶅甫浣犵湅鍝堝笇绠楁硶涔嬬編

SSL/TLS娣卞害瑙f瀽--TLS鎬ц兘浼樺寲

Tomcat8瀹夎锛?瀹夊叏閰嶇疆涓庢€ц兘浼樺寲

鍒濊瘑Protobuf