Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 在windows phone 7中将WriteableBitmap图像设置为背景_Windows Phone 7_Background Image_Writeablebitmapex - Fatal编程技术网

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

Windows phone 7 在windows phone 7中将WriteableBitmap图像设置为背景,windows-phone-7,background-image,writeablebitmapex,Windows Phone 7,Background Image,Writeablebitmapex,使用WriteableBitMapExWPhone,我成功地创建了具有遮罩效果的图像,但是我想知道如何将该图像设置为我的页面背景?我的代码如下: ImageBrush imageBrush = new ImageBrush(); ImageBrush imageBrush2 = new ImageBrush(); ////load the photo WriteableBitmap bgImage = LoadBitmap

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

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

将WriteableBitmap转换为BitMapImage