Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Update iOS to an easier way to retrieve a stream for the image
Browse files Browse the repository at this point in the history
  • Loading branch information
timrisi committed Apr 28, 2016
1 parent f45538d commit 40f0693
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions microsoft-cognitive-services/iOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,13 @@ void OnTakePhotoPressed (object sender, EventArgs eventArgs)
picker.SourceType = UIImagePickerControllerSourceType.Camera;

picker.FinishedPickingMedia += async (o, e) => {
// Create a moderate quality version of the image
byte [] dataBytes;
using (NSData data = e.OriginalImage.AsJPEG (.5f)) {
dataBytes = new byte [data.Length];
System.Runtime.InteropServices.Marshal.Copy (data.Bytes, dataBytes, 0, Convert.ToInt32 (data.Length));
}

ThePhoto.Image = e.OriginalImage;
DetailsText.Text = "Processing...";

((UIImagePickerController)o).DismissViewController (true, null);

// Create a stream, send it to MCS, and get back
using (MemoryStream stream = new MemoryStream (dataBytes)) {
using (var stream = e.OriginalImage.AsJPEG(.5f).AsStream()) {
try {
float happyValue = await SharedProject.Core.GetAverageHappinessScore (stream);
DetailsText.Text = SharedProject.Core.GetHappinessMessage (happyValue);
Expand Down

0 comments on commit 40f0693

Please sign in to comment.