Load and display image from an url (async)

Topics: Windows Phone 8
Feb 21, 2014 at 9:24 AM
I want to load and display some image for my game from internet. Please give me some lines of code to do it? I tried Texture2D.FromStream but not work. Thanks totallyevil.
Coordinator
Feb 24, 2014 at 1:21 AM
Download the image to a file that exists in the title container. Then use the path of the file in the title container to load the texture. That should do it. Otherwise, load the image into a memory buffer and send that stream to the texture ctor.
Coordinator
Feb 24, 2014 at 1:22 AM
see this post:

https://cocos2dxna.codeplex.com/discussions/529121

this should help you to setup code to download an image from a URL.
Feb 25, 2014 at 8:50 AM
I downloaded image but texture was loaded by XNB format image in WP8. If I download an image from url and save file png, please show me how to convert xnb codebehind, and use next time do display form ingame cocos2d xna?
Coordinator
Feb 27, 2014 at 6:09 AM
You can't do the xnb conversion on the fly. XNB is just a packaging format that can include preprocessing for DXT formatting - which is useful for Direct-X platforms like Windows Phone 8.

Can you save the downloaded file into your Content location? Once in this location, you could use the ContentManager to load the file as a literal asset - using the FOO.PNG file name.

Make sure you are creating the downloaded textures on the UI thread. Windows Phone 8 has a unique requirement that uses the core graphics decoder for creating textures from raw assets. This core decoder requires the main UI thread for processing.