void ThreadSafeImageCapture(ContentReadyEventArgs e) { busy = false; WriteableBitmap image = BitmapFactory.New((int)Camera.AvailableResolutions.LastOrDefault().Width, (int)Camera.AvailableResolutions.LastOrDefault().Height); image.SetSource(e.ImageStream); if (Type == CameraType.FrontFacing) { image = WriteableBitmapExtensions.Flip(image, WriteableBitmapExtensions.FlipMode.Vertical); //image = WriteableBitmapExtensions.Flip(image, WriteableBitmapExtensions.FlipMode.Horizontal); } image = WriteableBitmapExtensions.Rotate(image, (int)angle); OrientedCameraImage orientedImage = new OrientedCameraImage() { Image = image, Angle = angle, Orientation = orientation }; if (Captured != null) { Captured(this, orientedImage); } }
public void Load(OrientedCameraImage newOrientedImage) { if (newOrientedImage != null) { OrientedImage = newOrientedImage; ImageBrushImage = new ImageBrush(); ImageBrushImage.ImageSource = OrientedImage.Image; ImageShape.Fill = ImageBrushImage; double ratio=Math.Max(initWidth, initHeight) / (Math.Max(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight)); Width = ratio * Math.Max(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight); Height = ratio * Math.Min(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight); ThisTransform.Rotation = OrientedImage.Angle; if (OrientedImage.Orientation== PageOrientation.PortraitDown) { Canvas.SetLeft(this, 0); Canvas.SetTop(this, Math.Max(this.ActualHeight,this.ActualWidth)); } if (OrientedImage.Orientation == PageOrientation.PortraitUp) { Canvas.SetLeft(this, Math.Min(this.ActualHeight, this.ActualWidth)); Canvas.SetTop(this, 0); } if (OrientedImage.Orientation == PageOrientation.LandscapeLeft) { Canvas.SetLeft(this,0); Canvas.SetTop(this,0); } if (OrientedImage.Orientation == PageOrientation.LandscapeRight) { Canvas.SetLeft(this, Math.Max(this.ActualHeight, this.ActualWidth)); Canvas.SetTop(this, Math.Min(this.ActualHeight, this.ActualWidth)); } // if (displayOrientation != ShootOrientation) //ImageBrushImageImageBrushImage { //compare here to ImageBitmapImage.PixelWidth > ImageBitmapImage.PixelHeight that are already the same to every pics.... //if (ImageBitmapImage.PixelWidth > ImageBitmapImage.PixelHeight) /* if (ShootOrientation == PageOrientation.LandscapeRight || ShootOrientation == PageOrientation.LandscapeLeft) { if (displayOrientation == PageOrientation.Landscape || displayOrientation == PageOrientation.LandscapeLeft) ThisTransform.Rotation = -90; if (displayOrientation == PageOrientation.LandscapeRight) ThisTransform.Rotation = 90; // WidthToLandscape(); } else { if (displayOrientation == PageOrientation.Portrait || displayOrientation == PageOrientation.PortraitUp) ThisTransform.Rotation = 90; if (displayOrientation == PageOrientation.PortraitDown) ThisTransform.Rotation = -90; // WidthToPortrait(); }*/ //} } else Debugger.Log(0,"","OrientedImage is null in"+this.ToString()); }
public void Load(OrientedCameraImage newOrientedImage) { if (newOrientedImage != null) { OrientedImage = newOrientedImage; ImageBrushImage = new ImageBrush(); ImageBrushImage.ImageSource = OrientedImage.Image; ImageShape.Fill = ImageBrushImage; double ratio = Math.Max(initWidth, initHeight) / (Math.Max(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight)); if (OrientedImage.Orientation == PageOrientation.PortraitDown) { Width = ratio * Math.Min(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight); Height = ratio * Math.Max(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight); } if (OrientedImage.Orientation == PageOrientation.PortraitUp) { Width = ratio * Math.Min(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight); Height = ratio * Math.Max(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight); } if (OrientedImage.Orientation == PageOrientation.LandscapeLeft) { Width = ratio * Math.Max(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight); Height = ratio * Math.Min(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight); } if (OrientedImage.Orientation == PageOrientation.LandscapeRight) { Width = ratio * Math.Max(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight); Height = ratio * Math.Min(OrientedImage.Image.PixelWidth, OrientedImage.Image.PixelHeight); } } else Debugger.Log(0, "", "OrientedImage is null in" + this.ToString()); }
void ThreadSafeImageCapture(ContentReadyEventArgs e) { busy = false; BitmapImage image = new BitmapImage(); image.SetSource(e.ImageStream); OrientedCameraImage orientedImage = new OrientedCameraImage() { Image = image, Angle = angle, Orientation = orientation }; if (Captured != null) { Captured(this, orientedImage); } }