surfaceview

android中SurfaceView组件使用解析

不打扰是莪最后的温柔 提交于 2019-12-09 14:52:51
SurfaceView组件可以实现高效率的绘制二维图或者显示图像,在游戏开发中经常用到。在android中,已经提供了SurfaceView组件。使用时,一般是通过继承的方法实现自定义surfaceView,也可以在MainActivity中通过接口surfaceHolder.callback接口实现,这里介绍通过接口实现surfaceView绘图,当然,绘图可以是静态图(在指定区域只绘制一次),也可以是动态图(指定区域-->绘制-->再循环)。 SurfaceView组件的使用流程:通过findViewById()实例化SurfaceView组件,得到实例化对象;利用getHolder()方法得到SurfaceViewHolder类对象,为该对象添加callBack(Context context)回调;在surfaceCreate()方法中添加surfaceView刚显示的初始化代码,这个方法在实例化SurfaceView组件时执行,比如可以初始化背景颜色,绘图区显示出的形状、坐标等;surfaceChanged()方法主要是在surfaceView对象大小、形状改变时调用;surfaceDestroyed()方法是在surfaceView销毁时调用,一般是添加kill代码。 在SurfaceView组件显示区域上,实现绘制二维图形需要三个类:Paint

Fastest way to draw a MediaCodec-decoded video frame to screen?

风格不统一 提交于 2019-12-09 11:46:58
问题 I'm looking for the fastest way to take an image frame received from the MediaCodec decoder and draw it to the Android device screen. The important constraints and explanations are: Cannot use MediaPlayer. No intermediate app allowed. Must draw output frames from the MediaCodec decoder to the screen as quickly as possible (minimize latency). The available decoder output formats are as follows: ColorFormat[0] 0x00000013 COLOR_FormatYUV420Planar ColorFormat[1] 0x00000015 COLOR

Android中surfaceView的使用(转载)

霸气de小男生 提交于 2019-12-09 10:57:50
首先我们先来看下官方API对SurfaceView的介绍 SurfaceView的API介绍 Provides a dedicated drawing surface embedded inside of a view hierarchy. You can control the format of this surface and, if you like, its size; the SurfaceView takes care of placing the surface at the correct location on the screen The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed. The view hierarchy will take care of correctly compositing with the Surface any siblings of the SurfaceView that would normally appear on top of it. This

Android之SurfaceView学习

本小妞迷上赌 提交于 2019-12-09 10:57:35
首先我们先来看下官方API对SurfaceView的介绍 SurfaceView的API介绍 Provides a dedicated drawing surface embedded inside of a view hierarchy. You can control the format of this surface and, if you like, its size; the SurfaceView takes care of placing the surface at the correct location on the screen The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed. The view hierarchy will take care of correctly compositing with the Surface any siblings of the SurfaceView that would normally appear on top of it. This

Android SurfaceView

不问归期 提交于 2019-12-09 10:57:23
SurfaceView 是View的继承类,这个视图里内嵌了一个专门用于绘制的Surface。可以控制这个Surface的格式和尺寸。SurfaceView控制这个Surface的绘制位置 SurfaceView:基于view视图进行拓展的视图类,更适合2D游戏的开发;是view的子类,类上使用双缓冲机制,在新的线程中更新画面所以新界面速度比view快。 Surface是纵深排序的,这说明它总在自己所在的窗口的后面。SurfaceView 提供了一个可见区域,只有在这个可见区域内的surface部分内容才可见,可见区域外部部分不可 见。surface的排版显示受到视图层级关系的影响,它的兄弟节点会在顶端显示。这意味者surface的内容会被它的兄弟视图遮挡,这一特性可以用来放置遮盖物(overlays)(例如:文本和按钮等控件)。但是,当surface上面有透明控件时,它的每次变化都会引起框架重新计算它和顶层控件的透明效果,这会影响性能。可以通过SurfaceHolder接口访问这个surface,getHolder()方法可以得到这个接口 Surfaceview变的可见时,surface被创建,surfaceView隐藏前,surface被毁灭。这样可以节省资源。surface创建:surfaceCreated(SurfaceHolder)和surfaceDestroyed

android大扫盲之SurfaceView,SurfaceHolder,SurfaceHol...

喜你入骨 提交于 2019-12-09 10:56:57
最近接触到了SurfaceView,SurfaceHolder,SurfaceHolder.CallBack,一直不求其解,现在来粗浅认识一下它们。 先看一下官方的定义: 1.SurfaceView SurfaceView是视图(View)的继承类,这个视图里内嵌了一个专门用于绘制的Surface。你可以控制这个Surface的格式和尺寸。Surfaceview控制这个Surface的绘制位置。 surface是纵深排序(Z-ordered)的,这表明它总在自己所在窗口的后面。surfaceview提供了一个可见区域,只有在这个可见区域内 的surface部分内容才可见,可见区域外的部分不可见。surface的排版显示受到视图层级关系的影响,它的兄弟视图结点会在顶端显示。这意味者 surface的内容会被它的兄弟视图遮挡,这一特性可以用来放置遮盖物(overlays)(例如,文本和按钮等控件)。注意,如果surface上面 有透明控件,那么它的每次变化都会引起框架重新计算它和顶层控件的透明效果,这会影响性能。 你可以通过SurfaceHolder接口访问这个Surface.用getHolder()方法可以得到这个接口。 surfaceview变得可见时,surface被创建;surfaceview隐藏前,surface被销毁。这样能节省资源。如果你要查看

Android之SurfaceView学习(一)

∥☆過路亽.° 提交于 2019-12-09 10:56:14
Android之SurfaceView学习(一) 首先我们先来看下官方API对SurfaceView的介绍 SurfaceView的API介绍 Provides a dedicated drawing surface embedded inside of a view hierarchy. You can control the format of this surface and, if you like, its size; the SurfaceView takes care of placing the surface at the correct location on the screen The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed. The view hierarchy will take care of correctly compositing with the Surface any siblings of the SurfaceView that would normally

How to get a SurfaceHolder with a valid Surface (needed by EGL.eglCreateWindowSurface)?

社会主义新天地 提交于 2019-12-09 10:18:53
问题 I try to initialize GLES with EGL (because I want to draw from the main thread instead of using a Renderer and drawing from inside onDrawFrame). I get the error: "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface". Obviously mEgl.eglCreateWindowSurface fails because surfaceHolder has not a valid surface. How do I get a SurfaceHolder with a valid Surface to proceed? My Activity.onCreate method is: protected void onCreate(Bundle savedInstanceState) { super.onCreate

How to count the Framerate with which a SurfaceView refreshes?

喜欢而已 提交于 2019-12-09 07:13:24
问题 I have a third party framework that shows video on a SurfaceView. I would like to measure the framerate of the video to check if the phone is capable of showing the video fast enough, or if I need to use another solution to show the information to the user. How can I measure the speed with that a SurfaceView is updated? 回答1: If the code is not clear just ask. LinkedList<Long> times = new LinkedList<Long>(){{ add(System.nanoTime()); }}; @Override protected void onDraw(Canvas canvas) { double

New gms.maps.MapView rendering lags a bit when in a ListView?

我的未来我决定 提交于 2019-12-09 05:58:05
问题 I'm trying to put an instance of the new MapView in a ListView. New mapview being: com.google.android.gms.maps.MapView I'm turning all interactions off, and setting a fixed height for the view: GoogleMapOptions options = new GoogleMapOptions(); options.mapType(GoogleMap.MAP_TYPE_NORMAL); options.compassEnabled(false); options.rotateGesturesEnabled(false); options.scrollGesturesEnabled(false); options.tiltGesturesEnabled(false); options.zoomControlsEnabled(false); options.zoomGesturesEnabled