locked
what is metro class for WriteableBitmap

    Question

  • Hi ,

    I have done below coding for windwos 7 mobile application  for downloading  images ,can u please tell me  what is metro class for  below coding?

      WriteableBitmap wbSource = new WriteableBitmap(tempImage);
                                MemoryStream newStream = new MemoryStream();
                                wbSource.SaveJpeg(newStream, tempImage.PixelWidth, tempImage.PixelHeight, 0, 100);
                                image.SetSource(newStream);

    Thanks

    Sutahahr.j


    Thanks Suthahar.J

    Friday, October 26, 2012 12:43 PM

Answers

  • It depends on what you are doing. What is tempImage?

    The Windows.UI.Xaml.Media.Imaging.WriteableBitmap class can be loaded from a stream with SetSource, but it cannot be loaded from another BitmapSource (unfortunately there isn't a way for Windows Store apps to render Xaml UIElements into bitmaps).

    Once you have the image in the WritableBitmap (or in a BitmapImage) you don't need to extract the stream to put it in an Image. You can set that directly:

                BitmapImage bmp = new BitmapImage(new Uri("http://i.s-microsoft.com/global/ImageStore/PublishingImages/logos/hp/logo-lg-1x.png")); 
                img.Source = bmp;
    

    --Rob

     

            
    • Proposed as answer by Jesse Jiang Wednesday, October 31, 2012 2:55 AM
    • Marked as answer by Jesse Jiang Thursday, November 1, 2012 2:33 AM
    Sunday, October 28, 2012 12:21 AM
    Owner

All replies

  • It depends on what you are doing. What is tempImage?

    The Windows.UI.Xaml.Media.Imaging.WriteableBitmap class can be loaded from a stream with SetSource, but it cannot be loaded from another BitmapSource (unfortunately there isn't a way for Windows Store apps to render Xaml UIElements into bitmaps).

    Once you have the image in the WritableBitmap (or in a BitmapImage) you don't need to extract the stream to put it in an Image. You can set that directly:

                BitmapImage bmp = new BitmapImage(new Uri("http://i.s-microsoft.com/global/ImageStore/PublishingImages/logos/hp/logo-lg-1x.png")); 
                img.Source = bmp;
    

    --Rob

     

            
    • Proposed as answer by Jesse Jiang Wednesday, October 31, 2012 2:55 AM
    • Marked as answer by Jesse Jiang Thursday, November 1, 2012 2:33 AM
    Sunday, October 28, 2012 12:21 AM
    Owner
  • Hi,

    Thanks above coding is working fine but my question is below

    i am trying to set an image in a Windows Store Apps , The url where the image is located required Authenticator, i have a valid username and password, but i have no idea how to load the image with authenticated URl


    Thanks Suthahar.J

    Tuesday, October 30, 2012 5:15 AM
  • Hi Suthahar,

    It depends on what you mean by an authenticated URI. What sort of authentication is required? Take a look at the Web authentication broker for a way to handle some standard authentication schemes.

    --Rob

    Wednesday, October 31, 2012 4:38 AM
    Owner