surfaceview

Android canvas fill background color (Canvas application)

三世轮回 提交于 2019-12-03 14:39:26
By having the following codes, I have some questions. public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( new View(this) { Paint mPaint = new Paint(); @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); int width = this.getWidth(); int height = this.getHeight(); int radius = width > height ? height/2 : width/2; int center_x = width/2; int center_y = height/2; // prepare a paint mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(5

Android SurfaceView canvas drawing with a thread

时间秒杀一切 提交于 2019-12-03 14:36:27
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'm doing wrong, but I'm not that familiar with Treadding, has it something to do with how many cores my

How to make a crop camera view on SurfaceView Android

送分小仙女□ 提交于 2019-12-03 14:06:47
问题 I want to create an cropping application using surfaceview on the android operating system. I've made ​​a display surface for displaying direct view camera, but I still fails when I want to add a cropping feature directly on the camera display. Figure edits below this is going to accomplish: When the capture button is clicked then the images result will appear on the screen, as shown below: The following is the source code MainActivity.java package com.example.CameraPreview1; import java.io

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

偶尔善良 提交于 2019-12-03 13:52:14
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(savedInstanceState); GLSurfaceView surfaceView = new GLSurfaceView(this); setContentView(surfaceView);

Android SurfaceHolder.unlockCanvasAndPost() does not cause redraw

杀马特。学长 韩版系。学妹 提交于 2019-12-03 12:37:23
I'm implementing a fairly standard app with the Android sdk that involves drawing using the SurfaceView, SurfaceHolder, Callback setup. In my main thread (UI thread) I have no drawing or handling of the SurfaceHolder (or the canvas you retrieve with it). In a separate thread I have the following: Log.i("GAME.DrawThread", "run()"); Log.i("GAME.DrawThread", Thread.currentThread().getName()); Canvas canvas = null; try { canvas = holder.lockCanvas(); synchronized(holder) { Log.i("GAME", "draw():synchronized"); Paint paint = new Paint(); paint.setColor(R.color.draw_color); canvas.drawColor(R.color

BUG: createWindowSurface failed EGL_BAD_ALLOC

我只是一个虾纸丫 提交于 2019-12-03 10:40:43
问题 I have an application on Google Play for counting down numbers and letters. In this application I have the following activities: google sigin archivements admob service I use Google Analytics, and ACRA for error reporting. I don't use GLsurfaceView, but I use ACRA one or two times a day which gives me these errors: java.lang.RuntimeException: createWindowSurface failed EGL_BAD_ALLOC at android.view.HardwareRenderer$GlRenderer.createSurface(HardwareRenderer.java:763) at android.view

Can't configure Camera2 API for a preview

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to set a preview for camera, to use it to scan a QR code, using Camera2 API. My problem is to configure camera. This is my code: //setting the preview surface layout file <?xml version="1.0" encoding="utf-8"?> <SurfaceView android:layout_width="250dp" android:layout_height="250dp" android:id="@+id/surfaceView" android:layout_gravity="center" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android

Relationship between Surface and Canvas: Android

依然范特西╮ 提交于 2019-12-03 09:54:42
What exactly is the relationship between a Surface and Canvas. Please explain. A surface is a buffer. A Canvas holds the drawing. Views are not attached to the Canvas nor the Surface. The window is tied to a Surface and the ViewRoot asks the Surface for a Canvas that is then used by the Views to draw onto. For a detailled anwser, you can read this whole discussion , really interesting. 来源: https://stackoverflow.com/questions/3370212/relationship-between-surface-and-canvas-android

Android: Dynamically Blur Surface with Video

有些话、适合烂在心里 提交于 2019-12-03 08:29:57
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 deprecated in newer APIs. Can anyone share some insight on how a surface can be dynamically blurred? Thank

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

柔情痞子 提交于 2019-12-03 08:11:18
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(false); mMapView = new MapView(getActivity(), options); mMapView.setLayoutParams(new AbsListView