Have been solved this issue.
1. Get the INTERNAL_DataURL of BitmapImage (when the Source of Image is an image opened via FileOpenDialog)
2. Divide into parts (Max 8000 characters) by using the String.Substring method.
3. Send to WCF Service part by part (I can't configure the WCF to accept the whole string so the service refuses and returning a 500 error message that says entity is very large (the DataURL))
4. The WCF then consolidates the string parts, converts to byte array then saves to the database.
Here's the code to convert from DataURL to ByteArray.
Code: Select all
private byte ImageStringToByteArray(String Data)
//Example of image DataURL
//string str = "data:image/png;base64,/9j/4AAQSkZJRgABAQEAyADIAAD/2wBD....";
var base64data = Regex.Match(Data, @"data:image/(?<type>.+?),(?<data>.+)").Groups["data"].Value;
byte imageBytes = Convert.FromBase64String(base64data);
I don't think if this method is efficient, but this works for me.