surfaceholder

Change size of Android custom SurfaceView

╄→尐↘猪︶ㄣ 提交于 2019-12-05 18:46:11
I'm trying to create a 2D game engine for an Android app. I've followed this tutorial , which works fine for creating a full screen display, but I don't want that. I want to make my view take the top 2/3 (or whatever) of the screen, and fill the bottom third with standard Android widgets (buttons, text entry, etc.). I cannot get this to work. The best I can get is a blank white screen. I've tried many permutations, including using an outer LinerLayout, then embedding the custom SurfaceView inside a nested RelativeLayout, and putting the Android widgets in a nested LinearLayout, and it doesn't

LiveWallpaper with SurfaceHolder.lockCanvas(Rect dirty)

不羁的心 提交于 2019-12-05 10:36:43
I would like to ask about a problem that has been addressed here once or twice, but none of information I found could help me overcome the problem I faced a few days ago. I want to make a live wallpaper for android using canvases - it is not graphically complicated enough to require OpenGL. For simplicity assume it consists of solid background and two smaller rectangles. Drawing consists of three separate stages (in single thread): backgroundDraw() requests entire canvas lock and draws on it solid color draw1() requests partial (Rect r1) lock and draws only on locked rectangle draw2() requests

Get RGB from a SurfaceView displaying Live camera

时间秒杀一切 提交于 2019-12-05 01:34:36
问题 I am displaying a live camera in SurfaceView using camera.startPreview(); . Any idea on how I can get live RGB readings from the camera? Thanks 回答1: I thought I could get the data converted from the SurfaceView . But the best method to use is : Set the camera's orientation to 90 degrees. Set output format to NV21 (which is guranteed to be supported on all devices). Set to turn the Flash ON. Start preview in the SurfaceView . List item camera = Camera.open(); cameraParam = camera.getParameters

Android Camera - app passed NULL surface

会有一股神秘感。 提交于 2019-12-05 00:33:10
Whenever I run the cam_thread I get the error "app passed NULL surface". This code supposedly works on the HTC Incredible 1. I've reconfigured it slightly to run on a droid x. However I still get this error. public class Android_Activity extends Activity { Main_thread simulator; ToggleButton togglebutton; EditText ip_text; SensorManager sm = null; SurfaceView view; Sensors_thread the_sensors=null; String IP_address; Android_Activity the_app; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); view = new SurfaceView

java.io.IOException: setDataSource failed.: status=0x80000000

白昼怎懂夜的黑 提交于 2019-12-04 23:51:18
I am trying to play url using media player in activity using: mediaPlayer = MediaPlayer.create(getApplicationContext(), Uri.parse("http://www.pocketjourney.com/downloads/pj/video/famous.3gp"), holder); It's working fine. Same code I use to set it as an live wallpaper in @onSurfaceCreated in WallpaperService , it's giving me following error log D/MediaPlayer( 4128): create failed: D/MediaPlayer( 4128): java.io.IOException: setDataSource failed.: status=0x80000000 D/MediaPlayer( 4128): at android.media.MediaPlayer._setDataSource(Native Method) D/MediaPlayer( 4128): at android.media.MediaPlayer

Reopening camera after intent chooser is canceled

一世执手 提交于 2019-12-04 09:35:07
I have created a custom camera preview view CameraView which extends SurfaceView , and it also implements SurfaceHolder.Callback interface. The view operates with the camera. When you open the view it shows a camera preview. On the same screen there is also overlay with two buttons - 'Take picture', 'Choose from gallery'. The activity that holds the CameraView releases and reopens the camera in onPause() and onResume() methods. If I click the 'Choose from gallery' button, the following intent is created: Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*");

Can't set video quality for media recorder.video produces flickering video

时光总嘲笑我的痴心妄想 提交于 2019-12-04 08:01:32
mMediaRecorder = new MediaRecorder(); // Step 1: Unlock and set camera to MediaRecorder mCamera.unlock(); mMediaRecorder.setCamera(mCamera); // Step 2: Set sources // activate this for recording with sound\ mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mMediaRecorder.setVideoSize(getMaxSupportedVideoSize().width,getMaxSupportedVideoSize().height); mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); mMediaRecorder.setAudioEncoder

Get RGB from a SurfaceView displaying Live camera

家住魔仙堡 提交于 2019-12-03 17:01:00
I am displaying a live camera in SurfaceView using camera.startPreview(); . Any idea on how I can get live RGB readings from the camera? Thanks I thought I could get the data converted from the SurfaceView . But the best method to use is : Set the camera's orientation to 90 degrees. Set output format to NV21 (which is guranteed to be supported on all devices). Set to turn the Flash ON. Start preview in the SurfaceView . List item camera = Camera.open(); cameraParam = camera.getParameters(); cameraParam.setPreviewFormat(ImageFormat.NV21); camera.setDisplayOrientation(90); camera.setParameters

How to show the camera preview on a SurfaceView?

别等时光非礼了梦想. 提交于 2019-12-03 05:55:21
问题 I am trying to open the camera hardware on a SurfaceView. In the layout, I created a SurfaceView and I open the camera as shown in the code below. When I run the code, the toast in the CameraAvailableCB shows up and says "onCameraAvailable" but nothing appears on the SurfaceView. How do I show the camera display on the SurfaceView? Code @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.mBtnCapture =

How to show the camera preview on a SurfaceView?

大憨熊 提交于 2019-12-02 19:18:48
I am trying to open the camera hardware on a SurfaceView. In the layout, I created a SurfaceView and I open the camera as shown in the code below. When I run the code, the toast in the CameraAvailableCB shows up and says "onCameraAvailable" but nothing appears on the SurfaceView. How do I show the camera display on the SurfaceView? Code @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.mBtnCapture = (Button) findViewById(R.id.actMain_btn_capture); this.mSurfaceView = (SurfaceView) findViewById(R.id