UNPKG

3.38 kBTypeScriptView Raw
1import { Observable } from 'rxjs/Observable';
2export interface CameraPreviewRect {
3 x: number;
4 y: number;
5 width: number;
6 height: number;
7}
8export interface CameraPreviewSize {
9 maxWidth: number;
10 maxHeight: number;
11}
12/**
13 * @beta
14 * @name CameraPreview
15 * @description
16 * Showing camera preview in HTML
17 *
18 * For more info, please see the [Cordova Camera Preview Plugin Docs](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview).
19 *
20 * @usage
21 * ```
22 * import { CameraPreview, CameraPreviewRect } from 'ionic-native';
23 *
24 * // camera options (Size and location)
25 * let cameraRect: CameraPreviewRect = {
26 * x: 100,
27 * y: 100,
28 * width: 200,
29 * height: 200
30 * };
31 *
32 *
33 * // start camera
34 * CameraPreview.startCamera(
35 * cameraRect, // position and size of preview
36 * 'front', // default camera
37 * true, // tap to take picture
38 * false, // disable drag
39 * false, // keep preview in front. Set to true (back of the screen) to apply overlaying elements
40 * 1 // set the preview alpha
41 * );
42 *
43 * // Set the handler to run every time we take a picture
44 * CameraPreview.setOnPictureTakenHandler().subscribe((result) => {
45 * console.log(result);
46 * // do something with the result
47 * });
48 *
49 *
50 * // take a picture
51 * CameraPreview.takePicture({
52 * maxWidth: 640,
53 * maxHeight: 640
54 * });
55 *
56 * // Switch camera
57 * CameraPreview.switchCamera();
58 *
59 * // set color effect to negative
60 * CameraPreview.setColorEffect('negative');
61 *
62 * // Stop the camera preview
63 * CameraPreview.stopCamera();
64 *
65 * ```
66 *
67 * @interfaces
68 * CameraPreviewRect
69 * CameraPreviewSize
70 */
71export declare class CameraPreview {
72 /**
73 * Starts the camera preview instance.
74 * @param {CameraPreviewRect} position and size of the preview window - {x: number, y: number, width: number, height: number}
75 * @param {string} which camera to use - 'front' | 'back'
76 * @param {boolean} enable tap to take picture
77 * @param {boolean} enable preview box drag across the screen
78 * @param {boolean} send preview box to the back of the webview
79 * @param {number} alpha of the preview box
80 */
81 static startCamera(rect: CameraPreviewRect, defaultCamera: string, tapEnabled: boolean, dragEnabled: boolean, toBack: boolean, alpha: number): void;
82 /**
83 * Stops the camera preview instance.
84 */
85 static stopCamera(): void;
86 /**
87 * Take the picture, the parameter size is optional
88 * @param {CameraPreviewSize} optional - size of the picture to take
89 */
90 static takePicture(size?: CameraPreviewSize): void;
91 /**
92 * Register a callback function that receives the original picture and the image captured from the preview box.
93 * @returns {Observable<any>}
94 */
95 static setOnPictureTakenHandler(): Observable<any>;
96 /**
97 * Switch from the rear camera and front camera, if available.
98 */
99 static switchCamera(): void;
100 /**
101 * Show the camera preview box.
102 */
103 static show(): void;
104 /**
105 * Hide the camera preview box.
106 */
107 static hide(): void;
108 /**
109 * Disables the camera preview
110 */
111 static disable(): void;
112 /**
113 * Set camera color effect.
114 */
115 static setColorEffect(effect: string): void;
116}