// Informs when thumbnail picture has been taken, saves to isolated storage // User will select this image in the pictures application to bring up the full-resolution picture. public void cam_CaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { var latitude = currentCoordinate.Location.Latitude.ToString("0.00000"); var longitude = currentCoordinate.Location.Longitude.ToString("0.00000"); string fileName = latitude + longitude + "_th.jpg"; try { // Save thumbnail as JPEG to isolated storage. var bytes = new List<byte>(); using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create,FileAccess.Write)) { // Initialize the buffer for 4KB disk pages. var readBuffer = new byte[4096]; int bytesRead; // Copy the thumbnail to isolated storage. while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) { targetStream.Write(readBuffer, 0, bytesRead); bytes.AddRange(readBuffer); } bytes.RemoveRange((int)targetStream.Length, (int)(bytes.Count - targetStream.Length)); } UploadImage(latitude, longitude, fileName, bytes.ToArray()); } }catch (Exception exception){ DebugTextBlock.Text = exception.Message; }finally { // Close image stream e.ImageStream.Close(); } }
public void CamCaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { string fileName = _savedCounter + "_th.jpg"; try { using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using ( IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create, FileAccess.Write)) { byte[] readBuffer = new byte[4096]; int bytesRead; while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) { targetStream.Write(readBuffer, 0, bytesRead); } } } } finally { e.ImageStream.Close(); } }
public void captureThumbnailAvailableHandler(object sender, ContentReadyEventArgs e) { string fileName = counter + "_th.jpg"; try { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream stream = isf.OpenFile(fileName, FileMode.Create, FileAccess.Write)) { byte[] buffer = new byte[4096]; int bytesRead = -1; while ((bytesRead = e.ImageStream.Read(buffer, 0, buffer.Length)) > 0) { stream.Write(buffer, 0, bytesRead); } } } } catch (Exception) { } finally { e.ImageStream.Close(); } }
void camera_CaptureImageAvailable(object sender, ContentReadyEventArgs e) { if (e.ImageStream != null) { Deployment.Current.Dispatcher.BeginInvoke(() => { ControlUi.Visibility = System.Windows.Visibility.Collapsed; CameraHolder.Visibility = System.Windows.Visibility.Collapsed; SettingsUI.Visibility = Visibility.Collapsed; PhotoAcceptUi.Visibility = Visibility.Visible; ImageHolderUI.Visibility = System.Windows.Visibility.Visible; ControlUi.Visibility = Visibility.Collapsed; CapturedImage.Stretch = Stretch.Fill; var bmp = PictureDecoder.DecodeJpeg(e.ImageStream, (int)camera.Resolution.Width, (int)camera.Resolution.Height); bmp.Resize((int)this.ActualWidth, (int)this.ActualHeight, WriteableBitmapExtensions.Interpolation.NearestNeighbor); if (isBlackEffectSelected) { int[] pixel = temp.Effect.Process(bmp.Pixels,480,640); pixel.CopyTo(bmp.Pixels, 0); } CapturedImage.Source = bmp; }); } }
private void captureImageAvailable(object sender, ContentReadyEventArgs e) { string filename = "" + ".jpg"; Dispatcher.BeginInvoke(delegate() { txtmsg.Text = "Image available"; }); }
// Informs when full resolution picture has been taken, saves to local media library and isolated storage. private void CameraCaptureImageCompleted(object sender, ContentReadyEventArgs e) { Deployment.Current.Dispatcher.BeginInvoke(() => { lock (this) { //cameraViewModel.CameraInUse = false; } }); }
private void PhotoCamera_CaptureImageAvailable(object sender, ContentReadyEventArgs e) { var eventHandler = CaptureImageAvailable; if (eventHandler != null) { eventHandler(this, e); } }
void camera_CaptureImageAvailable(object sender, ContentReadyEventArgs e) { Dispatcher.BeginInvoke(() => { currentImage = DecodeImage(e.ImageStream, (int)camera.Orientation); photoContainer.Fill = new ImageBrush { ImageSource = currentImage }; imageDetails.Text = "Image captured from PhotoCamera."; }); }
private void cam_CaptureCompleted(object sender, ContentReadyEventArgs e) { this.Dispatcher.BeginInvoke(() => { BitmapImage tempImage = new BitmapImage(); tempImage.SetSource(RotateStream(e.ImageStream, Convert.ToInt32(cam.Orientation))); Result.Source = tempImage; Result.Visibility = Visibility.Visible; VideoCanvas.Visibility = Visibility.Collapsed; }); }
private void CameraOnCaptureImageAvailable(object sender, ContentReadyEventArgs contentReadyEventArgs) { if (this.NewCameraCaptureImage != null) { this.NewCameraCaptureImage.Invoke(this, contentReadyEventArgs); } Task.Factory.StartNew( async() => { this.file = await SaveToLocalFolderAsync(contentReadyEventArgs.ImageStream, "_____ccuiphoto.jpg"); this.StopFlag = true; }); }
// --- private void camera_CaptureImageAvailable(object sender, ContentReadyEventArgs e) { capturing = false; Stream imageStream = (Stream)e.ImageStream; BarcodeDecoder barcodeDecoder = new BarcodeDecoder(); Dictionary<DecodeOptions, object> decodingOptions = new Dictionary<DecodeOptions, object>(); List<BarcodeFormat> possibleFormats = new List<BarcodeFormat>(1); Result result; Dispatcher.BeginInvoke( () => { WriteableBitmap qrImage = new WriteableBitmap((int)camera.Resolution.Width, (int)camera.Resolution.Height); imageStream.Position = 0; qrImage.LoadJpeg(imageStream); possibleFormats.Add(BarcodeFormat.QRCode); decodingOptions.Add( DecodeOptions.PossibleFormats, possibleFormats); try { result = barcodeDecoder.Decode(qrImage, decodingOptions); resultText.Text = result.Text; } catch (NotFoundException) { // this is expected if the image does not contain a valid // code, Or is too distorted to read resultText.Text = "<nothing to display>"; } catch (Exception ex) { // something else went wrong, so alert the user MessageBox.Show( ex.Message, "Error Decoding Image", MessageBoxButton.OK); } } ); }
void cam_CaptureImageAvailable(object sender, ContentReadyEventArgs e) { Dispatcher.BeginInvoke(() => { orientation = Orientation; cameraType = cam.CameraType; var bmp = new BitmapImage(); bmp.SetSource(e.ImageStream); var writeableBmp = BitmapFactory.New(bmp.PixelWidth, bmp.PixelHeight).FromStream(e.ImageStream); ImageSource = WriteableBitmapHelpers.TransformBitmapByCameraTypeAndPageOrientation(writeableBmp, cameraType, orientation); PictureAvailableScenario(); }); }
// Informs when thumbnail photo has been taken, saves to the local folder // User will select this image in the Photos Hub to bring up the full-resolution. public void cam_CaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { try { // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = "Captured image available, saving thumbnail."; }); // Save thumbnail as JPEG to the local folder. using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { if (!isStore.DirectoryExists("files")) { isStore.CreateDirectory("files"); } string fileName = "files\\" + DateTime.Now.ToString("yymmddhhmmss") + "_th.jpg"; using (IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create, FileAccess.Write)) { // Initialize the buffer for 4KB disk pages. byte[] readBuffer = new byte[4096]; int bytesRead = -1; // Copy the thumbnail to the local folder. while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) { targetStream.Write(readBuffer, 0, bytesRead); } } } // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = "Thumbnail has been saved to the local folder."; }); } finally { // Close image stream e.ImageStream.Close(); } }
// Informs when thumbnail picture has been taken, saves to isolated storage // User will select this image in the pictures application to bring up the full-resolution picture. public void cam_CaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { string completeName = filename + "_th.jpg"; if (filename.Equals("-1")) GlobalVars.fileNameThumb = completeName; try { // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = "Captured image available, saving thumbnail."; }); // Save thumbnail as JPEG to isolated storage. using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream targetStream = isStore.OpenFile(completeName, FileMode.Create, FileAccess.Write)) { // Initialize the buffer for 4KB disk pages. byte[] readBuffer = new byte[4096]; int bytesRead = -1; // Copy the thumbnail to isolated storage. while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) { targetStream.Write(readBuffer, 0, bytesRead); } } } // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = "Thumbnail has been saved to isolated storage."; }); } finally { // Close image stream e.ImageStream.Close(); } }
// Informs when thumbnail photo has been taken, saves to the local folder // User will select this image in the Photos Hub to bring up the full-resolution. public void cam_CaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { try { // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = "Captured image available, saving thumbnail."; }); // Save thumbnail as JPEG to the local folder. using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { if (!isStore.DirectoryExists("files")) isStore.CreateDirectory("files"); string fileName = "files\\" + DateTime.Now.ToString("yymmddhhmmss") + "_th.jpg"; using (IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create, FileAccess.Write)) { // Initialize the buffer for 4KB disk pages. byte[] readBuffer = new byte[4096]; int bytesRead = -1; // Copy the thumbnail to the local folder. while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) { targetStream.Write(readBuffer, 0, bytesRead); } } } // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = "Thumbnail has been saved to the local folder."; }); } finally { // Close image stream e.ImageStream.Close(); } }
private void CameraOnCaptureImageAvailable(object sender, ContentReadyEventArgs contentReadyEventArgs) { if (SaveToCameraRoll) { Dispatcher.BeginInvoke(() => { WriteableBitmap bitmap = CreateWriteableBitmap(contentReadyEventArgs.ImageStream, (int)Camera.Resolution.Width, (int)Camera.Resolution.Height); SaveCapturedImage(bitmap); } ); } if (NewCameraCaptureImage != null) { NewCameraCaptureImage.Invoke(this, contentReadyEventArgs); } }
//Informs when thumbnail picture has been taken, then store it //User selects image in photos for full res public void cam_CaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { string fileName = savedCounter + "_th.jpg"; try { //Write message UI Deployment.Current.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = "Captured image available, saving thumbnail."; }); //Save thumbnail as JPEG storage using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create, FileAccess.Write)) { //Initialize the buffer for 4KB disk pages byte[] readBuffer = new byte[4096]; int bytesRead = -1; //Copy the thumbnail to storage while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) { targetStream.Write(readBuffer, 0, bytesRead); } } } //Write message to UI Deployment.Current.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = "Thumbnail has been saved to isolated storage."; }); } finally { //Close image stream e.ImageStream.Close(); } }
// Informs when thumbnail photo has been taken, saves to the local folder // User will select this image in the Photos Hub to bring up the full-resolution. public void cam_CaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { string fileName = savedCounter + "_th.jpg"; try { // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { }); // Save thumbnail as JPEG to the local folder. using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create, FileAccess.Write)) { // Initialize the buffer for 4KB disk pages. byte[] readBuffer = new byte[4096]; int bytesRead = -1; // Copy the thumbnail to the local folder. while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) { targetStream.Write(readBuffer, 0, bytesRead); } } } // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { }); } finally { // Close image stream e.ImageStream.Close(); } }
void Camera_CaptureImageAvailable(object sender, ContentReadyEventArgs e) { string fileName = SavedCounter + ".jpg"; try { //TODO : ADD INSERT STREAM TO SERVER SaveInputStream(e.ImageStream, SavedCounter); Debug.WriteLine("Captured image available, saving picture " + fileName); //e.ImageStream.Seek(0, SeekOrigin.Begin); //using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) //{ // using (IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create, FileAccess.Write)) // { // // Initialize the buffer for 4KB disk pages. // byte[] readBuffer = new byte[4096]; // int bytesRead = -1; // // Copy the image to isolated storage. // while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) // { // targetStream.Write(readBuffer, 0, bytesRead); // } // } //} } finally { // Close image stream // e.ImageStream.Close(); } }
private void PhotoCamera_CaptureImageAvailable(object sender, ContentReadyEventArgs e) { if (_onCaptureImageAvailable != null) { _onCaptureImageAvailable(e.ImageStream); } }
// Informs when thumbnail picture has been taken, saves to isolated storage // User will select this image in the pictures application to bring up the full-resolution picture. public void cam_CaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { Debug.WriteLine("cam_CaptureThumbnailAvailable"); string fileName = savedCounter + "_th.jpg"; try { // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = "Captured image available, saving thumbnail."; }); // Save thumbnail as JPEG to isolated storage. using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create, FileAccess.Write)) { // Initialize the buffer for 4KB disk pages. byte[] readBuffer = new byte[4096]; int bytesRead = -1; // Copy the thumbnail to isolated storage. while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) { targetStream.Write(readBuffer, 0, bytesRead); } } } Debug.WriteLine("filename <= {0}", fileName); switch (cm) { case CaptureMode.CaptureFrame: frameFilename_th = fileName; // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream tgtStream = isStore.OpenFile(frameFilename_th, FileMode.Open, FileAccess.Read)) { Debug.WriteLine("Reading {0} from Isolated Storage", frameFilename_th); BitmapImage bi = new BitmapImage(); bi.SetSource(tgtStream); WriteableBitmap wb = new WriteableBitmap(bi); createHole(wb, 0.5F, 0.4F, 0.3F, 0.5F); lastView.Source = wb; lastView.Visibility = Visibility.Visible; } } }); break; case CaptureMode.CapturePhoto: photoFilename_th = fileName; //break; // separate postview page is shown. no need to perform below procedure. // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream frameStream = isStore.OpenFile(frameFilename_th, FileMode.Open, FileAccess.Read)) { Debug.WriteLine("Reading {0} from Isolated Storage", frameFilename_th); BitmapImage fb = new BitmapImage(); fb.SetSource(frameStream); WriteableBitmap fwb = new WriteableBitmap(fb); createHole(fwb, 0.5F, 0.4F, 0.3F, 0.5F); using (IsolatedStorageFileStream photoStream = isStore.OpenFile(photoFilename_th, FileMode.Open, FileAccess.Read)) { BitmapImage pb = new BitmapImage(); pb.SetSource(photoStream); WriteableBitmap pwb = new WriteableBitmap(pb); blit(fwb, pwb, 0.5F, 0.4F, 0.3F, 0.5F); lastView.Source = fwb; lastView.Visibility = Visibility.Visible; //canvas1.Visibility = Visibility.Collapsed; GuidelineOut.Begin(); } } } }); break; } } finally { // Close image stream e.ImageStream.Close(); } }
private void captureImageAvailable(object sender, ContentReadyEventArgs e) { string filename = "" + ".jpg"; Dispatcher.BeginInvoke(delegate() { txtmsg.Text = "Image available"; BitmapImage bmp = new BitmapImage(); bmp.SetSource(e.ImageStream); PhoneApplicationService.Current.State["image"] = bmp; NavigationService.Navigate(new Uri("/views/LoadingPage.xaml", UriKind.Relative)); }); // TODO: fix onNavigatedTO and onNavigationFrom problems }
private void Camera_CaptureImageAvailable(object sender, ContentReadyEventArgs e) { Deployment.Current.Dispatcher.BeginInvoke(() => { // Save file. string filename = string.Format("{0:yyyyMMdd-HHmmss}.jpg", DateTime.Now); int reducingRate = Int32.Parse(AppResources.ReducingRate); int photoQuality = Int32.Parse(AppResources.PhotoQuality); FileStorage.SaveToIsolatedStorage(e.ImageStream, filename, reducingRate, photoQuality); Model.File file = new Model.File(); file.FileName = filename; file.FileSize = FileStorage.FileSize(filename); file.Uid = 0; RESTService service = new RESTService(AppResources.RESTServiceUri); service.CreateFile(file, onFileCreatedRemotely, onError); }); }
void Camera_Image_Available(object sender, ContentReadyEventArgs e) { Dispatcher.BeginInvoke(() => Camera_Image_Capture(e)); }
void cameraCaptureTask_Completed(object sender, ContentReadyEventArgs e) { MemoryStream ms = new MemoryStream(); try { e.ImageStream.Seek(0, SeekOrigin.Begin); e.ImageStream.CopyTo(ms); Deployment.Current.Dispatcher.BeginInvoke(delegate() { try { string filename = SavePictures(ms); AnalyzeAndDisplayImage(filename); } finally { ms.Close(); } }); } finally { e.ImageStream.Close(); pauseFramesEvent.Set(); } }
void ThreadSafeImageCapture(ContentReadyEventArgs e) { busy = false; WriteableBitmap image = BitmapFactory.New((int)Camera.AvailableResolutions.LastOrDefault().Width, (int)Camera.AvailableResolutions.LastOrDefault().Height); image.SetSource(e.ImageStream); if (Type == CameraType.FrontFacing) { image = WriteableBitmapExtensions.Flip(image, WriteableBitmapExtensions.FlipMode.Vertical); //image = WriteableBitmapExtensions.Flip(image, WriteableBitmapExtensions.FlipMode.Horizontal); } image = WriteableBitmapExtensions.Rotate(image, (int)angle); OrientedCameraImage orientedImage = new OrientedCameraImage() { Image = image, Angle = angle, Orientation = orientation }; if (Captured != null) { Captured(this, orientedImage); } }
private void CaptureImageAvailable(object sender, ContentReadyEventArgs e) { if (cameraIsInitialized) { Dispatcher.BeginInvoke(() => ThreadSafeImageCapture(e)); } }
void photoCamera_CaptureImageAvailable(object sender, ContentReadyEventArgs e) { throw new NotImplementedException(); }
private void frontCam_ThumbnailAvailable(object sender, ContentReadyEventArgs e) { this.Dispatcher.BeginInvoke(delegate() { if (frontCam == null) { //MessageBox.Show("ERROR: Camera is not available", "ERROR", MessageBoxButton.OK); ShowToastMessage("Error Starting Front Camera", "Front Camera could not be initialized"); return; } // Initialize a new Bitmap image WriteableBitmap bitmap = new WriteableBitmap((int)frontCam.PreviewResolution.Width, (int)frontCam.PreviewResolution.Height); // Get the bitmap from the camera frontCam.GetPreviewBufferArgb32(bitmap.Pixels); // Foreach Alerter, try to analize the value. List<AlertEvent> alertEvents = new List<AlertEvent>(); foreach (IAlerter alerter in frontAlerters) { alerter.GetData(); AlertEvent alertEvent = new AlertEvent() { AlertLevel = alerter.ProcessData(bitmap), AlertTime = DateTime.Now, AlertType = alerter.GetAlerterType(), Driver = _currentDriver }; if (alertEvent.AlertLevel >= ALERT_THRESHOLD) _currentDrive.Events.Add(alertEvent); alertEvents.Add(alertEvent); } // Calculate the safety score (for all valid values). double res = calculateSafetyScore(alertEvents.Where(_event => _event.AlertLevel != -1)); // Update the UI updateScreen(res); }); }
void Camera_CaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { Deployment.Current.Dispatcher.BeginInvoke(() => { BitmapImage image = new BitmapImage(); image.SetSource(e.ImageStream); this.lastShot.Source = image; this.lastShotFrame.Visibility = System.Windows.Visibility.Visible; this.cameraView.Visibility = System.Windows.Visibility.Collapsed; }); }
private void CamCaptureImageAvailable(object sender, ContentReadyEventArgs e) { string fileName = _savedCounter + ".jpg"; try { _library.SavePictureToCameraRoll(fileName, e.ImageStream); e.ImageStream.Seek(0, SeekOrigin.Begin); using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using ( IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create, FileAccess.Write)) { byte[] readBuffer = new byte[4096]; int bytesRead; while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) { targetStream.Write(readBuffer, 0, bytesRead); } } } } finally { e.ImageStream.Close(); GlobalVars.PhotoName = fileName; Dispatcher.BeginInvoke(() => NavigationService.Navigate(new System.Uri("/Emergency.xaml", System.UriKind.Relative))); } }
/// <summary> /// Called when [camera capture image available]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="Microsoft.Devices.ContentReadyEventArgs"/> instance containing the event data.</param> private void OnCameraCaptureImageAvailable(object sender, ContentReadyEventArgs e) { System.Diagnostics.Debug.WriteLine("CaptureImageAvailable"); }
private void cam_CaptureImageAvailable(object sender, ContentReadyEventArgs e) { try { string fileName = Guid.NewGuid().ToString("N") + ".jpg"; // Save picture to the library camera roll. library.SavePictureToCameraRoll(fileName, e.ImageStream); // Set the position of the stream back to start e.ImageStream.Seek(0, SeekOrigin.Begin); // Save picture as JPEG to isolated storage. using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream targetStream = isStore.OpenFile("temp.dat", FileMode.Create, FileAccess.Write)) { // Initialize the buffer for 4KB disk pages. var readBuffer = new byte[4096]; int bytesRead; // Copy the image to isolated storage. while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) { targetStream.Write(readBuffer, 0, bytesRead); } targetStream.Flush(); } } Deployment.Current.Dispatcher.BeginInvoke(ReadImage); } catch (Exception exception) { Deployment.Current.Dispatcher.BeginInvoke(() => MessageBox.Show(exception.ToString())); } finally { // Close image stream e.ImageStream.Close(); } }
private void PhotoCamera_CaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { var eventHandler = CaptureThumbnailAvailable; if (eventHandler != null) { eventHandler(this, e); } }
private void cam_ThumbnailAvailable(object sender, ContentReadyEventArgs e) { throw new NotImplementedException(); }
void cam_CaptureImageAvailable(object sender, ContentReadyEventArgs e) { MediaLibrary library = new MediaLibrary(); string fileName = Guid.NewGuid().ToString() + ".jpg"; library.SavePictureToCameraRoll(fileName, e.ImageStream); Dispatcher.BeginInvoke(() => msg.Text = "照片保存成功"); }
// Informs when thumbnail picture has been taken, saves to isolated storage // User will select this image in the pictures application to bring up the full-resolution picture. public void cam_CaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { string fileName = savedCounter + "_th.jpg"; try { // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = "Captured image available, saving thumbnail."; }); // Save thumbnail as JPEG to isolated storage. using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create, FileAccess.Write)) { // Initialize the buffer for 4KB disk pages. byte[] readBuffer = new byte[4096]; int bytesRead = -1; // Copy the thumbnail to isolated storage. while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0) { targetStream.Write(readBuffer, 0, bytesRead); } } } // Write message to UI thread. Deployment.Current.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = "Thumbnail has been saved to isolated storage."; }); } finally { // Close image stream e.ImageStream.Close(); } IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication(); IsolatedStorageFileStream isoStream = isoStore.OpenFile(fileName, FileMode.Open, FileAccess.Read); BitmapImage bitmap; System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { bitmap = new BitmapImage(); bitmap.SetSource(isoStream); Image img = new Image(); img.Source = bitmap; ImageData imgData = new ImageData() {Name=fileName, ThumbNailBitmap = bitmap}; thumbNails.Insert(0, imgData ); }); }
// Informs when thumbnail picture has been taken, saves to isolated storage // User will select this image in the pictures application to bring up the full-resolution picture. public void cam_CaptureThumbnailAvailable(object sender, ContentReadyEventArgs e) { }