-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(canvas-camera): add CanvasCamera support
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import {Plugin, Cordova} from './plugin'; | ||
/** | ||
* @name CanvasCamera | ||
* @description | ||
* | ||
* @usage | ||
* ``` | ||
* import {CanvasCamera} from 'ionic-native'; | ||
* | ||
* let object = document.getElementById('myDiv'); | ||
* // or | ||
* @ViewChild('myDiv') object; | ||
* | ||
* CanvasCamera.initialize(object); | ||
* | ||
* CanvasCamera.start(); | ||
* | ||
* CanvasCamera.takePicture().then(picture => { }); | ||
* | ||
* ``` | ||
*/ | ||
@Plugin({ | ||
plugin: 'com.keith.cordova.plugin.canvascamera', | ||
pluginRef: 'CanvasCamera', | ||
repo: 'https://github.com/donaldp24/CanvasCameraPlugin' | ||
}) | ||
export class CanvasCamera { | ||
static DestinationType = { | ||
DATA_URL: 0, | ||
FILE_URI: 1 | ||
}; | ||
static PictureSourceType = { | ||
PHOTOLIBRARY : 0, | ||
CAMERA : 1, | ||
SAVEDPHOTOALBUM : 2 | ||
}; | ||
static EncodingType = { | ||
JPEG : 0, | ||
PNG : 1 | ||
}; | ||
static CameraPosition = { | ||
BACK : 0, | ||
FRONT : 1 | ||
}; | ||
static CameraPosition = { | ||
BACK : 1, | ||
FRONT : 2 | ||
}; | ||
static FlashMode = { | ||
OFF : 0, | ||
ON : 1, | ||
AUTO : 2 | ||
}; | ||
/** | ||
* Initialize the Camera | ||
* @param htmlElement {HTMLElement} The HTML Element to preview the camera in | ||
*/ | ||
@Cordova({sync: true}) | ||
static initialize(htmlElement: HTMLElement): void { } | ||
|
||
/** | ||
* Start capture video as images from camera to preview camera on web page. | ||
* @param options | ||
*/ | ||
@Cordova({sync: true}) | ||
static start(options?: { | ||
quality?: number; | ||
sourceType?: number; | ||
destinationType?: number; | ||
allowEdit?: boolean; | ||
correctOrientation?: boolean; | ||
saveToPhotoAlbum?: boolean; | ||
encodingType?: number; | ||
width?: number; | ||
height?: number; | ||
}): void { } | ||
|
||
/** | ||
* Takes a photo | ||
* @returns {Promise<any>} | ||
*/ | ||
@Cordova() | ||
static takePicture(): Promise<any> {return; } | ||
|
||
/** | ||
* Sets the flash mode | ||
* @param flashMode {number} Flash mode, use CanvasCamera.FlashMode constant to set | ||
*/ | ||
@Cordova({sync: true}) | ||
static setFlashMode(flashMode: number): void { } | ||
|
||
/** | ||
* Set camera position | ||
* @param cameraPosition {number} Camera Position, use CanvasCamera.CameraPosition constant | ||
*/ | ||
@Cordova({sync: true}) | ||
static setCameraPosition(cameraPosition: number): void {} | ||
} |