Windows phone 7 在windows phone 7中将WriteableBitmap图像设置为背景
使用WriteableBitMapExWPhone,我成功地创建了具有遮罩效果的图像,但是我想知道如何将该图像设置为我的页面背景?我的代码如下: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
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