开发者

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

开发者 https://www.devze.com 2023-03-13 11:06 出处:网络
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

精彩评论

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