开发者

How to create a bitmap image programmatically when its source is an image with Build Action = Resource?

How to create a bitmap image programmatically when its source is an image with Build Action = Resource?

When I try the following I get an invalid URI exception :(

BitmapIm开发者_StackOverflow社区age image = new BitmapImage(new Uri("/MyAssembly;component/Images/MyImage.png"));

I'm using silverlight 4 and this code is inside one of the many projects of my solution (it's a silverlight class library and not the silverlight application).


BitmapImage image = new BitmapImage(new Uri("/MyAssembly;component/Images/MyImage.png"));

should be:

BitmapImage image = new BitmapImage(new Uri("/MyAssembly;component/Images/MyImage.png", UriKind.Relative));

Images/MyImage.png also assumes your image is located inside a folder called Images.


var image = new ImageInline(new Uri("/BF.SilverlightClient;component/Views/Reports/ChartLegendBar.png", UriKind.Relative))
            { Width = 200, Height = 25};
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜