Created
          January 26, 2011 16:45 
        
      - 
      
- 
        Save jak/796979 to your computer and use it in GitHub Desktop. 
    Pictures over Web Services - Service side
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [WebMethod] | |
| public string GetPicture() { | |
| // Load the picture | |
| Image img = Image.FromFile("Path/To/Picture.jpg"); | |
| // Create a memory stream, and put the image contents into it. | |
| MemoryStream stream = new MemoryStream(); | |
| img.Save(stream, img.RawFormat); | |
| // return data, encoded in Base64 | |
| return Convert.ToBase64String(stream.ToArray()); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment