Sunday, April 20, 2014

How to share a captured image and add predefined text in a email compose task

Hey I am capturing a photo using the webcam how do I share that Image windows store app here is the code for the capturing image and sharing it. Problem is I cant share it without importing it. Moreover the other problem is I use the share status task but for Email I want the body to be predefined it is not how should I do that?



CameraCaptureUI camera = new CameraCaptureUI();
camera.PhotoSettings.CroppedAspectRatio = new Size(16, 9);
StorageFile photo = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo);

//By default the photo will be stored at location
//%localappdata%\Packages\APP_PACKAGE_ID\TempState

if (photo != null)
{
//await photo.MoveAsync(KnownFolders.PicturesLibrary);
//OR
await photo.MoveAsync(KnownFolders.PicturesLibrary, "resolvepic" + photo.FileType, NameCollisionOption.GenerateUniqueName);
BitmapImage bmp = new BitmapImage();
IRandomAccessStream stream = await photo.OpenAsync(FileAccessMode.Read);
bmp.SetSource(stream);
CapturedPhoto.Source = bmp;


private void ShareTextHandler(DataTransferManager sender, DataRequestedEventArgs e)
{

if (this.imageFile != null)
{
DataRequest requestData = e.Request;
requestData.Data.Properties.Title = "Please fix this problem as soon as possible";
requestData.Data.Properties.Description = TextInput.Text;

List<IStorageItem> imageItems = new List<IStorageItem>();
imageItems.Add(this.imageFile);
requestData.Data.SetStorageItems(imageItems);
RandomAccessStreamReference imageStreamRef = RandomAccessStreamReference.CreateFromFile(this.imageFile);
requestData.Data.Properties.Thumbnail = imageStreamRef;
requestData.Data.SetBitmap(imageStreamRef);
}
}







pratik


No comments:

Post a Comment