When we take a picture using the phone's camera, it will be handed to us as a byte array. To send this to the server, we will convert it into a Base64-encoded string. To display that message locally, we will need to convert it back into a byte array and then pass that byte array to a helper method of the ImageSource class to create an instance of the ImageSource object. This object will make sense to the Image control and an image will be displayed.
Since there is a lot of code here, we suggest that you perform the following steps and look at each line of code in detail as you follow them:
- Create a folder called Converters in the Chat project.
- Create a new class called Base64ImageConverter in the Converters folder; ensure the class implements the IValueConverter interface.
- In the Convert() method of the class, cast the value object parameter to a string called base64String.
- Convert base64String into a byte array using the System.Convert...