Re: Create Bitmap from SurfaceView

9,860 views
Skip to first unread message

Dianne Hackborn

unread,
Mar 30, 2009, 8:48:28 PM3/30/09
to android-...@googlegroups.com
Sorry, by its nature a SurfaceView does not draw in the normal view hierarchy update system, so it won't be drawn in that.

On Mon, Mar 30, 2009 at 3:45 PM, serveace6 <phuc...@gmail.com> wrote:

It appears that you can create a bitmap from what is showing on the
screen via View.getDrawingCache() once View.setDrawingCacheEnabled()
is set to true.  But it does not seems to work for the SurfaceView.
Is there a way to do it?



--
Dianne Hackborn
Android framework engineer
hac...@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.

Dianne Hackborn

unread,
Mar 31, 2009, 3:46:40 AM3/31/09
to android-...@googlegroups.com
I don't believe so; the purpose of surface view is to provide a dedicated hardware accelerated drawing surface, which can be in an unusual format like yuv, so doing screenshots out of it is not that simple.

On Mon, Mar 30, 2009 at 11:16 PM, serveace6 <phuc...@gmail.com> wrote:

So it is not possible to take a snapshot of what is showing on the
SurfaceView?  If it is possible, how would you do it?


On Mar 30, 5:48 pm, Dianne Hackborn <hack...@android.com> wrote:
> Sorry, by its nature a SurfaceView does not draw in the normal view
> hierarchy update system, so it won't be drawn in that.
>
> On Mon, Mar 30, 2009 at 3:45 PM, serveace6 <phucs...@gmail.com> wrote:
>
> > It appears that you can create a bitmap from what is showing on the
> > screen via View.getDrawingCache() once View.setDrawingCacheEnabled()
> > is set to true.  But it does not seems to work for the SurfaceView.
> > Is there a way to do it?
>
> --
> Dianne Hackborn
> Android framework engineer

>
> 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.

serveace6

unread,
Mar 30, 2009, 6:45:45 PM3/30/09
to android-platform

Simon Depiets

unread,
Mar 30, 2009, 7:47:29 PM3/30/09
to android-...@googlegroups.com
2009/3/31 serveace6 <phuc...@gmail.com>:
I did it with an ImageView because i had the same problem you have

Worked fine with ImageView


--
Lliane aka Simon Depiets
Epita Promo 2011,42
http://www.lliane.com
A man is smoking with his girlfriend. She angers herself : "don't you
see the warning on the box ?!"
To which the man replies, "I am a programmer. I don't worry about
warnings. I only worry about errors."

serveace6

unread,
Mar 31, 2009, 2:16:32 AM3/31/09
to android-platform
So it is not possible to take a snapshot of what is showing on the
SurfaceView? If it is possible, how would you do it?

On Mar 30, 5:48 pm, Dianne Hackborn <hack...@android.com> wrote:
> Sorry, by its nature a SurfaceView does not draw in the normal view
> hierarchy update system, so it won't be drawn in that.
>
> On Mon, Mar 30, 2009 at 3:45 PM, serveace6 <phucs...@gmail.com> wrote:
>
> > It appears that you can create a bitmap from what is showing on the
> > screen via View.getDrawingCache() once View.setDrawingCacheEnabled()
> > is set to true.  But it does not seems to work for the SurfaceView.
> > Is there a way to do it?
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com

Dave Sparks

unread,
Mar 31, 2009, 11:37:51 AM3/31/09
to android-platform
In fact, there are cases where the display data for the SurfaceView
isn't even accessible to the app processor - it may be the output of a
hardware video pipeline that is composited with the display output of
the app processor through a dedicated video overlay.

serveace6

unread,
Mar 31, 2009, 6:50:09 PM3/31/09
to android-platform
Thanks for all the help!

shubh

unread,
Aug 13, 2012, 3:18:33 AM8/13/12
to android-...@googlegroups.com
did any one try http://www.droidnova.com/how-to-create-and-save-a-screenshot-from-a-surfaceview,880.html , here there are showing capture bitmap using surface view ?
Reply all
Reply to author
Forward
0 new messages