I thought I was drawing the View into the Bitmap with

screenshot = Bitmap.createBitmap(mView.getDrawingCache());
or
screenshot = Bitmap.createBitmap(mView.getDrawingCache(),
                mView.getLeft(), mView.getTop(),
                mView.getMeasuredWidth(), mView.getMeasuredHeight());

Is there another, better way?



On Jan 14, 3:33 pm, James Yum <j...@google.com> wrote:
> Just checking, have you thought about drawing the view into a Bitmap?
>
> Cheers,
> James
>
> On Wed, Jan 14, 2009 at 12:29 PM, srajpal <sraj...@gmail.com> wrote:
>
> > but i get the same error if i just pick a potion of the screen
>
> > screenshot = Bitmap.createBitmap(mView.getDrawingCache(),
> > 100,100,100,100);
>
> > or try to pass it exact size
>
> > screenshot = Bitmap.createBitmap(mView.getDrawingCache(),
> >                mView.getLeft(), mView.getTop(),
> >                mView.getMeasuredWidth(), mView.getMeasuredHeight());
>
> > any suggestions?
>
> > On Jan 14, 1:25 am, Romain Guy <romain...@google.com> wrote:
> >> Yes, you are creating a drawing cache that the system has decided is
> >> too large. In such a situation, the returned drawing cache is null.
> >> You have to account for this.
>
> >> On Tue, Jan 13, 2009 at 5:34 PM, srajpal <sraj...@gmail.com> wrote:
>
> >> > I am having an issue when trying to save a screen shot of a view to a
> >> > file.
>
> >> > I am using the following code to save the bitmap
>
> >> > Java:
>
> >> > Bitmap screenshot;
>
> >> > mView.setDrawingCacheEnabled(true);
> >> > screenshot = Bitmap.createBitmap(mView.getDrawingCache());
> >> > mView.setDrawingCacheEnabled(false);
>
> >> > try {
> >> >       FileOutputStream fos = new FileOutputStream("/sdcard/
> >> > test.png");
> >> >     screenshot.compress(Bitmap.CompressFormat.PNG, 100, fos);
> >> >     fos.close();
> >> > } catch (FileNotFoundException e) {
> >> >     Log.d("FileNotFoundException: " + e.getMessage());
> >> > } catch (IOException e) {
> >> >     Log.d("IOException: " + e.getMessage());
> >> > }
>
> >> > it works fine unless i put the following in my onCreate() to make sure
> >> > I am in full screen mode
>
> >> > Java:
>
> >> > getWindow().setFlags
> >> > (WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
>
> >> > when that code is in there I get a NullPointerException at createBitmap
> >> > ()
> >> > does anybody know why this would be happening?
> >> > _________________
> >> > --
> >> > Sunny
>
> >> --
> >> Romain Guy
> >> Android framework engineer
> >> romain...@android.com
>
> >> Note: please don't send private questions to me, as I don't have time
> >> to provide private support.  All such questions should be posted on
> >> public forums, where I and others can see and answer them
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to