PowerApps 中的照相机控件Camera control in PowerApps

一个控件,用户通过此控件可使用设备上的照相机拍照。A control with which the user can take photos by using the camera on the device.

说明Description

如果添加此控件,用户可从应用运行的任何位置使用一张或多张照片更新数据源。If you add this control, the user can update a data source with one or more photos from wherever the app is running.

关键属性Key properties

Camera - 在具有多个照相机的设备上,应用所使用的照相机的数字 ID。Camera – On a device that has more than one camera, the numeric ID of the camera that the app uses.

其他属性Additional properties

BorderColor – 控件边框的颜色。BorderColor – The color of a control's border.

BorderStyle – 控件边框是实线虚线点线还是BorderStyle – Whether a control's border is Solid, Dashed, Dotted, or None.

BorderThickness – 控件边框的粗细。BorderThickness – The thickness of a control's border.

Brightness - 用户在图像中可能感知到的光线强度。Brightness – How much light the user is likely to perceive in an image.

Contrast - 用户可区分图像中相似颜色的轻松程度。Contrast – How easily the user can distinguish between similar colors in an image.

DisplayMode – 此控件是允许用户输入 (Edit)、仅显示数据 (View),还是已禁用 (Disabled)。DisplayMode – Whether the control allows user input (Edit), only displays data (View), or is disabled (Disabled).

Height – 控件上边缘和下边缘之间的距离。Height – The distance between a control's top and bottom edges.

OnSelect – 用户点击或单击某个控件时应用响应的方式。OnSelect – How the app responds when the user taps or clicks a control.

OnStream - 更新 Stream 属性时应用的响应方式。OnStream – How the app responds when the Stream property is updated.

Photo - 用户拍摄照片时捕获的图像。Photo – The image captured when the user takes a picture.

Stream - 基于 StreamRate 属性自动更新的图像。Stream – Automatically updated image based on the StreamRate property.

StreamRate - 在 Stream 属性上更新图像的频率(以毫秒为单位)。StreamRate – How often to update the image on the Stream property, in milliseconds. 此值的范围介于 100(1/10 秒)到 3,600,000(1 小时)之间。This value can range from 100 (1/10th of a second) to 3,600,000 (1 hour).

Tooltip - 用户将鼠标悬停在控件上时显示的解释性文本。Tooltip – Explanatory text that appears when the user hovers over a control.

Visible – 控件显示还是隐藏。Visible – Whether a control appears or is hidden.

Width – 控件左边缘和右边缘之间的距离。Width – The distance between a control's left and right edges.

X - 控件左边缘与其父容器(如果没有父容器,则为屏幕)左边缘之间的距离。X – The distance between the left edge of a control and the left edge of its parent container (screen if no parent container).

Y - 控件上边缘与其父容器(如果没有父容器,则为屏幕)上边缘之间的距离。Y – The distance between the top edge of a control and the top edge of the parent container (screen if no parent container).

Zoom – 相机中图像被放大的百分比或 PDF 查看器中文件的视图百分比。Zoom – The percentage by which an image from a camera is magnified or the view of a file in a PDF viewer.

Patch( DataSource, BaseRecord, ChangeRecord )Patch( DataSource, BaseRecord, ChangeRecord )

示例Example

  1. 添加“照相机”控件,将其命名为 MyCamera,并将其 OnSelect 属性设置为以下公式:Add a Camera control, name it MyCamera, and set its OnSelect property to this formula:
    Collect(MyPix, MyCamera.Photo)Collect(MyPix, MyCamera.Photo)

    不知道如何添加、命名和配置控件Don't know how to add, name, and configure a control?

    想要了解有关 Collect 函数或其他函数的详细信息?Want more information about the Collect function or other functions?

  2. 按 F5,然后单击或点击 MyCamera 进行拍照。Press F5, and then take a photo by clicking or tapping MyCamera.
  3. 添加图像库控件,然后重新调整其图像控件、其模板以及“图像库”控件本身的大小,以适应屏幕大小。Add an Image gallery control, and then resize its Image control, its template, and the Image gallery control itself to fit in the screen.
  4. 将“图像库”控件的 Items 属性设置为以下表达式:Set the Items property of the Image gallery control to this expression:
    MyPix.UrlMyPix.Url.
  5. 将库中的“图像”控件的 Image 属性设置为以下表达式:Set the Image property of the Image control in the gallery to this expression:
    ThisItem.UrlThisItem.Url

    拍摄的照片将在“图像库”控件中显示。The photo that you took appears in the Image gallery control.

  6. 拍摄所需数量的照片,然后按 Esc 返回默认工作区。Take as many photos as you want, and then return to the default workspace by pressing Esc.
  7. (可选)将“图像库”控件中“图像”控件的 OnSelect 属性设置为 Remove(MyPix, ThisItem),按 F5,然后单击或点击照片将其删除。(optional) Set the OnSelect property of the Image control in the Image gallery control to Remove(MyPix, ThisItem), press F5, and then click or tap a photo to remove it.

使用 SaveData 函数本地保存照片或使用 Patch 函数更新数据源。Use the SaveData function to save the photos locally or the Patch function to update a data source.