在 Windows Phone 7 中将 WriteableBitmap 图像设置为背景
使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过将 WriteableBitmap 转换为 BitMapImage 并将 BitMapImage 设置为 imageBrush.ImageSource 解决了这个问题
I solved this by convert WriteableBitmap to BitMapImage and set the BitMapImage as imageBrush.ImageSource