title: Android Convert Large view to bitmap
body: <p>I need to convert large views say(width and height as 1280x1760) to Bitmap and save the image to sdcard.But When i create views more than of size 1280x1400 my application is throwing an Exception wnen createBitmap(view.getDrawingCache()) is called.I am using 10 inch samsung tab.
  Does image pixel depend on tab pixel
  here is my code</p>
  
  <pre><code> View   view2=LayoutInflater.from(getApplicationContext()).inflate(R.layout.sample, null);
  
               LinearLayout   view=new LinearLayout(getApplicationContext());
                view.setBackgroundColor(Color.GRAY);  
                view.setOrientation(LinearLayout.VERTICAL);
               view.addView(view2,new LayoutParams(1280,1760));
  
  
                view.setDrawingCacheEnabled(true);
  
  
               view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 
                      MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
  
                view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); 
  
                view.buildDrawingCache(true);
             try{
                Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
                //Bitmap bitmap = Bitmap.createScaledBitmap(view.getDrawingCache(), 1280, 1200, true);
  
  
                //setContentView(view);   
                String path = Environment.getExternalStorageDirectory()+"/Pictures";     
  
                            File image = new File(path, "Image7.jpg");
  
                            // Encode the file as a PNG image.
                            FileOutputStream outStream=null;
  
  
                                outStream = new FileOutputStream(image);
                                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream); 
  
                                outStream.flush();
                                outStream.close();
  
                                     setContentView(view);
                            } catch (Exception e) {
                              Toast.makeText(getBaseContext(), e.getMessage(), 10).show();
  
                        }
  </code></pre>
  
  <p>and sample.xml layout is</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;ImageView
          android:id="@+id/imageView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/ic_launcher" /&gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="match_parent"
          android:layout_height="300px"
          android:text="TextView" 
          android:background="#ffff00"/&gt;
  
      &lt;Button android:layout_weight="1"
          android:id="@+id/button1"  android:background="#ff00ff"
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:text="Button" /&gt;
  
     &lt;Button android:layout_weight="1"  android:background="#ff0000"
          android:id="@+id/button2"
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:text="Button" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>here is the LOGCAT</p>
  
  <pre><code>01-21 14:26:50.381: E/AndroidRuntime(1611): FATAL EXCEPTION: main
  01-21 14:26:50.381: E/AndroidRuntime(1611): java.lang.NullPointerException
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at android.graphics.Bitmap.createBitmap(Bitmap.java:455)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at com.hunterlab.essentials.view2image.View2ImageActivity$1.Check(View2ImageActivity.java:196)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at com.hunterlab.essentials.view2image.View2ImageActivity$1.onClick(View2ImageActivity.java:79)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at android.view.View.performClick(View.java:3110)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at android.view.View$PerformClick.run(View.java:11928)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at android.os.Handler.handleCallback(Handler.java:587)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at android.os.Handler.dispatchMessage(Handler.java:92)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at android.os.Looper.loop(Looper.java:132)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at android.app.ActivityThread.main(ActivityThread.java:4025)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at java.lang.reflect.Method.invokeNative(Native Method)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at java.lang.reflect.Method.invoke(Method.java:491)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
  01-21 14:26:50.381: E/AndroidRuntime(1611):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>