protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) { base.OnMeasure(widthMeasureSpec, heightMeasureSpec); int width = MeasureSpec.GetSize(widthMeasureSpec); int height = MeasureSpec.GetSize(heightMeasureSpec); //get current settings from MirrorController mZoomRatio = MirrorController.GetInstance().GetZoomRatio();//from 1 to 4 mMirrorFlip = MirrorController.GetInstance().GetMirrorFlip();//true:flip image, flase:default if (0 == mRatioWidth || 0 == mRatioHeight) { SetMeasuredDimension(width, height); } else { int newHeight = width * mRatioHeight / mRatioWidth; Matrix mat = new Matrix(); if (mMirrorFlip) { //flip image mat.PostTranslate(-(float)(width / 2.0), -(float)(newHeight / 2.0)); mat.PostScale((float)-1.0 * mZoomRatio, (float)1.0 * mZoomRatio); mat.PostTranslate((float)(width / 2.0), (float)(newHeight / 2.0)); } else { //normal image mat.PostTranslate(-(float)(width / 2.0), -(float)(newHeight / 2.0)); mat.PostScale((float)1.0 * mZoomRatio, (float)1.0 * mZoomRatio); mat.PostTranslate((float)(width / 2.0), (float)(newHeight / 2.0)); } SetTransform(mat); mat.Reset(); SetMeasuredDimension(width, newHeight); } }
private void ChangeBrightness() { var attributes = Activity.Window.Attributes; attributes.ScreenBrightness = MirrorController.GetInstance().GetBrightness(); Activity.Window.Attributes = attributes; }
private void StopCapture() { bool toStop = MirrorController.GetInstance().ToggleCaptureStop(); if (toStop) { Toast.MakeText(Activity, Resource.String.pause, ToastLength.Short).Show(); mPreviewSession.StopRepeating(); } else { UpdatePreview(); } }
private void FlipImage() { bool isFlipped = MirrorController.GetInstance().ToggleMirrorFlip(); if (isFlipped) { Toast.MakeText(Activity, Resource.String.frip_mode, ToastLength.Short).Show(); } else { Toast.MakeText(Activity, Resource.String.mirror_mode, ToastLength.Short).Show(); } mTextureView.RequestLayout(); }
private void Darken() { MirrorController.GetInstance().Darken(); ChangeBrightness(); }
private void ZoomOut() { MirrorController.GetInstance().ZoomOut(); mTextureView.RequestLayout(); }