开发者

set WriteableBitmap image to background in windows phone 7

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开发者_C百科;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;


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜