web-bizz/com.customplugins.camera
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf400
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fswiss\fcharset0 ArialMT;\f2\fnil\fcharset0 HelveticaNeue;
\f3\fnil\fcharset0 Monaco;}
{\colortbl;\red255\green255\blue255;\red134\green19\blue62;\red38\green38\blue38;\red26\green26\blue26;
\red205\green205\blue205;\red198\green50\blue253;\red52\green0\blue71;\red34\green0\blue47;\red244\green241\blue239;
\red0\green68\blue254;\red0\green61\blue204;\red102\green0\blue141;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}}
\margl1440\margr1440\vieww26680\viewh17180\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\f0\fs24 \cf0
\b\fs48 Instructions for custom camera plugin
\b0 \
\pard\pardeftab720
\f1\fs28 \cf2 \
*This new custom camera plugin follows the Android API instructions on {\field{\*\fldinst{HYPERLINK "http://developer.android.com/guide/topics/media/camera.html#custom-camera"}}{\fldrslt http://developer.android.com/guide/topics/media/camera.html#custom-camera}}.\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardeftab720\pardirnatural
\f0 \cf2 *The Phonegap app is not restarted by the Android GC when the new custom camera plugin methods are called.
\f1 \
\pard\pardeftab720
\cf2 *This plugin supports Phonegap Version 3+ Instructions for installing configuring on Phonegap 3+ (instruction for plugman install)\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\f0\fs24 \cf0 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\b\fs36 \cf0 - Installing the plugin\
\pard\pardeftab720
\f1\b0\fs28 \cf3 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\f0\fs32 \cf4 1) You can install this plugin using following CLI command
\fs30 \cf4 \
\i \cb5 cordova plugin add Path/to/Plugin\cb1 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i0\fs28 \cf0 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\b\fs36 \cf0 - Using the plugin
\b0\fs24 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\fs28 \cf0 Call the plugin from JavaScript. The API
\fs30 follows same calling convention as Phonegap navigator.camera.getPicture, as defined here:\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
{\field{\*\fldinst{HYPERLINK "http://docs.phonegap.com/en/3.2.0/cordova_camera_camera.md.html#camera.getPicture"}}{\fldrslt \cf0 http://docs.phonegap.com/en/3.2.0/cordova_camera_camera.md.html#camera.getPicture}}\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\fs28 \cf0 .\
\
```js\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i \cf6 navigator.customCamera.getPicture(success, failure, [ options ]);
\i0 \cf0 \
```\
\
| Parameter | Description |\
| ----------------------- | --------------------------| \
| \cf7 success\cf0 | A callback which will be executed on successful capture with the file URI as the first parameter. |\
| \cf7 error\cf0 | A callback which will be executed if the capture fails with an error message as the first parameter. |\
| \cf8 options\cf0 | An optional object specifying capture options. |\
\
\b ### Capture options\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\b0 \cf0 \
\pard\tx220\tx720\pardeftab720\li720\fi-720\sl400\sa240
\f2\b\fs26 \cf0 \cb9 \'95
\f0\fs28 \cf10 \cb1 quality
\b0 \cf0 : Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Number) \
\pard\tx220\tx720\pardeftab720\li720\fi-720\sl400\sa240
\f2\b \cf0 \cb9 \'95 \cf11 targetWidth
\b0 \cf0 : Width in pixels to scale image. Must be used with
\b targetHeight
\b0 . Aspect ratio remains constant.
\i (Number)
\i0 \
\pard\tx220\tx720\pardeftab720\li720\fi-720\sl400\sa240
\ls1\ilvl0
\b \cf0 {\listtext \'95 }\cf11 targetHeight
\b0 \cf0 : Height in pixels to scale image. Must be used with
\b targetWidth
\b0 . Aspect ratio remains constant.
\i (Number)
\i0 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\f0 \cf0 \cb1 \
\pard\tx220\tx720\pardeftab720\li720\fi-720\sl400\sa240
\f2\b\fs26 \cf0 \cb9 \'95
\f0\fs28 \cf11 \cb1 destinationType
\b0 \cf0 : Choose the format of the return value. Defined in navigator.camera.DestinationType (Number)\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i \cf0 customCamera.DestinationType = \{\
DATA_URL : 0, // Return image as base64-encoded string\
FILE_URI : 1, // Return image file URI\
\};\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i0 \cf0 \
\
\pard\tx220\tx720\pardeftab720\li720\fi-720\sl400\sa240
\f2\b\fs26 \cf0 \cb9 \'95
\f0\fs28 \cf11 \cb1 pictureSourceType
\b0 \cf0 : Set the source of the picture. Defined in navigator.camera.PictureSourceType (Number)\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i \cf0 Camera.PictureSourceType = \{\
PHOTOLIBRARY : 0,\
CAMERA : 1,\
\};\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i0 \cf0 \
\pard\tx220\tx720\pardeftab720\li720\fi-720\sl400\sa240
\f2\b\fs26 \cf0 \cb9 \'95
\fs28 \cf11 cameraDirection
\b0 \cf0 : Choose the camera to use (front- or back-facing). Defined in
\f3 navigator.camera.Direction
\f2\i (Number)\
customCamera.Direction = \{\
BACK : 0, // Use the back-facing camera\
FRONT : 1 // Use the front-facing camera\
\};
\f0\i0 \cb1 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\cf0 \
### Image scaling\
\
Setting both targetWidth and targetHeight to -1 will disable image scaling. Setting both values to positive integers will scale the image to that exact size which may result in distortion. If the aspect ratio should be respected, supply only the targetWidth or targetHeight and the other will be set based on the aspect ratio.\
\
### Example\
\
```js\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i \cf12 customCamera.getPicture(onPhotoDataSuccess, onFail, \{ quality: 100,\
destinationType: destinationType.DATA_URL,\
pictureSourceType: pictureSource.CAMERA,\
direction: customCamera.Direction.BACK \});\cf0 \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i0 \cf0 ```\
\
I have attached my testing project.\
I have created this project by CLI command.\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i \cf0 cordova create mytesting\
cordova platform add android\
cordova plugin add PathToPlugin\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i0 \cf0 \
and run\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i \cf0 cordova run android\
\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
\i0 \cf0 \
All testing was OK!}