c# - Does WriteableBitmap has new features in Silverlight 4? -
And if someone can give me an example to use it with a stream? (Not sure how that works) I know how to make BitmapImage
from URI
, now let me write this image to the writeable bitmap < / Code>, but I get a blank exception error with something like this:
In short: No, there are no new features in Silverlight 4. Compensate missing functionality.
Regarding your real problem: You should add a handler to the event to see if an error occurs while downloading the image. And you should create a writeable bitmap in the event handler.
var image = new bitmapImage (new URI ("http://www.example.com/example.png")); Writeable bitmap newImage = faucet; Image.ImageOpened + = (s, e) = & gt; NewImage = new writable bitmap (image);
Please also keep in mind that cross-domain contexts are allowed. See for details, you should place the image in the ClientBin folder of the web project and instead use a relative path.
Alternatively, you can compile the image as a resource in the assembly and load it if you are there. There is an extension method to make this task a bit easier. But keep in mind that the size of the assembly raises and the time for the initial XAP load will increase.
// Write the address of the calling assembly by writing a relative path. Writeable bitmap (0, 0) .FromResource ("example.png");
Comments
Post a Comment