1

使用 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;
4

1 回答 1

3

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

于 2011-08-26T03:03:02.190 回答