surfaceview

Android: SurfaceView Flickering

假如想象 提交于 2020-01-07 03:05:06
问题 I am having an issue with drawing to a SurfaceView , when the bitmap images on the SurfaceView are moved, they flicker (or tear). I did not have this problem in previous iterations of my code. But now that I finally got the bitmaps to scale properly by using a separate Canvas for each bitmap, this problem started occurring. These are the important parts of my custom SurfaceView class: public class DrawingSurface extends SurfaceView implements SurfaceHolder.Callback { public DrawingSurface

Multiple Bitmap update on same android SurfaceView

牧云@^-^@ 提交于 2020-01-06 23:42:45
问题 Recently I tried to write an app which captures frame buffer from say USB camera (that need to be displayed as preview), and image processed output that need to be overlapped on the preview. Can anybody give me some pointers how to start? Moreover I need to draw some rectangle on the preview. I was trying to use multiple SurfaceView to draw but not succeeded. Can anybody help me out? 回答1: What you need it the bitmap and image view reference counting. Android keeps image data in native array,

使用Camera进行拍照

时光总嘲笑我的痴心妄想 提交于 2020-01-06 06:14:40
Android应用提供了Camera来控制拍照,使用Camera进行拍照的步骤如下: 1、调用Camera的open()方法打开相机。 2、调用Camera的getParameters()方法获取拍照参数,该方法返回一个Camera.Parameters对象。 3、调用Camera的startPreview()方法开始预览取景,在预览取景之前需要调用Camera的setPreviewDisplay(SurfaceHolder holder)方法设置使用哪个SurfaceView来显示取景图片。 4、调用Camera的setParameters(),并将Camera.Parameters对象作为参数传入,这样即可对相机的拍照参数进行控制。 5、调用Camera的startPreview()方法开始预览取景,在预览取景之前调用Camera的setPreviewDisplay(SurfaceHolder holder)方法设置使用哪个SurfaceView来显示取景图片。 6、调用Camera的takePicture()方法进行拍照。 7、结束程序时,调用Camera的stopPreview()结束取景预览,并调用release()方法释放资源。 import java.io.File; import java.io.FileNotFoundException; import java

Android Camera后台拍照

Deadly 提交于 2020-01-06 06:14:25
http://item.congci.com/item/android-camera-houtai-paizhao 有许多人希望在不让用户知道的情况下,使用Android后台Service调用摄像头拍照,网上不少资料,都讲到不预览无法实现拍照,涉及到用户隐私,属于非法调用摄像头...怎么办!!! 曾经看到一篇博文,里面有一句经典的话:没有什么是绝对的,没有什么是绕不过去的。接下来就来分析一下怎么绕过去,实现不预览拍照。 要求①:不让用户看到拍照界面 难点:预览界面必须在一个Activity上,而弹出了Activity之后,用户再傻,都知道你在干嘛,怎么办!! 思路:弹出Activity就弹出吧,咱对Activity做手脚,让他全透明,再来个全屏,和无标题栏,不就和没东西弹出来一个效果。 要点②:不预览 难点:非法调用摄像头,怎么办!!报错 "take picture failed ! !" 思路:你要在Activity上有SurfaceView进行预览,那就来一个SurfaceView,打不了咱再对SurfaceView做手脚就是 了...设这SurfaceView长和宽都为0.1 你不是要预览吗,也有,问题是预览框这么小,要是你还能看到那就没办 法了... 好了,不多说,思路有了就开始工作: 首先,用来拍照的Activity布局: < RelativeLayout xmlns

android image preview example for cropping

强颜欢笑 提交于 2020-01-05 04:12:12
问题 Many apps, such as Facebook, have this feature where after a user chooses an image from their device's gallery, the user is then brought to a preview where they can choose a cropped version of their image. After looking through SO (e.g. How to crop image on camera preview "Goggles style" - Android), I found this link to a an example, but the zip seems to be for sale ( CameraPreview.zip ). Since that post is a bit old, I was wondering if someone is aware of another example out there or if they

Android SurfaceView Preview too dark

▼魔方 西西 提交于 2020-01-05 00:48:49
问题 I'm developing an App that uses Surfaceview. I can take pictures and everything's fine. My problem is: the image of the preview is too dark. I try to change the SceneMode of the camera, but nothing is working (I've tried AUTO, NIGHT and NIGHT_PORTRAIT). Here is the difference between pictures taken with my app: and the Android Camera App (native): Here's my code (the params used on cam): c = Camera.open(0); Camera.Parameters params = c.getParameters(); params.setSceneMode(Camera.Parameters

Flickering while using surface view

笑着哭i 提交于 2020-01-04 19:00:54
问题 I am using surface view to show some graphics, the problem is that there is a flickering effect when I am moving the figure in the screen, I understand that this is due to double buffering problem, even though I went through many posts, I am unable to fix the problem, please take a look at my code and help me get this fixed. public class CustomSurfaceView extends SurfaceView implements Runnable{ Thread mThread = null; SurfaceHolder mSurfaceHolder; volatile boolean mRunning = false; Bitmap

Create cameraview (mask) on surfaceview in android

我只是一个虾纸丫 提交于 2020-01-04 17:31:55
问题 I want to create a mask on camera surface view. see image below. mask is resizable. image will be clicked only by unblurred area. can anybody give idea how to create suh mask? thanks in advance. 回答1: You can't draw on the Surface of the SurfaceView that is receiving the camera preview. You have two basic options: draw on the View part of the SurfaceView, treating it as a custom view, or create a second SurfaceView and layer it on top of the camera surface. For the latter, you would use

Create cameraview (mask) on surfaceview in android

落爺英雄遲暮 提交于 2020-01-04 17:31:01
问题 I want to create a mask on camera surface view. see image below. mask is resizable. image will be clicked only by unblurred area. can anybody give idea how to create suh mask? thanks in advance. 回答1: You can't draw on the Surface of the SurfaceView that is receiving the camera preview. You have two basic options: draw on the View part of the SurfaceView, treating it as a custom view, or create a second SurfaceView and layer it on top of the camera surface. For the latter, you would use

Android SurfaceView not responding to touch events

被刻印的时光 ゝ 提交于 2020-01-04 15:28:23
问题 I am trying to get a simple surface view to respond to touch events. The application below launches but does not respond to touch events. I have a Log.i statement to confirm (by printing to the console) whether or not the touch event is working. Can anyone tell me what I am doing wrong? This is the my main activity public class MainActivity extends Activity { public static int screenWidth, screenHeight; public static boolean running=true; public static MainSurface mySurface; @Override