-
public class TextureCameraPreview extends CameraPreview<TextureView, SurfaceTexture>
A preview implementation based on TextureView. Better than SurfaceCameraPreview but much less powerful than GlCameraPreview.
-
-
Constructor Summary
Constructors Constructor Description TextureCameraPreview(Context context, ViewGroup parent)
-
Method Summary
Modifier and Type Method Description ViewgetRootView()For testing purposes, should return the root view that was inflated into theparent during onCreateView. Class<SurfaceTexture>getOutputClass()Returns the type of the output returned by getOutput. SurfaceTexturegetOutput()Returns the output surface object (for example a SurfaceHolderor a SurfaceTexture). booleansupportsCropping()Whether this preview implementation supports cropping.The base implementation does not, but it is strongly recommended to do so. voidsetDrawRotation(int drawRotation)Should be called after setStreamSize!Sets the rotation, if any, to be applied when drawing. -
Methods inherited from class com.otaliastudios.cameraview.preview.CameraPreview
getOutput, getOutputClass, getSurfaceSize, getView, hasSurface, isCropping, onDestroy, onPause, onResume, setDrawRotation, setStreamSize, setSurfaceCallback -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getRootView
@NonNull() View getRootView()
For testing purposes, should return the root view that was inflated into theparent during onCreateView.
-
getOutputClass
@NonNull() Class<SurfaceTexture> getOutputClass()
Returns the type of the output returned by getOutput.
-
getOutput
@NonNull() SurfaceTexture getOutput()
Returns the output surface object (for example a SurfaceHolderor a SurfaceTexture).
-
supportsCropping
boolean supportsCropping()
Whether this preview implementation supports cropping.The base implementation does not, but it is strongly recommended to do so.
-
setDrawRotation
void setDrawRotation(int drawRotation)
Should be called after setStreamSize!Sets the rotation, if any, to be applied when drawing.Sometimes we don't need this:- In Camera1, the buffer producer sets our Surface size and rotates it based on the valuethat we pass to setDisplayOrientation,so the stream that comes in is already rotated (if we apply SurfaceTexture transform).- In Camera2, for android.view.SurfaceView based previews, apparently it just worksout of the box. The producer might be doing something similar.But in all the other Camera2 cases, we need to apply this rotation when drawing the surface.Seems that Camera1 can correctly rotate the stream/transform to VIEW,while Camera2, that does not have any rotation API, will only rotate to BASE.That's why in Camera2 this angle is set as the offset between BASE and VIEW.
- Parameters:
drawRotation- the rotation in degrees
-
-
-
-