{"id":1206,"date":"2016-02-06T21:19:48","date_gmt":"2016-02-06T13:19:48","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=1206"},"modified":"2026-08-18T12:58:47","modified_gmt":"2026-08-18T04:58:47","slug":"android-%e9%ab%98%e6%b8%85%e5%8a%a0%e8%bd%bd%e5%b7%a8%e5%9b%be%e6%96%b9%e6%a1%88-%e6%8b%92%e7%bb%9d%e5%8e%8b%e7%bc%a9%e5%9b%be%e7%89%87","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=1206","title":{"rendered":"Android \u9ad8\u6e05\u52a0\u8f7d\u5de8\u56fe\u65b9\u6848 \u62d2\u7edd\u538b\u7f29\u56fe\u7247"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\">\u52a0\u8f7d\u4e16\u754c\u5730\u56fe\u3001\u6e05\u660e\u4e0a\u6cb3\u56fe\u8fd9\u7c7b\u4e0d\u5141\u8bb8\u538b\u7f29\u7684\u5de8\u56fe\u65f6\uff0c\u6574\u56fe\u89e3\u7801\u5f88\u5bb9\u6613 OOM\u3002\u672c\u7bc7\u7528 BitmapRegionDecoder \u6309\u77e9\u5f62\u7a97\u53e3\u505a\u5c40\u90e8\u89e3\u7801\uff0c\u518d\u81ea\u5b9a\u4e49\u53ef\u62d6\u52a8\u7684 View\uff0c\u628a\u9ad8\u6e05\u539f\u56fe\u4e00\u5757\u5757\u753b\u5230\u5c4f\u5e55\u4e0a\u3002<\/p>\n<\/blockquote>\n<p><!--more--><\/p>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-3498\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png\" alt=\"\" width=\"2151\" height=\"1105\" srcset=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png 2151w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-768x395.png 768w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-1536x789.png 1536w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-2048x1052.png 2048w\" sizes=\"(max-width: 2151px) 100vw, 2151px\" \/><\/a><\/p>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e00\u3001\u6982\u8ff0<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u8ddd\u79bb\u4e0a\u4e00\u7bc7\u535a\u5ba2\u6709\u6bb5\u65f6\u95f4\u6ca1\u66f4\u65b0\u4e86\uff0c\u4e3b\u8981\u662f\u6700\u8fd1\u6709\u4e9b\u79c1\u4e8b\u5bfc\u81f4\u7684\uff0c\u90a3\u4e48\u5c31\u5148\u6765\u4e00\u7bc7\u7b80\u5355\u4e00\u70b9\u7684\u535a\u5ba2\u8109\u52a8\u56de\u6765\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u5bf9\u4e8e\u52a0\u8f7d\u56fe\u7247\uff0c\u5927\u5bb6\u90fd\u4e0d\u964c\u751f\uff0c\u4e00\u822c\u4e3a\u4e86\u5c3d\u53ef\u80fd\u907f\u514dOOM\u90fd\u4f1a\u6309\u7167\u5982\u4e0b\u505a\u6cd5\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: decimal;\">\n<li>\n<section>\u5bf9\u4e8e\u56fe\u7247\u663e\u793a\uff1a\u6839\u636e\u9700\u8981\u663e\u793a\u56fe\u7247\u63a7\u4ef6\u7684\u5927\u5c0f\u5bf9\u56fe\u7247\u8fdb\u884c\u538b\u7f29\u663e\u793a\u3002<\/section>\n<\/li>\n<li>\n<section>\u5982\u679c\u56fe\u7247\u6570\u91cf\u975e\u5e38\u591a\uff1a\u5219\u4f1a\u4f7f\u7528LruCache\u7b49\u7f13\u5b58\u673a\u5236\uff0c\u5c06\u6240\u6709\u56fe\u7247\u5360\u636e\u7684\u5185\u5bb9\u7ef4\u6301\u5728\u4e00\u4e2a\u8303\u56f4\u5185\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u5176\u5b9e\u5bf9\u4e8e\u56fe\u7247\u52a0\u8f7d\u8fd8\u6709\u79cd\u60c5\u51b5\uff0c\u5c31\u662f\u5355\u4e2a\u56fe\u7247\u975e\u5e38\u5de8\u5927\uff0c\u5e76\u4e14\u8fd8\u4e0d\u5141\u8bb8\u538b\u7f29\u3002\u6bd4\u5982\u663e\u793a\uff1a\u4e16\u754c\u5730\u56fe\u3001\u6e05\u660e\u4e0a\u6cb3\u56fe\u3001\u5fae\u535a\u957f\u56fe\u7b49\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u90a3\u4e48\u5bf9\u4e8e\u8fd9\u79cd\u9700\u6c42\uff0c\u8be5\u5982\u4f55\u505a\u5462\uff1f<\/p>\n<p style=\"margin: 1em 0px;\">\u9996\u5148\u4e0d\u538b\u7f29\uff0c\u6309\u7167\u539f\u56fe\u5c3a\u5bf8\u52a0\u8f7d\uff0c\u90a3\u4e48\u5c4f\u5e55\u80af\u5b9a\u662f\u4e0d\u591f\u5927\u7684\uff0c\u5e76\u4e14\u8003\u8651\u5230\u5185\u5b58\u7684\u60c5\u51b5\uff0c\u4e0d\u53ef\u80fd\u4e00\u6b21\u6027\u6574\u56fe\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\uff0c\u6240\u4ee5\u80af\u5b9a\u662f\u5c40\u90e8\u52a0\u8f7d\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u7528\u5230\u4e00\u4e2a\u7c7b\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">BitmapRegionDecoder<\/code><\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u5176\u6b21\uff0c\u65e2\u7136\u5c4f\u5e55\u663e\u793a\u4e0d\u5b8c\uff0c\u90a3\u4e48\u6700\u8d77\u7801\u8981\u6dfb\u52a0\u4e00\u4e2a\u4e0a\u4e0b\u5de6\u53f3\u62d6\u52a8\u7684\u624b\u52bf\uff0c\u8ba9\u7528\u6237\u53ef\u4ee5\u62d6\u52a8\u67e5\u770b\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u90a3\u4e48\u7efc\u4e0a\uff0c\u672c\u7bc7\u535a\u6587\u7684\u76ee\u7684\u5c31\u662f\u53bb\u81ea\u5b9a\u4e49\u4e00\u4e2a\u663e\u793a\u5de8\u56fe\u7684View\uff0c\u652f\u6301\u7528\u6237\u53bb\u62d6\u52a8\u67e5\u770b\uff0c\u5927\u6982\u7684\u6548\u679c\u56fe\u5982\u4e0b\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><img decoding=\"async\" src=\"http:\/\/img.blog.csdn.net\/20151021103013582\" alt=\"\" width=\"320px\" \/><\/p>\n<p style=\"margin: 1em 0px;\">\u597d\u5427\uff0c\u8fd9\u6e05\u660e\u4e0a\u6cb3\u56fe\u592a\u957f\u4e86\uff0c\u60f3\u8981\u89c2\u770b\u5168\u56fe\uff0c\u6587\u672b\u4e0b\u8f7d\uff0c\u56fe\u7247\u5728assets\u76ee\u5f55\u3002\u5f53\u7136\u5982\u679c\u4f60\u7684\u56fe\uff0c\u9ad8\u5ea6\u4e5f\u5f88\u5927\uff0c\u80af\u5b9a\u4e5f\u662f\u53ef\u4ee5\u4e0a\u4e0b\u62d6\u52a8\u7684\u3002<\/p>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\"><a name=\"t2\"><\/a>\u4e8c\u3001\u521d\u8bc6BitmapRegionDecoder<\/span><\/h2>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">BitmapRegionDecoder<\/code>\u4e3b\u8981\u7528\u4e8e\u663e\u793a\u56fe\u7247\u7684\u67d0\u4e00\u5757\u77e9\u5f62\u533a\u57df\uff0c\u5982\u679c\u4f60\u9700\u8981\u663e\u793a\u67d0\u4e2a\u56fe\u7247\u7684\u6307\u5b9a\u533a\u57df\uff0c\u90a3\u4e48\u8fd9\u4e2a\u7c7b\u975e\u5e38\u5408\u9002\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u5bf9\u4e8e\u8be5\u7c7b\u7684\u7528\u6cd5\uff0c\u975e\u5e38\u7b80\u5355\uff0c\u65e2\u7136\u662f\u663e\u793a\u56fe\u7247\u7684\u67d0\u4e00\u5757\u533a\u57df\uff0c\u90a3\u4e48\u81f3\u5c11\u53ea\u9700\u8981\u4e00\u4e2a\u65b9\u6cd5\u53bb\u8bbe\u7f6e\u56fe\u7247\uff1b\u4e00\u4e2a\u65b9\u6cd5\u4f20\u5165\u663e\u793a\u7684\u533a\u57df\u5373\u53ef\uff1b\u8be6\u89c1\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>BitmapRegionDecoder\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684newInstance\u65b9\u6cd5\u6765\u6784\u9020\u5bf9\u8c61\uff0c\u652f\u6301\u4f20\u5165\u6587\u4ef6\u8def\u5f84\uff0c\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u6587\u4ef6\u7684inputstrem\u7b49\u3002\u4f8b\u5982\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\"> BitmapRegionDecoder bitmapRegionDecoder =\n  BitmapRegionDecoder.newInstance(inputStream, false);<\/code><\/pre>\n<\/section>\n<\/li>\n<li>\n<section>\u4e0a\u8ff0\u89e3\u51b3\u4e86\u4f20\u5165\u6211\u4eec\u9700\u8981\u5904\u7406\u7684\u56fe\u7247\uff0c\u90a3\u4e48\u63a5\u4e0b\u6765\u5c31\u662f\u663e\u793a\u6307\u5b9a\u7684\u533a\u57df\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">bitmapRegionDecoder.decodeRegion(rect, options);<\/code><\/pre>\n<p>\u53c2\u6570\u4e00\u5f88\u660e\u663e\u662f\u4e00\u4e2arect\uff0c\u53c2\u6570\u4e8c\u662fBitmapFactory.Options\uff0c\u4f60\u53ef\u4ee5\u63a7\u5236\u56fe\u7247\u7684<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">inSampleSize<\/code>,<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">inPreferredConfig<\/code>\u7b49\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u90a3\u4e48\u4e0b\u9762\u770b\u4e00\u4e2a\u8d85\u7ea7\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">package com.zhy.blogcodes.largeImage;\n\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapFactory;\nimport android.graphics.BitmapRegionDecoder;\nimport android.graphics.Rect;\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.widget.ImageView;\n\nimport com.zhy.blogcodes.R;\n\nimport java.io.IOException;\nimport java.io.InputStream;\n\npublic class LargeImageViewActivity extends AppCompatActivity\n{\n    private ImageView mImageView;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState)\n    {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_large_image_view);\n\n        mImageView = (ImageView) findViewById(R.id.id_imageview);\n        try\n        {\n            InputStream inputStream = getAssets().open(\"tangyan.jpg\");\n\n            \/\/\u83b7\u5f97\u56fe\u7247\u7684\u5bbd\u3001\u9ad8\n            BitmapFactory.Options tmpOptions = new BitmapFactory.Options();\n            tmpOptions.inJustDecodeBounds = true;\n            BitmapFactory.decodeStream(inputStream, null, tmpOptions);\n            int width = tmpOptions.outWidth;\n            int height = tmpOptions.outHeight;\n\n            \/\/\u8bbe\u7f6e\u663e\u793a\u56fe\u7247\u7684\u4e2d\u5fc3\u533a\u57df\n            BitmapRegionDecoder bitmapRegionDecoder = BitmapRegionDecoder.newInstance(inputStream, false);\n            BitmapFactory.Options options = new BitmapFactory.Options();\n            options.inPreferredConfig = Bitmap.Config.RGB_565;\n            Bitmap bitmap = bitmapRegionDecoder.decodeRegion(new Rect(width \/ 2 - 100, height \/ 2 - 100, width \/ 2 + 100, height \/ 2 + 100), options);\n            mImageView.setImageBitmap(bitmap);\n\n        } catch (IOException e)\n        {\n            e.printStackTrace();\n        }\n\n    }\n\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4e0a\u8ff0\u4ee3\u7801\uff0c\u5c31\u662f\u4f7f\u7528BitmapRegionDecoder\u53bb\u52a0\u8f7dassets\u4e2d\u7684\u56fe\u7247\uff0c\u8c03\u7528<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">bitmapRegionDecoder.decodeRegion<\/code>\u89e3\u6790\u56fe\u7247\u7684\u4e2d\u95f4\u77e9\u5f62\u533a\u57df\uff0c\u8fd4\u56debitmap\uff0c\u6700\u7ec8\u663e\u793a\u5728ImageView\u4e0a\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u6548\u679c\u56fe\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><img decoding=\"async\" src=\"http:\/\/img.blog.csdn.net\/20151021103048017\" alt=\"\" width=\"320px\" \/><\/p>\n<p style=\"margin: 1em 0px;\">\u4e0a\u9762\u7684\u5c0f\u56fe\u663e\u793a\u7684\u5373\u4e3a\u4e0b\u9762\u7684\u5927\u56fe\u7684\u4e2d\u95f4\u533a\u57df\u3002<\/p>\n<p style=\"margin: 1em 0px;\">ok\uff0c\u90a3\u4e48\u76ee\u524d\u6211\u4eec\u5df2\u7ecf\u4e86\u89e3\u4e86<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">BitmapRegionDecoder<\/code>\u7684\u57fa\u672c\u7528\u6237\uff0c\u90a3\u4e48\u5f80\u5916\u6269\u6563\uff0c\u6211\u4eec\u9700\u8981\u81ea\u5b9a\u4e49\u4e00\u4e2a\u63a7\u4ef6\u53bb\u663e\u793a\u5de8\u56fe\u5c31\u5f88\u7b80\u5355\u4e86\uff0c\u9996\u5148Rect\u7684\u8303\u56f4\u5c31\u662f\u6211\u4eecView\u7684\u5927\u5c0f\uff0c\u7136\u540e\u6839\u636e\u7528\u6237\u7684\u79fb\u52a8\u624b\u52bf\uff0c\u4e0d\u65ad\u53bb\u66f4\u65b0\u6211\u4eec\u7684Rect\u7684\u53c2\u6570\u5373\u53ef\u3002<\/p>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\"><a name=\"t3\"><\/a>\u4e09\u3001\u81ea\u5b9a\u4e49\u663e\u793a\u5927\u56fe\u63a7\u4ef6<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u6839\u636e\u4e0a\u9762\u7684\u5206\u6790\u5462\uff0c\u6211\u4eec\u8fd9\u4e2a\u81ea\u5b9a\u4e49\u63a7\u4ef6\u601d\u8def\u5c31\u975e\u5e38\u6e05\u6670\u4e86\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u63d0\u4f9b\u4e00\u4e2a\u8bbe\u7f6e\u56fe\u7247\u7684\u5165\u53e3<\/section>\n<\/li>\n<li>\n<section>\u91cd\u5199onTouchEvent\uff0c\u5728\u91cc\u9762\u6839\u636e\u7528\u6237\u79fb\u52a8\u7684\u624b\u52bf\uff0c\u53bb\u66f4\u65b0\u663e\u793a\u533a\u57df\u7684\u53c2\u6570<\/section>\n<\/li>\n<li>\n<section>\u6bcf\u6b21\u66f4\u65b0\u533a\u57df\u53c2\u6570\u540e\uff0c\u8c03\u7528invalidate\uff0conDraw\u91cc\u9762\u53bbregionDecoder.decodeRegion\u62ff\u5230bitmap\uff0c\u53bbdraw<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u7406\u6e05\u4e86\uff0c\u53d1\u73b0so easy\uff0c\u4e0b\u9762\u4e0a\u4ee3\u7801\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">package com.zhy.blogcodes.largeImage.view;\n\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapFactory;\nimport android.graphics.BitmapRegionDecoder;\nimport android.graphics.Canvas;\nimport android.graphics.Rect;\nimport android.util.AttributeSet;\nimport android.view.MotionEvent;\nimport android.view.View;\n\nimport java.io.IOException;\nimport java.io.InputStream;\n\n\/**\n * Created by zhy on 15\/5\/16.\n *\/\npublic class LargeImageView extends View\n{\n    private BitmapRegionDecoder mDecoder;\n    \/**\n     * \u56fe\u7247\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6\n     *\/\n    private int mImageWidth, mImageHeight;\n    \/**\n     * \u7ed8\u5236\u7684\u533a\u57df\n     *\/\n    private volatile Rect mRect = new Rect();\n\n    private MoveGestureDetector mDetector;\n\n    private static final BitmapFactory.Options options = new BitmapFactory.Options();\n\n    static\n    {\n        options.inPreferredConfig = Bitmap.Config.RGB_565;\n    }\n\n    public void setInputStream(InputStream is)\n    {\n        try\n        {\n            mDecoder = BitmapRegionDecoder.newInstance(is, false);\n            BitmapFactory.Options tmpOptions = new BitmapFactory.Options();\n            \/\/ Grab the bounds for the scene dimensions\n            tmpOptions.inJustDecodeBounds = true;\n            BitmapFactory.decodeStream(is, null, tmpOptions);\n            mImageWidth = tmpOptions.outWidth;\n            mImageHeight = tmpOptions.outHeight;\n\n            requestLayout();\n            invalidate();\n        } catch (IOException e)\n        {\n            e.printStackTrace();\n        } finally\n        {\n\n            try\n            {\n                if (is != null) is.close();\n            } catch (Exception e)\n            {\n            }\n        }\n    }\n\n    public void init()\n    {\n        mDetector = new MoveGestureDetector(getContext(), new MoveGestureDetector.SimpleMoveGestureDetector()\n        {\n            @Override\n            public boolean onMove(MoveGestureDetector detector)\n            {\n                int moveX = (int) detector.getMoveX();\n                int moveY = (int) detector.getMoveY();\n\n                if (mImageWidth &gt; getWidth())\n                {\n                    mRect.offset(-moveX, 0);\n                    checkWidth();\n                    invalidate();\n                }\n                if (mImageHeight &gt; getHeight())\n                {\n                    mRect.offset(0, -moveY);\n                    checkHeight();\n                    invalidate();\n                }\n\n                return true;\n            }\n        });\n    }\n\n    private void checkWidth()\n    {\n\n        Rect rect = mRect;\n        int imageWidth = mImageWidth;\n        int imageHeight = mImageHeight;\n\n        if (rect.right &gt; imageWidth)\n        {\n            rect.right = imageWidth;\n            rect.left = imageWidth - getWidth();\n        }\n\n        if (rect.left &lt; 0)\n        {\n            rect.left = 0;\n            rect.right = getWidth();\n        }\n    }\n\n    private void checkHeight()\n    {\n\n        Rect rect = mRect;\n        int imageWidth = mImageWidth;\n        int imageHeight = mImageHeight;\n\n        if (rect.bottom &gt; imageHeight)\n        {\n            rect.bottom = imageHeight;\n            rect.top = imageHeight - getHeight();\n        }\n\n        if (rect.top &lt; 0)\n        {\n            rect.top = 0;\n            rect.bottom = getHeight();\n        }\n    }\n\n    public LargeImageView(Context context, AttributeSet attrs)\n    {\n        super(context, attrs);\n        init();\n    }\n\n    @Override\n    public boolean onTouchEvent(MotionEvent event)\n    {\n        mDetector.onToucEvent(event);\n        return true;\n    }\n\n    @Override\n    protected void onDraw(Canvas canvas)\n    {\n        Bitmap bm = mDecoder.decodeRegion(mRect, options);\n        canvas.drawBitmap(bm, 0, 0, null);\n    }\n\n    @Override\n    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)\n    {\n        super.onMeasure(widthMeasureSpec, heightMeasureSpec);\n\n        int width = getMeasuredWidth();\n        int height = getMeasuredHeight();\n\n        int imageWidth = mImageWidth;\n        int imageHeight = mImageHeight;\n\n         \/\/\u9ed8\u8ba4\u76f4\u63a5\u663e\u793a\u56fe\u7247\u7684\u4e2d\u5fc3\u533a\u57df\uff0c\u53ef\u4ee5\u81ea\u5df1\u53bb\u8c03\u8282\n        mRect.left = imageWidth \/ 2 - width \/ 2;\n        mRect.top = imageHeight \/ 2 - height \/ 2;\n        mRect.right = mRect.left + width;\n        mRect.bottom = mRect.top + height;\n\n    }<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u6839\u636e\u4e0a\u8ff0\u6e90\u7801:<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: decimal;\">\n<li>\n<section>setInputStream\u91cc\u9762\u53bb\u83b7\u5f97\u56fe\u7247\u7684\u771f\u5b9e\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6\uff0c\u4ee5\u53ca\u521d\u59cb\u5316\u6211\u4eec\u7684mDecoder<\/section>\n<\/li>\n<li>\n<section>onMeasure\u91cc\u9762\u4e3a\u6211\u4eec\u7684\u663e\u793a\u533a\u57df\u7684rect\u8d4b\u503c\uff0c\u5927\u5c0f\u4e3aview\u7684\u5c3a\u5bf8<\/section>\n<\/li>\n<li>\n<section>onTouchEvent\u91cc\u9762\u6211\u4eec\u76d1\u542cmove\u7684\u624b\u52bf\uff0c\u5728\u76d1\u542c\u7684\u56de\u8c03\u91cc\u9762\u53bb\u6539\u53d8rect\u7684\u53c2\u6570\uff0c\u4ee5\u53ca\u505a\u8fb9\u754c\u68c0\u67e5\uff0c\u6700\u540einvalidate<\/section>\n<\/li>\n<li>\n<section>\u5728onDraw\u91cc\u9762\u5c31\u662f\u6839\u636erect\u62ff\u5230bitmap\uff0c\u7136\u540edraw\u4e86<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">ok\uff0c\u4e0a\u9762\u5e76\u4e0d\u590d\u6742\uff0c\u4e0d\u8fc7\u5927\u5bb6\u6709\u6ca1\u6709\u6ce8\u610f\u5230\uff0c\u8fd9\u4e2a\u76d1\u542c\u7528\u6237move\u624b\u52bf\u7684\u4ee3\u7801\u5199\u7684\u6709\u70b9\u5947\u602a\uff0c\u6069\uff0c\u8fd9\u91cc\u6a21\u4eff\u4e86\u7cfb\u7edf\u7684<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">ScaleGestureDetector<\/code>\uff0c\u7f16\u5199\u4e86<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">MoveGestureDetector<\/code>\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>MoveGestureDetector<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">package com.zhy.blogcodes.largeImage.view;\n\nimport android.content.Context;\nimport android.graphics.PointF;\nimport android.view.MotionEvent;\n\npublic class MoveGestureDetector extends BaseGestureDetector\n{\n\n    private PointF mCurrentPointer;\n    private PointF mPrePointer;\n    \/\/\u4ec5\u4ec5\u4e3a\u4e86\u51cf\u5c11\u521b\u5efa\u5185\u5b58\n    private PointF mDeltaPointer = new PointF();\n\n    \/\/\u7528\u4e8e\u8bb0\u5f55\u6700\u7ec8\u7ed3\u679c\uff0c\u5e76\u8fd4\u56de\n    private PointF mExtenalPointer = new PointF();\n\n    private OnMoveGestureListener mListenter;\n\n    public MoveGestureDetector(Context context, OnMoveGestureListener listener)\n    {\n        super(context);\n        mListenter = listener;\n    }\n\n    @Override\n    protected void handleInProgressEvent(MotionEvent event)\n    {\n        int actionCode = event.getAction() &amp; MotionEvent.ACTION_MASK;\n        switch (actionCode)\n        {\n            case MotionEvent.ACTION_CANCEL:\n            case MotionEvent.ACTION_UP:\n                mListenter.onMoveEnd(this);\n                resetState();\n                break;\n            case MotionEvent.ACTION_MOVE:\n                updateStateByEvent(event);\n                boolean update = mListenter.onMove(this);\n                if (update)\n                {\n                    mPreMotionEvent.recycle();\n                    mPreMotionEvent = MotionEvent.obtain(event);\n                }\n                break;\n\n        }\n    }\n\n    @Override\n    protected void handleStartProgressEvent(MotionEvent event)\n    {\n        int actionCode = event.getAction() &amp; MotionEvent.ACTION_MASK;\n        switch (actionCode)\n        {\n            case MotionEvent.ACTION_DOWN:\n                resetState();\/\/\u9632\u6b62\u6ca1\u6709\u63a5\u6536\u5230CANCEL or UP ,\u4fdd\u9669\u8d77\u89c1\n                mPreMotionEvent = MotionEvent.obtain(event);\n                updateStateByEvent(event);\n                break;\n            case MotionEvent.ACTION_MOVE:\n                mGestureInProgress = mListenter.onMoveBegin(this);\n                break;\n        }\n\n    }\n\n    protected void updateStateByEvent(MotionEvent event)\n    {\n        final MotionEvent prev = mPreMotionEvent;\n\n        mPrePointer = caculateFocalPointer(prev);\n        mCurrentPointer = caculateFocalPointer(event);\n\n        \/\/Log.e(\"TAG\", mPrePointer.toString() + \" ,  \" + mCurrentPointer);\n\n        boolean mSkipThisMoveEvent = prev.getPointerCount() != event.getPointerCount();\n\n        \/\/Log.e(\"TAG\", \"mSkipThisMoveEvent = \" + mSkipThisMoveEvent);\n        mExtenalPointer.x = mSkipThisMoveEvent ? 0 : mCurrentPointer.x - mPrePointer.x;\n        mExtenalPointer.y = mSkipThisMoveEvent ? 0 : mCurrentPointer.y - mPrePointer.y;\n\n    }\n\n    \/**\n     * \u6839\u636eevent\u8ba1\u7b97\u591a\u6307\u4e2d\u5fc3\u70b9\n     *\n     * @param event\n     * @return\n     *\/\n    private PointF caculateFocalPointer(MotionEvent event)\n    {\n        final int count = event.getPointerCount();\n        float x = 0, y = 0;\n        for (int i = 0; i &lt; count; i++)\n        {\n            x += event.getX(i);\n            y += event.getY(i);\n        }\n\n        x \/= count;\n        y \/= count;\n\n        return new PointF(x, y);\n    }\n\n    public float getMoveX()\n    {\n        return mExtenalPointer.x;\n\n    }\n\n    public float getMoveY()\n    {\n        return mExtenalPointer.y;\n    }\n\n    public interface OnMoveGestureListener\n    {\n        public boolean onMoveBegin(MoveGestureDetector detector);\n\n        public boolean onMove(MoveGestureDetector detector);\n\n        public void onMoveEnd(MoveGestureDetector detector);\n    }\n\n    public static class SimpleMoveGestureDetector implements OnMoveGestureListener\n    {\n\n        @Override\n        public boolean onMoveBegin(MoveGestureDetector detector)\n        {\n            return true;\n        }\n\n        @Override\n        public boolean onMove(MoveGestureDetector detector)\n        {\n            return false;\n        }\n\n        @Override\n        public void onMoveEnd(MoveGestureDetector detector)\n        {\n        }\n    }\n\n}<\/code><\/pre>\n<\/section>\n<\/li>\n<li>\n<section>BaseGestureDetector<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">package com.zhy.blogcodes.largeImage.view;\n\nimport android.content.Context;\nimport android.view.MotionEvent;\n\npublic abstract class BaseGestureDetector\n{\n\n    protected boolean mGestureInProgress;\n\n    protected MotionEvent mPreMotionEvent;\n    protected MotionEvent mCurrentMotionEvent;\n\n    protected Context mContext;\n\n    public BaseGestureDetector(Context context)\n    {\n        mContext = context;\n    }\n\n    public boolean onToucEvent(MotionEvent event)\n    {\n\n        if (!mGestureInProgress)\n        {\n            handleStartProgressEvent(event);\n        } else\n        {\n            handleInProgressEvent(event);\n        }\n\n        return true;\n\n    }\n\n    protected abstract void handleInProgressEvent(MotionEvent event);\n\n    protected abstract void handleStartProgressEvent(MotionEvent event);\n\n    protected abstract void updateStateByEvent(MotionEvent event);\n\n    protected void resetState()\n    {\n        if (mPreMotionEvent != null)\n        {\n            mPreMotionEvent.recycle();\n            mPreMotionEvent = null;\n        }\n        if (mCurrentMotionEvent != null)\n        {\n            mCurrentMotionEvent.recycle();\n            mCurrentMotionEvent = null;\n        }\n        mGestureInProgress = false;\n    }\n\n}<\/code><\/pre>\n<p>\u4f60\u53ef\u80fd\u4f1a\u8bf4\uff0c\u4e00\u4e2amove\u624b\u52bf\u641e\u8fd9\u4e48\u591a\u4ee3\u7801\uff0c\u592a\u9ebb\u70e6\u4e86\u3002\u7684\u786e\u662f\u7684\uff0cmove\u624b\u52bf\u7684\u68c0\u6d4b\u975e\u5e38\u7b80\u5355\uff0c\u90a3\u4e48\u4e4b\u6240\u4ee5\u8fd9\u4e48\u5199\u5462\uff0c\u4e3b\u8981\u662f\u4e3a\u4e86\u53ef\u4ee5\u590d\u7528\uff0c\u6bd4\u5982\u73b0\u5728\u6709\u4e00\u5806\u7684<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">XXXGestureDetector<\/code>\uff0c\u5f53\u6211\u4eec\u9700\u8981\u76d1\u542c\u4ec0\u4e48\u624b\u52bf\uff0c\u5c31\u76f4\u63a5\u62ff\u4e2adetector\u6765\u68c0\u6d4b\u591a\u65b9\u4fbf\u3002\u6211\u76f8\u4fe1\u5927\u5bb6\u80af\u5b9a\u4e5f\u90c1\u95f7\u8fc7Google\uff0c\u4e3a\u4ec0\u4e48\u53ea\u6709<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">ScaleGestureDetector<\/code>\u800c\u6ca1\u6709<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">RotateGestureDetector<\/code>\u5462\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u6839\u636e\u4e0a\u8ff0\uff0c\u5927\u5bb6\u5e94\u8be5\u7406\u89e3\u4e86\u4e3a\u4ec0\u4e48\u8981\u8fd9\u4e48\u505a\uff0c\u5f53\u65f6\u4e0d\u5f3a\u5236\uff0c\u6bcf\u4e2a\u4eba\u90fd\u6709\u4e2a\u6027\u3002<\/p>\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\">\u4e0d\u8fc7\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff1a\u4e0a\u9762\u8fd9\u4e2a\u624b\u52bf\u68c0\u6d4b\u7684\u5199\u6cd5\uff0c\u4e0d\u662f\u6211\u60f3\u7684\uff0c\u800c\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u9879\u76ee<a href=\"https:\/\/github.com\/rharter\/android-gesture-detectors\">https:\/\/github.com\/rharter\/android-gesture-detectors<\/a>\uff0c\u91cc\u9762\u5305\u542b\u5f88\u591a\u7684\u624b\u52bf\u68c0\u6d4b\u3002\u5bf9\u5e94\u7684\u535a\u6587\u662f\uff1a<a href=\"http:\/\/code.almeros.com\/android-multitouch-gesture-detectors#.VibzzhArJXg\">http:\/\/code.almeros.com\/android-multitouch-gesture-detectors#.VibzzhArJXg<\/a>\u90a3\u9762\u4e0a\u9762\u4e24\u4e2a\u7c7b\u5c31\u662f\u6211\u5077\u5b66\u4e86\u7684~ \u54c8<\/p>\n<\/blockquote>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\"><a name=\"t4\"><\/a>\u56db\u3001\u6d4b\u8bd5<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u6d4b\u8bd5\u5176\u5b9e\u6ca1\u6492\u597d\u8bf4\u7684\u4e86\uff0c\u5c31\u662f\u628a\u6211\u4eec\u7684LargeImageView\u653e\u5165\u5e03\u5c40\u6587\u4ef6\uff0c\u7136\u540eActivity\u91cc\u9762\u53bb\u8bbe\u7f6einputstream\u4e86\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;RelativeLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n                xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"&gt;\n\n    &lt;com.zhy.blogcodes.largeImage.view.LargeImageView\n        android:id=\"@+id\/id_largetImageview\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\/&gt;\n\n&lt;\/RelativeLayout&gt;<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u7136\u540e\u5728Activity\u91cc\u9762\u53bb\u8bbe\u7f6e\u56fe\u7247\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">package com.zhy.blogcodes.largeImage;\n\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\n\nimport com.zhy.blogcodes.R;\nimport com.zhy.blogcodes.largeImage.view.LargeImageView;\n\nimport java.io.IOException;\nimport java.io.InputStream;\n\npublic class LargeImageViewActivity extends AppCompatActivity\n{\n    private LargeImageView mLargeImageView;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState)\n    {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_large_image_view);\n\n        mLargeImageView = (LargeImageView) findViewById(R.id.id_largetImageview);\n        try\n        {\n            InputStream inputStream = getAssets().open(\"world.jpg\");\n            mLargeImageView.setInputStream(inputStream);\n\n        } catch (IOException e)\n        {\n            e.printStackTrace();\n        }\n\n    }\n\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u6548\u679c\u56fe\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><img decoding=\"async\" src=\"http:\/\/img.blog.csdn.net\/20151021103123812\" alt=\"\" width=\"320px\" \/><\/p>\n<p style=\"margin: 1em 0px;\">ok\uff0c\u90a3\u4e48\u5230\u6b64\uff0c\u663e\u793a\u5de8\u56fe\u7684\u65b9\u6848\u4ee5\u53ca\u8be6\u7ec6\u7684\u4ee3\u7801\u5c31\u63cf\u8ff0\u5b8c\u6210\u4e86\uff0c\u603b\u4f53\u8fd8\u662f\u975e\u5e38\u7b80\u5355\u7684\u3002 \u4f46\u662f\uff0c\u5728\u5b9e\u9645\u7684\u9879\u76ee\u4e2d\uff0c\u53ef\u80fd\u4f1a\u6709\u66f4\u591a\u7684\u9700\u6c42\uff0c\u6bd4\u5982\u589e\u52a0\u653e\u5927\u3001\u7f29\u5c0f\uff1b\u589e\u52a0\u5feb\u6ed1\u624b\u52bf\u7b49\u7b49\uff0c\u90a3\u4e48\u5927\u5bb6\u53ef\u4ee5\u53bb\u53c2\u8003\u8fd9\u4e2a\u5e93\uff1a<a href=\"https:\/\/github.com\/johnnylambada\/WorldMap\">https:\/\/github.com\/johnnylambada\/WorldMap<\/a>\uff0c\u8be5\u5e93\u57fa\u672c\u5b9e\u73b0\u4e86\u7edd\u5927\u591a\u6570\u7684\u9700\u6c42\uff0c\u5927\u5bb6\u6839\u636e\u672c\u6587\u8fd9\u4e2a\u601d\u8def\u518d\u53bb\u770b\u8fd9\u4e2a\u5e93\uff0c\u4e5f\u4f1a\u7b80\u5355\u5f88\u591a\uff0c\u5b9a\u5236\u8d77\u6765\u4e5f\u5bb9\u6613\u3002\u6211\u8fd9\u4e2a\u5730\u56fe\u7684\u56fe\u5c31\u662f\u8be5\u5e93\u91cc\u9762\u63d0\u4f9b\u7684\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u54c8\uff0c\u638c\u63e1\u4e86\u8fd9\u4e2a\uff0c\u4ee5\u540e\u9762\u8bd5\u8fc7\u7a0b\u4e2d\u4e5f\u53ef\u4ee5\u6084\u6084\u7684\u88c5\u4e00\u628a\u4e86\uff0c\u5f53\u4f60\u4f18\u96c5\u7684\u7b54\u5b8candroid\u52a0\u8f7d\u56fe\u7247\u7684\u65b9\u6848\u4ee5\u540e\uff0c\u7136\u540e\u63a5\u4e00\u53e5\uff0c\u5176\u5b9e\u8fd8\u6709\u4e00\u79cd\u60c5\u51b5\uff0c\u5c31\u662f\u9ad8\u6e05\u663e\u793a\u5de8\u56fe\uff0c\u90a3\u4e48\u6211\u4eec\u5e94\u8be5\u2026\u76f8\u4fe1\u9762\u8bd5\u5b98\u5bf9\u4f60\u7684\u5370\u8c61\u4f1a\u597d\u5f88\u591a~ have a nice day ~<\/p>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/github.com\/hongyangAndroid\/Android_Blog_Demos\">\u6e90\u7801\u70b9\u51fb\u4e0b\u8f7d<\/a><\/p>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\"><a name=\"t5\"><\/a>\u53c2\u8003\u94fe\u63a5<\/span><\/h2>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section><a href=\"http:\/\/code.almeros.com\/android-multitouch-gesture-detectors#.VibzzhArJXg\">http:\/\/code.almeros.com\/android-multitouch-gesture-detectors#.VibzzhArJXg<\/a><\/section>\n<\/li>\n<li>\n<section><a href=\"https:\/\/github.com\/rharter\/android-gesture-detectors\">https:\/\/github.com\/rharter\/android-gesture-detectors<\/a><\/section>\n<\/li>\n<li>\n<section><a href=\"https:\/\/github.com\/johnnylambada\/WorldMap\">https:\/\/github.com\/johnnylambada\/WorldMap<\/a><\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u539f\u6587\u51fa\u5904:<a href=\"http:\/\/blog.csdn.net\/lmj623565791\/article\/details\/49300989\">Android \u9ad8\u6e05\u52a0\u8f7d\u5de8\u56fe\u65b9\u6848 \u62d2\u7edd\u538b\u7f29\u56fe\u7247<\/a><\/p>\n<table style=\"border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; text-align: left; overflow: auto; display: table; overflow-wrap: break-word; word-break: break-all;\" width=\"817\">\n<thead>\n<tr>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">\u573a\u666f<\/th>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">\u505a\u6cd5<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u666e\u901a\u5217\u8868\u56fe<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u6309\u63a7\u4ef6\u5c3a\u5bf8\u538b\u7f29 + LruCache<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u5355\u5f20\u5de8\u56fe\u4e14\u7981\u6b62\u538b\u7f29<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">BitmapRegionDecoder \u5c40\u90e8\u89e3\u7801<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u5c4f\u5e55\u770b\u4e0d\u5168<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u81ea\u5b9a\u4e49 View + \u62d6\u52a8\u624b\u52bf\u66f4\u65b0 Rect<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\"><strong>\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1a\u5de8\u56fe\u4e0d\u8981\u4e00\u6b21\u6027 decode \u8fdb\u5185\u5b58\uff1a\u7528 BitmapRegionDecoder.decodeRegion \u53ea\u89e3\u5f53\u524d\u7a97\u53e3\uff0c\u624b\u52bf\u79fb\u52a8\u65f6\u66f4\u65b0 Rect \u518d invalidate\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u52a0\u8f7d\u4e16\u754c\u5730\u56fe\u3001\u6e05\u660e\u4e0a\u6cb3\u56fe\u8fd9\u7c7b\u4e0d\u5141\u8bb8\u538b\u7f29\u7684\u5de8\u56fe\u65f6\uff0c\u6574\u56fe\u89e3\u7801\u5f88\u5bb9\u6613 OOM\u3002\u672c\u7bc7\u7528 BitmapRegionDec [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[66],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1206"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1206"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1206\/revisions"}],"predecessor-version":[{"id":3556,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1206\/revisions\/3556"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}