Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPF Loading .jpg from disk #14

Open
KirillOsenkov opened this issue Jul 28, 2018 · 0 comments
Open

WPF Loading .jpg from disk #14

KirillOsenkov opened this issue Jul 28, 2018 · 0 comments
Labels

Comments

@KirillOsenkov
Copy link
Owner

        private static BitmapSource LoadBitmap()
        {
            var file = "WindowsVistaBounceGrass.jpg";
            BitmapSource bitmapSource;
            using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete))
            {
                //var bitmapImage = new BitmapImage();
                //bitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                //bitmapImage.BeginInit();
                //bitmapImage.StreamSource = stream;
                //bitmapImage.EndInit();
// this results in: https://stackoverflow.com/q/7060817/37899

                bitmapSource = BitmapFrame.Create(
                    stream,
                    BitmapCreateOptions.None,
                    BitmapCacheOption.OnLoad);
            }

            return bitmapSource;
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant