C# wpf save bitmapsource to file


















Here a code to set transparent background to any bitmap resource within a Resource Dictionary not Resources. Forms age. I call this methode before InitializeComponent - methode. As far as I can tell the only way to convert from BitmapSource to Bitmap is through unsafe code Like this from Lesters WPF blog :. Is there an easier way in the framework? And what is the reason it isn't in there if it's not?

Bookmark the permalink. COM says:. March 28, at pm. Recent Books:. Search for:. Ask Question. Asked 11 years, 7 months ago. Active 10 months ago. Viewed 54k times. Improve this question. StayOnTarget 9, 9 9 gold badges 43 43 silver badges 66 66 bronze badges.

Add a comment. Active Oldest Votes. Add BitmapFrame. Create image ; encoder. EDIT : the bug mentioned above seems to be fixed in 4. Improve this answer. Active Oldest Votes. This one works perfectly: if File. ReadAllBytes filePath ; memoryStream. Write fileBytes, 0, fileBytes. Length ; memoryStream. Improve this answer. You took others' comments, didn't upvote anyone, created a derivative solution that you posted as an answer, and you gave yourself the Poster-Approved-Answer vote?

I'm new to stackoverflow. As you may see. Therefore I just cannot upvote others until I have a reputation of And since the others kindly provided good suggestions, but no real solution for people having the same problem, I provided the answer myself as a result of my very own research.

OnLoad; image. EndInit ;. Julien Roncaglia Add the following line to your loading code: image. OnLoad; This will load open the file, read it into memory, and close it all during image. Dragon 76 C. Dragon 76 9, 8 8 gold badges 33 33 silver badges 40 40 bronze badges.



0コメント

  • 1000 / 1000