Reputation: 21
I've created very simple android application which display image. Code:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/textView1"
android:scaleType="matrix"
android:src="@drawable/img_big_size"
/>
</RelativeLayout>
Furthermore I have two the same pictures ,first img_big_size.jpg(size 468 KB) and second img_small_size.jpg(size 192 KB). The first image has a higher resolution so it takes more memory than second image. When I try display second image(img_small_size.jpg) application works fine and display image. But when I try display fist image(img_small_size.jpg) application don't display image only show black screen. Why my application can't display first image?? How display first image?
I want to display first image because when I zoom image first the picture is more clear than second image.
Link to images: http://zapodaj.net/2096f7cc62055.jpg.html
http://zapodaj.net/cf7233054f2fc.jpg.html
Upvotes: 1
Views: 2433
Reputation: 2230
Your big image size dimen is : 1571x2166
OpenGLRenderer hardware Acceleration cannot handle bitmap larger than 2048x2048. You can try to disable hardware Acceleration by defining android:hardwareAccelerated="false" inside in AndroidManifest.xml file.
<application
android:hardwareAccelerated="false"
android:largeHeap="true" >
or for your best performance, you can resize your image before displaying it. reserving large heap will significantly decrease your app performance.
Upvotes: 4