我使用下面的代码在我的应用程序中拍摄一张照片,但是当我接受这张照片时,图像会被拉伸,但是当我从那个页面导航时,再一次,图像分辨率是正确的,尽管图像的一部分是黑色的。我的问题是,如何才能正确地显示图像,而不拉伸它。
CameraCaptureTask cam = new CameraCaptureTask();
cam.Completed += task_Completed;
cam.Show();
void task_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
bmp.SetSource(e.ChosenPhoto);
imgProfilePic.ImageSource = bmp;
}xaml是:
<Button HorizontalAlignment="Center"
toolkit:TurnstileFeatherEffect.FeatheringIndex="2"
toolkit:TiltEffect.IsTiltEnabled="True"
x:Name="btnprofilepic"
Width="250"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
MouseLeave="btnprofilepic_MouseLeave"
Tap="imgProfilePic_Tap"
Margin="0,20,0,20"
Height="200" BorderThickness="0"
MouseLeftButtonUp="btnprofilepic_MouseLeftButtonUp"
MouseLeftButtonDown="btnprofilepic_MouseLeftButtonDown">
<Button.Background>
<ImageBrush x:Name="imgProfilePic"
Stretch="Fill" />
</Button.Background>
</Button>发布于 2014-04-07 11:38:11
在您的xaml make = "Uniform“中,因为fill将根据容器将图像分散.
https://stackoverflow.com/questions/22911247
复制相似问题