I coded my service thate takes photos in my windows 8 application. I used CameraCaptureUI API. It works but the result, the image taken is mirrored : the left is in right and vice-versa. I searched in the PhotoSettings of CameraCapture and searched in the internet, but nothing.
I was thinking maybe the solution would be to rotate the bitmapimage that i save from the stream of camera. This is what i've tried till now and it's not working :/
public async Task<IPhoto> TakePhotoAsync(string filename)
{
var dialog = new CameraCaptureUI();
dialog.PhotoSettings.CroppedAspectRatio = new Size(4, 3);
dialog.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Png;
StorageFile file = await dialog.CaptureFileAsync( CameraCaptureUIMode.Photo );
if (file != null)
{
var stream = await file.OpenAsync(FileAccessMode.Read);
//create decoder and encoder
BitmapDecoder dec = await BitmapDecoder.CreateAsync(stream);
BitmapEncoder enc = await BitmapEncoder.CreateForTranscodingAsync(stream, dec);
enc.BitmapTransform.Rotation = BitmapRotation.Clockwise180Degrees;
await enc.FlushAsync();
var bitmap = new BitmapImage();
bitmap.SetSource(stream);
return new WPhotos(file);
}
return null;
}
Thank you in advance for your time and help :)
If you want to flip the image that you saved from the stream try this:
How to Verticaly Flip an BitmapImage
Basicly you should use ScaleTransform
instead of Rotation
.