ImageBrush 问题 Windows Phone 8.1

ImageBrush issue Windows Phone 8.1

我需要在 windows phone 通用应用程序中创建一个圆形图像。

为了创建这种图像,我使用了以下代码:

<Border CornerRadius="30" Height="60" Width="60">
    <Border.Background>
            <ImageBrush ImageSource="ms-appx:///Assets/round_image.png" />
    </Border.Background>
</Border>

但是这段代码对内存的影响很大,每张图片大约需要4Mb。 使用此代码解决了问题,但图像不圆。

<Border CornerRadius="30" Height="60" Width="60">
        <Image Source="ms-appx:///Assets/round_image.png" Stretch="Fill" />
</Border>

我需要显示20张图片,这2种方式相差80mb左右。

这个内存问题有解决方案吗?

尝试以下操作:

<Border CornerRadius="30" Height="60" Width="60">
    <Border.Background>
            <ImageBrush>
                <ImageBrush.ImageSource>
                    <BitmapImage
                        UriSource="ms-appx:///Assets/round_image.png" 
                        DecodePixelWidth="60"
                        DecodePixelHeight="60"
                        DecodePixelType="Logical"/>
                </ImageBrush.ImageSource>
            </ImageBrush>
    </Border.Background>
</Border>

问题可能是您的图片太大了。这会将图像解码为实际显示大小,如果原始图像太大,这将提高渲染性能。