surfaceview

Using a ViewPager over a CameraPreview

浪尽此生 提交于 2019-12-21 06:25:24
问题 I've been trying to create a Camera Preview that displays a View Pager with several transparent images over the preview. But, I'm getting this error: 05-10 03:31:23.614: E/AndroidRuntime(674): FATAL EXCEPTION: main 05-10 03:31:23.614: E/AndroidRuntime(674): java.lang.NullPointerException 05-10 03:31:23.614: E/AndroidRuntime(674): at com.android.gs1.MainActivity$CameraPreview.surfaceCreated(MainActivity.java:102) 05-10 03:31:23.614: E/AndroidRuntime(674): at android.view.SurfaceView

Pausing threads properly onPause() and onResume() with a SurfaceView and Thread in Android

被刻印的时光 ゝ 提交于 2019-12-21 06:08:06
问题 To run the games that I've created on Android, I've been using a GamePanel contains the methods onDraw() and onTouch(). I also have been using a GameThread class that calls onDraw() and update() repeatedly. My activity instantiates the GamePanel and my GamePanel instantiates the GameThread. My onPause() just sets the condition in the while-loop inside the thread, run, to false. My onResume() used to just set that equal to true, however that would give me a force close error ( see edit #1 )

Rotate bitmap in fixed point like a clock hand in SurfaceView

核能气质少年 提交于 2019-12-21 05:30:28
问题 I have an image in drawable folder for clock hand. I want to rotate it in fixed point like a clock hand. I have tried below code which rotates the hand in circular path around a fixed point but not as like clock hand. Matrix matrix = new Matrix(); matrix.reset(); matrix.preTranslate(0, 0); matrix.postRotate(angleRotation, -0, -0); matrix.postTranslate(240, 480); canvas.drawColor(Color.WHITE); canvas.drawBitmap(bitmap, matrix, null); I am struggling for hours to get it sorted out. Any help

Android VideoView not playing sequential videos

試著忘記壹切 提交于 2019-12-21 05:04:38
问题 I want to play 2 videos in a row. The first video always plays just fine. After it finishes, you can see in the log that it sets the new video URL, but then SurfaceView throws an error and the VideoView just freezes with the last frame of the first video. Nothing else happens. Any thoughts ? Thanks ! LE: Surprisingly, the OnPreparedListener gets called for the second video. LE2: Sometimes the second video plays just fine, sometimes it doesn't... and I haven't changed a line of code between

Android SurfaceView canvas drawing with a thread

这一生的挚爱 提交于 2019-12-21 04:52:17
问题 I am experimenting with drawing on a canvas using a thread to create a simple game engine but I'm having some weird issues I cannot explain. The purpose of this "game" is to draw a circle every second on the canvas. This works, but not the way I want it to work, it seems the app is switching between two canvasses and adding a circle to each canvas so you get a switch between two canvasses every second with the same number of circles but in a different place on the canvas. I don't know what I

Color banding only on Android 4.0+

落爺英雄遲暮 提交于 2019-12-21 03:37:06
问题 On emulators running Android 4.0 or 4.0.3, I am seeing horrible colour banding which I can't seem to get rid of. On every other Android version I have tested, gradients look smooth. I have a SurfaceView which is configured as RGBX_8888, and the banding is not present in the rendered canvas. If I manually dither the image by overlaying a noise pattern at the end of rendering I can make the gradients smooth again, though obviously at a cost to performance which I'd rather avoid. So the banding

Android: Dynamically Blur Surface with Video

爱⌒轻易说出口 提交于 2019-12-21 02:34:16
问题 I am building an Android application where an ExoPlayer plays a video onto the surface of a SurfaceView, and I am investigating whether it is possible to dynamically blur the playing video. Blurring techniques that involve first generating a bitmap of the view to blur will not work, since the surface part of a SurfaceView does not appear in bitmaps. Surfaces and views used to have built-in blurring effects in older versions of Android (e.g. Surface.FX_SURFACE_BLUR), but seem to have been

Draw Rectangle on SurfaceView

一个人想着一个人 提交于 2019-12-20 09:24:28
问题 I would like to know how to draw a rectangle in specific position and size. I tried a couple of trials and examples here and on web, but nothing worked for me. I'm using a SurfaceView and SurfaceHolder to hold the camera preview. I just want to draw a rectangle when the user touch on the screen. I don't want to use external library and When I'm trying to get the canvas from the holder I'm getting null. For now there is no code, cause nothing work for me, if someone has a clue how to do it, I

Android Development: Combining small tiles/bitmaps into one bitmap

主宰稳场 提交于 2019-12-20 03:09:58
问题 Im trying to get all my small images like grass, water and asphalt and so on, into one bitmap. I have an Array that goes like this: public int Array[]={3, 1, 3, 3, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ,1 ,1, 1, 1 ,1 ,1 ,7 ,7 ,7, 7, 7 ,7, 7 ,7 ,7, 7 ,7 ,7 ,7 ,7, 7 ,7, 7 ,7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7, 7, 7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7 ,7 ,7 ,7 ,7 ,7 ,7 ,7 ,7, 7, 7, 7 ,7 ,7, 7 ,6, 6, 6, 6, 6 ,6 ,6, 6, 6 ,6 ,6, 6, 6 ,6, 6, 6 ,6, 6 ,6 ,6 }; So basicly this is a 10*10 Every number is

视频直播技术——帧概念

。_饼干妹妹 提交于 2019-12-19 13:13:21
一、前言   在 Android 音视频开发学习思路 中,我们不断的学习和了解音视频相关的知识,随着知识点不断的学习,我们现在应该做的事情,就是将知识点不断的串联起来。这样才能得到更深层次的领悟。通过整理 Android 音视频开发(一) : 通过三种方式绘制图片 我们知道可以使用ImageView和SurfaceView甚至是View来展示图片,通过整理 Android 音视频开发(三):使用 AudioTrack 播放PCM 音频 我们知道如何播放音频原始数据了。那么可不可以定义为,我们找到了如何播放音视频的最基本的方式呢?答,当然是的!在 JavaCV 学习(一):JavaCV 初体验 里,我们接触了一次JavaCV,发现里面提供的API相当丰富,尤其是图形图像处理方面,那么下面我们就基于JavaCV加上它提供的ffmpegAPi工具,来完成一个基本的拉流播放器的制作,鉴于起名很难,我们先把名字起好:NBPlayer。 二、设计方案 我们要做的是一个简单的拉流播放器,需要具备以下功能: 将直播流拉取到设备上并展现出来; 保证播放当前直播流的音视频是同步的; 播放视频时可以切换全屏幕与非全屏; 三、定义播放器的生命周期 在定义播放器的生命周期们需要做到以下两步:1. 先定义一下播放器的事件 2. 定义播放器展示的控件 1. 定义播放器事件 因为我们要做的就是一个播放器