-----当Bitmap大到超出gl_max_texture_size,就会导致bitmap对象无法绘制到ImageView
----- 问题分析: 既然bitmap太大导致,那就分割大bitmap对象,然后用2个ImageView显示
------ 举例 -------
------- demo_layout.xml
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/id_iv_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true" />
<ImageView
android:id="@+id/id_iv_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true" />
</LinearLayout>
</ScrollView>
---------- java代码
if (bitmap != null) {
/**
* W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (1080x4196, max=4096x4096)
* 单独的一个Bitmap太大,把其分割成2块,并分别显示在各自的ImageView里。
*/
Bitmap topBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), (int) (bitmap.getHeight() / 2.0f));
Bitmap bottomBitmap = Bitmap.createBitmap(bitmap, 0, (int) (bitmap.getHeight() / 2.0f), bitmap.getWidth(),
bitmap.getHeight() - (int) (bitmap.getHeight() / 2.0f));
mTopIv.setImageBitmap(topBitmap);
mBottomIv.setImageBitmap(bottomBitmap);
}