KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to convert from System.Windows.Controls.Image to byte[] and I didnt know which method from Image class could help in this scenary, by the way I really dont know what should I do, cause in my LINQ model the field appears as Binary type, I have to change this if I want to save it like a byte[] type? I found code posted here, but without using WPF: Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight); System.IO.MemoryStream stream = new System.IO.MemoryStream(); newBMP.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp); PHJProjectPhoto myPhoto = new PHJProjectPhoto { ProjectPhoto = stream.ToArray(), // <<--- This will convert your stream to a byte[] OrderDate = DateTime.Now, ProjectPhotoCaption = ProjectPhotoCaptionTextBox.Text, ProjectId = selectedProjectId };
Tags (comma-separated)
Save Edits
Cancel