首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在CameraCaptureTask中正确调整照片大小?

如何在CameraCaptureTask中正确调整照片大小?
EN

Stack Overflow用户
提问于 2014-04-07 11:34:01
回答 1查看 114关注 0票数 0

我使用下面的代码在我的应用程序中拍摄一张照片,但是当我接受这张照片时,图像会被拉伸,但是当我从那个页面导航时,再一次,图像分辨率是正确的,尽管图像的一部分是黑色的。我的问题是,如何才能正确地显示图像,而不拉伸它。

代码语言:javascript
复制
  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是:

代码语言:javascript
复制
 <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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-07 11:38:11

在您的xaml make = "Uniform“中,因为fill将根据容器将图像分散.

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22911247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档