Back to Devexpress

TakePictureDialog Class

windowsforms-devexpress-dot-xtraeditors-dot-camera-278427df.md

latest3.9 KB
Original Source

TakePictureDialog Class

The modal dialog to take pictures from a camera device.

Namespace : DevExpress.XtraEditors.Camera

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public class TakePictureDialog
vb
Public Class TakePictureDialog

Remarks

Use the Take Picture dialog to allow users to take pictures from an attached camera device in a modal dialog. This dialog contains an embedded Camera Control.

When a user captures an image and clicks the Save button, the image is saved to the TakePictureDialog.Image property.

The following code shows a TakePictureDialog and then saves the captured image to a file.

csharp
using DevExpress.XtraEditors.Camera;

TakePictureDialog d = new TakePictureDialog();
if(d.ShowDialog() == System.Windows.Forms.DialogResult.OK){
    Image i = d.Image;
    i.Save("C:\\snapshot.bmp");
}
vb
Imports DevExpress.XtraEditors.Camera

Dim d As New TakePictureDialog()
If d.ShowDialog() = System.Windows.Forms.DialogResult.OK Then 
    Dim i As Image = d.Image
    i.Save("C:\snapshot.bmp")
End If

Select the Camera Device and Resolution

The Take Picture dialog saves the currently selected camera device and its resolution in the system registry when a user closes the dialog. These settings are reused the next time a user opens the dialog. If the system registry contains no information on the previously used camera device, the Take Picture dialog will use the default camera device (CameraControl.GetDefaultDevice).

To override the default camera device and resolution selection, use the TakePictureDialog.Device and TakePictureDialog.ResolutionMode properties.

The following example sets the maximum resolution for the selected camera device.

csharp
TakePictureDialog dialog = new TakePictureDialog();
dialog.ResolutionMode = ResolutionMode.Maximum;
dialog.ShowDialog();
vb
Dim dialog As TakePictureDialog = New TakePictureDialog()
dialog.ResolutionMode = ResolutionMode.Maximum
dialog.ShowDialog()

Customize the Dialog and Output Image

The following events allow you to customize the dialog, camera device, resolution and captured image:

  • TakePictureDialog.Showing - Fires when the dialog is about to be displayed. Allows you to customize the form, and specify the camera device and resolution.
  • TakePictureDialog.Closed - Fires when the dialog is closed. Allows you to get the dialog result and captured image, and replace this image.

Inheritance

Object TakePictureDialog

See Also

TakePictureDialog Members

Camera Control

DevExpress.XtraEditors.Camera Namespace