H
H
Hirty2016-07-21 11:28:23
WPF
Hirty, 2016-07-21 11:28:23

Download image from Resources?

Is there an easier option?
Found only this one

const string UriPack = "pack://application:,,,";
        readonly string ComponentUri = "/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/";
            BitmapImage bmp = new BitmapImage(new Uri(UriPack + ComponentUri + "Resources/scheme (3).png", UriKind.Absolute));
            WriteableBitmap writeableBmp = new WriteableBitmap(bmp);
            image.Source = writeableBmp;

Is it possible to shorten the code or is there an easier way to solve this?
There is a picture on the form, it needs to be changed from Resources

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DrBrain, 2016-07-21
@Hirty

var bi = new BitmapImage(new Uri("pack://application:,,,/IMAGES/scheme (3).png"));
image.Source = bi;

Will this option work for you?
Only the picture should not be in the resources, but in the "IMAGES" folder (well, or another name for your taste) and set the "Assembly action" property of the picture (pictures) to "Resource".
Details: en.stackoverflow.com/questions/422465/%D0%9F%D1%80...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question