I am using SurfaceView with SurfaceHolder to start by previewing the camera in my test application.
public class TextLocatorActivity extends Activity { private Preview pvw; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); pvw = new Preview(this); setContentView(pvw); }
I want to use CameraPreview (comes with Samples SDK for SDK version 7). Clicking on the user interface takes a picture. Here's the Preview class:
public class Preview extends SurfaceView implements OnClickListener, SurfaceHolder.Callback { SurfaceHolder holder; Camera cam; final static String TAG = "TextLocator:Preview"; Preview(Context context) { super(context); holder = getHolder(); holder.addCallback(this); this.setOnClickListener(this);
}
Next, I try to make some additional picture appropriate to the Canvas SurfaceHolder . So I call canvas = holder.lockCanvas() . This will IllegalArgumentException with the message:
Surface type is SURFACE_TYPE_PUSH_BUFFERS
Now docs report that these surface types are outdated, the set value will be ignored. However, the camera preview only works if I set the type to this particular value.
How can I achieve a Canvas drawing in a SurfaceView , the image is displayed? Or should it be placed in another layer / view?
rdoubleui
source share