在 Windows Phone 7 中将 WriteableBitmap 图像设置为背景

发布于 2024-12-01 15:22:06 字数 992 浏览 0 评论 0原文

使用 WriteableBitMapExWPhone 我成功创建了具有遮罩效果的图像,但是我想知道如何将该图像设置为我的页面背景?我的代码如下:

            ImageBrush imageBrush = new ImageBrush();
        ImageBrush imageBrush2 = new ImageBrush();

        ////load the photo
        WriteableBitmap bgImage = LoadBitmap("/Music;component/Images/MainPage/covertart_bg.jpg");
        WriteableBitmap mask = LoadBitmap("/Music;component/Images/MainPage/mask_bg.png");

        //instantiate the empty parts for composition
        Rect cRect = new Rect(0, 0, bgImage.PixelWidth, bgImage.PixelHeight);
        //mask the photo
        bgImage.Blit(cRect, mask, cRect, WriteableBitmapExtensions.BlendMode.Mask);

        //My code is working as I can set the bgImage to BlitImage (this is the image control)
        BlitImage.Source = bgImage;

        //I want to set bgImage as my Panorama background, but the code below doesn't do the trick
        imageBrush2.ImageSource = bgImage;
        mainPanorama.Background = imageBrush2;

using the WriteableBitMapExWPhone I have successful create the image with mask effect, however I wonder how can I set that image to be my page background? My code below:

            ImageBrush imageBrush = new ImageBrush();
        ImageBrush imageBrush2 = new ImageBrush();

        ////load the photo
        WriteableBitmap bgImage = LoadBitmap("/Music;component/Images/MainPage/covertart_bg.jpg");
        WriteableBitmap mask = LoadBitmap("/Music;component/Images/MainPage/mask_bg.png");

        //instantiate the empty parts for composition
        Rect cRect = new Rect(0, 0, bgImage.PixelWidth, bgImage.PixelHeight);
        //mask the photo
        bgImage.Blit(cRect, mask, cRect, WriteableBitmapExtensions.BlendMode.Mask);

        //My code is working as I can set the bgImage to BlitImage (this is the image control)
        BlitImage.Source = bgImage;

        //I want to set bgImage as my Panorama background, but the code below doesn't do the trick
        imageBrush2.ImageSource = bgImage;
        mainPanorama.Background = imageBrush2;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最初的梦 2024-12-08 15:22:06

我通过将 WriteableBitmap 转换为 BitMapImage 并将 BitMapImage 设置为 imageBrush.ImageSource 解决了这个问题

I solved this by convert WriteableBitmap to BitMapImage and set the BitMapImage as imageBrush.ImageSource

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文