本文整理汇总了C#中ISurfaceHolder类的典型用法代码示例。如果您正苦于以下问题:C# ISurfaceHolder类的具体用法?C# ISurfaceHolder怎么用?C# ISurfaceHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISurfaceHolder类属于命名空间,在下文中一共展示了ISurfaceHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
public override void OnCreate(ISurfaceHolder surfaceHolder)
{
base.OnCreate (surfaceHolder);
// By default we don't get touch events, so enable them.
SetTouchEventsEnabled (true);
}
示例2: SurfaceChanged
public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Android.Graphics.Format format, int width, int height)
{
if (surfaceHolder.Surface == null) return;
try
{
camera.StopPreview();
}
catch (Exception)
{
// ignored
}
try
{
camera.SetDisplayOrientation(90);
camera.SetPreviewDisplay(surfaceHolder);
camera.SetPreviewCallback(previewCallback);
camera.StartPreview();
}
catch (Exception e)
{
Log.Debug("Cub.Xdroid.zbar", $"SurfaceChanged: error {e}");
}
}
示例3: SurfaceCreated
public void SurfaceCreated(ISurfaceHolder holder)
{
var outputFile = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(),
"myvideooutputfile.mp4");
if (!recording)
{
mediaRecorder = new MediaRecorder();
//correctCamera();
//if (camera != null)
// mediaRecorder.SetCamera(camera);
mediaRecorder.SetAudioSource(AudioSource.Mic);
mediaRecorder.SetVideoSource(VideoSource.Camera);
mediaRecorder.SetOutputFormat(OutputFormat.ThreeGpp);
mediaRecorder.SetAudioEncoder(AudioEncoder.Aac);
mediaRecorder.SetVideoEncoder(VideoEncoder.Mpeg4Sp);
if (System.IO.File.Exists(outputFile))
System.IO.File.Delete(outputFile);
System.IO.File.Create(outputFile);
CamcorderProfile camProf = CamcorderProfile.Get(CamcorderQuality.Low);
fps = camProf.VideoFrameRate;
mediaRecorder.SetOutputFile(outputFile);
mediaRecorder.SetPreviewDisplay(holder.Surface);
mediaRecorder.Prepare();
} else
{
mediaPlayer.SetDisplay(holder);
mediaPlayer.SetDataSource(outputFile);
mediaPlayer.Prepared += new EventHandler(mediaPlayer_Prepared);
mediaPlayer.PrepareAsync();
}
}
示例4: SurfaceChanged
public void SurfaceChanged (ISurfaceHolder holder, Android.Graphics.Format format, int w, int h)
{
// If your preview can change or rotate, take care of those events here.
// Make sure to stop the preview before resizing or reformatting it.
if (holder.Surface == null) {
// preview surface does not exist
CommonSampleLibrary.Log.Debug (TAG, "Preview surface does not exist");
return;
}
// stop preview before making changes
try {
camera.StopPreview ();
CommonSampleLibrary.Log.Debug (TAG, "Preview stopped.");
} catch (Exception e) {
// ignore: tried to stop a non-existent preview
CommonSampleLibrary.Log.Debug(TAG, "Error starting camera preview: " + e.Message);
}
int orientation = CalculatePreviewOrientation (cameraInfo, displayOrientation);
camera.SetDisplayOrientation (orientation);
try {
camera.SetPreviewDisplay (holder);
camera.StartPreview ();
CommonSampleLibrary.Log.Debug (TAG, "Camera preview started.");
} catch (Exception e) {
CommonSampleLibrary.Log.Debug (TAG, "Error starting camera preview: " + e.Message);
}
}
示例5: DrawThread
public DrawThread(ISurfaceHolder holder, PointVector screenCenter, Player player)
{
mHolder = holder;
mPlayer = player;
mScreenCenter = screenCenter;
UpdateInterval = 1000 / 60;
}
示例6: SurfaceCreated
public void SurfaceCreated(ISurfaceHolder holder)
{
mediaPlayer.SetDisplay(holder);
mediaPlayer.SetDataSource(filename);
mediaPlayer.Prepared += new EventHandler(mediaPlayer_Prepared);
mediaPlayer.PrepareAsync();
}
示例7: SurfaceDestroyed
public void SurfaceDestroyed(ISurfaceHolder holder)
{
if (aNativeWindow != IntPtr.Zero)
NativeMethods.ANativeWindow_release (aNativeWindow);
aNativeWindow = IntPtr.Zero;
}
示例8: SurfaceChanged
void ISurfaceHolderCallback.SurfaceChanged(ISurfaceHolder holder, Android.Graphics.Format format, int width, int height)
{
if ((int)Android.OS.Build.VERSION.SdkInt >= 19)
{
if (!_isSurfaceChanged)
{
_isSurfaceChanged = true;
_prevSurfaceWidth = width;
_prevSurfaceHeight = height;
}
else
{
// Forcing reinitialization of the view if SurfaceChanged() is called more than once to fix shifted drawing on KitKat.
// See https://github.com/mono/MonoGame/issues/2492.
if (!ScreenReceiver.ScreenLocked && Game.Instance.Platform.IsActive &&
(_prevSurfaceWidth != width || _prevSurfaceHeight != height))
{
_prevSurfaceWidth = width;
_prevSurfaceHeight = height;
base.SurfaceDestroyed(holder);
base.SurfaceCreated(holder);
}
}
}
SurfaceChanged(holder, format, width, height);
Android.Util.Log.Debug("MonoGame", "MonoGameAndroidGameView.SurfaceChanged: format = " + format + ", width = " + width + ", height = " + height);
if (_game.GraphicsDevice != null)
_game.graphicsDeviceManager.ResetClientBounds();
}
示例9: AcquireNativeWindow
void AcquireNativeWindow(ISurfaceHolder holder)
{
if (aNativeWindow != IntPtr.Zero)
NativeMethods.ANativeWindow_release (aNativeWindow);
aNativeWindow = NativeMethods.ANativeWindow_fromSurface (JniEnvironment.EnvironmentPointer, Holder.Surface.Handle);
NativeWindowAcquired ();
}
示例10: SurfaceCreated
public void SurfaceCreated(ISurfaceHolder holder)
{
this.holder = holder;
var canvas = holder.LockCanvas();
canvas.DrawColor(Android.Graphics.Color.Aquamarine);
holder.UnlockCanvasAndPost(canvas);
}
示例11: CameraPreview
/// <summary>
/// Default ctor
/// </summary>
public CameraPreview(Context context, Camera camera)
: base(context)
{
this.camera = camera;
surfaceHolder = GetHolder();
surfaceHolder.AddCallback(this);
surfaceHolder.SetType(ISurfaceHolderConstants.SURFACE_TYPE_PUSH_BUFFERS);
}
示例12: SurfaceCreated
public void SurfaceCreated(ISurfaceHolder holder)
{
Log.Info("PERSPEX", "Surface Created");
_renderTarget =
PerspexLocator.Current.GetService<IPlatformRenderInterface>()
.CreateRenderer(new PlatformHandle(holder.Surface.Handle, "Surface"));
Draw();
}
示例13: SurfaceDestroyed
public void SurfaceDestroyed(ISurfaceHolder holder)
{
if (!isPhotoTaken)
{
camera.StopPreview();
camera.Release();
previewing = false;
}
}
示例14: SurfaceCreated
public void SurfaceCreated (ISurfaceHolder holder)
{
if (camera == null) {
this.camera = Android.Hardware.Camera.Open ();
this.camera.SetPreviewDisplay (holder);
this.camera.SetPreviewCallback (this);
this.camera.StartPreview ();
}
}
示例15: SurfaceCreated
public void SurfaceCreated (ISurfaceHolder holder)
{
try {
if (Preview != null) {
Preview.SetPreviewDisplay (holder);
}
} catch (Exception ex) {
System.Diagnostics.Debug.WriteLine (@" ERROR: ", ex.Message);
}
}