本文整理汇总了C#中PhotoResult类的典型用法代码示例。如果您正苦于以下问题:C# PhotoResult类的具体用法?C# PhotoResult怎么用?C# PhotoResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PhotoResult类属于命名空间,在下文中一共展示了PhotoResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Task_Completed
private void Task_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
if (Helpers.FileHelpers.IsValidPicture(e.OriginalFileName))
{
if (App.PhotoModel != null)
{
App.PhotoModel.Dispose();
App.PhotoModel = null;
GC.Collect();
}
using (MemoryStream stream = new MemoryStream())
{
e.ChosenPhoto.CopyTo(stream);
App.PhotoModel = new PhotoModel() { Buffer = stream.GetWindowsRuntimeBuffer() };
App.PhotoModel.Captured = (sender == _cameraCaptureTask);
App.PhotoModel.Dirty = App.PhotoModel.Captured;
}
Dispatcher.BeginInvoke(() => { NavigationService.Navigate(new Uri("/Pages/PhotoPage.xaml", UriKind.Relative)); });
}
else
{
MessageBox.Show(AppResources.App_MessageBox_UnsupportedImage_Message,
AppResources.App_MessageBox_UnsupportedImage_Caption, MessageBoxButton.OK);
}
}
}
示例2: cameraCaptureTask_Completed
void cameraCaptureTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK && e.ChosenPhoto != null)
{
}
}
示例3: task_Completed
private async void task_Completed(object sender, PhotoResult e)
{
/* byte[] imageBits = new byte[(int)e.ChosenPhoto.Length];
e.ChosenPhoto.Read(imageBits, 0, imageBits.Length);
e.ChosenPhoto.Seek(0, System.IO.SeekOrigin.Begin);
MemoryStream screenshot = new MemoryStream(imageBits);
BitmapImage imageFromStream = new BitmapImage();
imageFromStream.SetSource(screenshot); */
Stream imgstream = e.ChosenPhoto;
//System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
//bmp.SetSource(e.ChosenPhoto);
//img.Source = bmp;
ApplyButton.Visibility = Visibility.Visible;
session = await EditingSessionFactory.CreateEditingSessionAsync(imgstream);
try
{
session.AddFilter(FilterFactory.CreateCartoonFilter(true));
// Save the image as a jpeg to the camera roll
using (MemoryStream stream = new MemoryStream())
{
WriteableBitmap bitmap = new WriteableBitmap(3552, 2448);
await session.RenderToWriteableBitmapAsync(bitmap);
bitmap.SaveJpeg(stream, bitmap.PixelWidth, bitmap.PixelHeight, 0, 100);
img.Source = bitmap;
}
//Force the framework to redraw the Image.
}
catch (Exception exception)
{
MessageBox.Show("Exception:" + exception.Message);
}
}
示例4: pcTask_Completed
void pcTask_Completed(object sender, PhotoResult e)
{
//如果照相成功则把照片保存到独立存储空间并显示出来
if (e.TaskResult == TaskResult.OK && e.Error == null)
{
BitmapImage bmpimg = new BitmapImage();
bmpimg.SetSource(e.ChosenPhoto);
App app = Application.Current as App;
Image img = new Image();
img.Source = bmpimg;
//app.DIYImg = img;
//image1.Source = bmpimg;
//IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
//if (!isf.DirectoryExists("UsersImage"))
//{
// isf.CreateDirectory("UsersImage");
//}
//using (Stream storagefilestream = isf.OpenFile(MusicName + ".jpg", FileMode.OpenOrCreate, FileAccess.Write))
//{
// WriteableBitmap wb = new WriteableBitmap(bmpimg);
// wb.SaveJpeg(storagefilestream, wb.PixelWidth, wb.PixelHeight, 0, 100);
//}
//NavigationService.Navigate(new Uri("/JigsawPuzzle;component/DIYPage.xaml", UriKind.Relative));
thread.Start();
}
}
示例5: ReadMetadataFromImage
private void ReadMetadataFromImage(object sender, PhotoResult photoResult)
{
//Setting the fileName
string fileName = "myWP7.dat";
new IsolatedStorageService().WriteOutToFile(fileName, photoResult.ChosenPhoto);
missingPetUploadViewModel.ImageUri = new Uri(photoResult.OriginalFileName);
}
示例6: task_Completed
void task_Completed(object sender, PhotoResult e)
{
if(e.TaskResult == TaskResult.OK)
{
var bmp = new WriteableBitmap(0,0);
bmp.SetSource(e.ChosenPhoto);
var bmpres = new WriteableBitmap(bmp.PixelWidth,bmp.PixelHeight);
var txt = new WindowsPhoneControl1();
txt.Text = txtInput.Text;
txt.FontSize = 36 * bmpres.PixelHeight / 480;
txt.Width = bmpres.PixelWidth;
txt.Height = bmpres.PixelHeight;
//should call Measure and when uicomponent is not in visual tree
txt.Measure(new Size(bmpres.PixelWidth, bmpres.PixelHeight));
txt.Arrange(new Rect(0, 0, bmpres.PixelWidth, bmpres.PixelHeight));
bmpres.Render(new Image() { Source = bmp }, null);
bmpres.Render(txt, null);
bmpres.Invalidate();
display.Source = bmpres;
}
}
示例7: photoChooserTask_Completed
private void photoChooserTask_Completed(object sender, PhotoResult e)
{
BitmapImage image = new BitmapImage();
image.SetSource(e.ChosenPhoto);
bitmapFotoDonatur = e.ChosenPhoto;
FotoDonatur = (image);
}
示例8: ctask_Completed
void ctask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
//CapturedImage = new WriteableBitmap();
CapturedImage = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
//CapturedImage.Resize();
string imgSize = (e.ChosenPhoto.Length / 1024).ToString();
string Height = CapturedImage.PixelHeight.ToString();
string Width = CapturedImage.PixelWidth.ToString();
long memoryRemaining = (long) DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage");
MessageBox.Show("Mem: " + memoryRemaining + "Size: " + imgSize + Environment.NewLine + "Dim: " + Height + "x" + Width);
StoreImageItem();
//CapturedImage = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
//myImage.Source = bmp;
//myImage.Stretch = Stretch.Uniform;
// swap UI element states
//savePhotoButton.IsEnabled = true;
//statusText.Text = "";
}
else
{
//savePhotoButton.IsEnabled = false;
//statusText.Text = "Task Result Error: " + e.TaskResult.ToString();
MessageBox.Show("Error");
}
CapturedImage = null;
}
示例9: cct_Completed
private void cct_Completed(object sender, PhotoResult e)
{
if (e.Error == null)
{
this.CallbackName = this.successCallback;
switch (e.TaskResult)
{
case TaskResult.OK:
int streamLength = Convert.ToInt32(e.ChosenPhoto.Length);
byte[] fileData = new byte[streamLength + 1];
e.ChosenPhoto.Read(fileData, 0, streamLength);
e.ChosenPhoto.Close();
string base64 = Convert.ToBase64String(fileData);
this.CallbackArgs = new[] { base64 };
break;
default:
this.CallbackArgs = new[] { string.Empty };
break;
}
}
else
{
this.CallbackName = this.errorCallback;
this.CallbackArgs = new[] { e.Error.Message };
}
}
示例10: cameraTask_Completed
void cameraTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
JpegInfo info = ExifLib.ExifReader.ReadJpeg(e.ChosenPhoto, e.OriginalFileName);
// Load the picture in a BitmapImage
System.Windows.Media.Imaging.BitmapImage bitmap = new System.Windows.Media.Imaging.BitmapImage();
bitmap.SetSource(e.ChosenPhoto);
// Place the loaded image in a WriteableBitmap
WriteableBitmap writeableBitmap = new WriteableBitmap(bitmap);
// Execute the filter on the pixels of the bitmap
ApplyFilter(writeableBitmap.Pixels);
// Set the source of our image to the WriteableBitmap
photoImage.Source = writeableBitmap;
//start count doown timer
countDownTimer = new DispatcherTimer();
countDownTimer.Interval = new TimeSpan(0, 0, 0, 1);
countDownTimer.Tick += new EventHandler(countDownTimerEvent);
// countDownTimer.Start();
txtCountdown.Text = "\n" + "seconds remaining";
ReadExif(info);
}
}
示例11: ptsk_Completed
void ptsk_Completed(object sender, PhotoResult e)
{
BitmapImage bi = new BitmapImage();
if(e.ChosenPhoto !=null)
bi.SetSource(e.ChosenPhoto);
img.Source = bi;
}
示例12: photoChooserTask_Completed
void photoChooserTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
firstimage.Source = new BitmapImage(new Uri(e.OriginalFileName));
}
}
示例13: OnPhotoChooserTaskCompleted
// Called when an existing photo is chosen with the photo chooser.
private void OnPhotoChooserTaskCompleted(object sender, PhotoResult e)
{
// Hide text messages
txtError.Visibility = Visibility.Collapsed;
txtMessage.Visibility = Visibility.Collapsed;
// Make sure the PhotoChooserTask is resurning OK
if (e.TaskResult == TaskResult.OK)
{
// initialize the result photo stream
photoStream = new MemoryStream();
// Save the stream result (copying the resulting stream)
e.ChosenPhoto.CopyTo(photoStream);
// save the original file name
fileName = e.OriginalFileName;
// display the chosen picture
var bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
bitmapImage.SetSource(photoStream);
imgSelectedImage.Source = bitmapImage;
// enable the upload button
btnUpload.IsEnabled = true;
}
else
{
// if result is not ok, make sure user can't upload
btnUpload.IsEnabled = false;
}
}
示例14: pct_Completed
async void pct_Completed(object sender, PhotoResult e)
{
if (e.TaskResult != TaskResult.OK || e.ChosenPhoto == null)
return;
try
{
// Create a source to read the image from PhotoResult stream
using (var source = new StreamImageSource(e.ChosenPhoto))
{
using (var effect = new PixlateEffect(source))
{
_effect = effect;
var target = new WriteableBitmap((int)ResultImage.ActualWidth, (int)ResultImage.ActualHeight);
// Create a new renderer which outputs WriteableBitmaps
using (var renderer = new WriteableBitmapRenderer(effect, target))
{
// Render the image with the filter(s)
await renderer.RenderAsync();
// Set the output image to Image control as a source
ResultImage.Source = target;
}
}
}
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
return;
}
}
示例15: photoChooserTask_Completed
void photoChooserTask_Completed(object sender, PhotoResult e)
{
ShareMediaTask shareMediaTask = new ShareMediaTask();
shareMediaTask.FilePath = e.OriginalFileName;
shareMediaTask.Show();
}