Giter Site home page Giter Site logo

sergenarhi / cordovacamerapreview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cordova-plugin-camera-preview/cordova-plugin-camera-preview

9.0 5.0 2.0 9.65 MB

Cordova plugin that allow camera interaction from HTML code

License: Apache License 2.0

Java 47.29% Objective-C 50.77% JavaScript 1.94%

cordovacamerapreview's Introduction

Cordova CameraPreview Plugin

Cordova plugin that allows camera interaction from HTML code.
Show camera preview popup on top of the HTML.

Features:

  • Start a camera preview from HTML code.
  • Drag the preview box.
  • Set camera color effect (Android and iOS).
  • Send the preview box to back of the HTML content.
  • Set a custom position for the camera preview box.
  • Set a custom size for the preview box.
  • Maintain HTML interactivity.

Installation:

cordova plugin add https://github.com/mbppower/CordovaCameraPreview.git

Phonegap Build:

<gap:plugin name="com.mbppower.camerapreview" version="0.0.8" source="plugins.cordova.io" />

Methods:

startCamera(rect, defaultCamera, tapEnabled, dragEnabled, toBack)
Starts the camera preview instance.

When setting the toBack to TRUE, remember to add the style bellow on your app's HTML body element:

style="background-color='transparent'"

Javascript:

var tapEnabled = true; //enable tap take picture
var dragEnabled = true; //enable preview box drag across the screen
var toBack = true; //send preview box to the back of the webview
var rect = {x: 100, y: 100, width: 200, height:200};
cordova.plugins.camerapreview.startCamera(rect, "front", tapEnabled, dragEnabled, toBack)

stopCamera()
Stops the camera preview instance.

cordova.plugins.camerapreview.stopCamera();

takePicture(size)
Take the picture, the parameter size is optional

cordova.plugins.camerapreview.takePicture({maxWidth:640, maxHeight:640});

setOnPictureTakenHandler(callback)
Register a callback function that receives the original picture and the image captured from the preview box.

cordova.plugins.camerapreview.setOnPictureTakenHandler(function(result){
	document.getElementById('originalPicture').src = result[0];//originalPicturePath;
	document.getElementById('previewPicture').src = result[1];//previewPicturePath;
});

switchCamera()
Switch from the rear camera and front camera, if available.

cordova.plugins.camerapreview.switchCamera();

show()
Show the camera preview box.

cordova.plugins.camerapreview.show();

hide()
Hide the camera preview box.

cordova.plugins.camerapreview.hide();

Base64 image:
Use the cordova-file in order to read the picture file and them get the base64.
Please, refer to this documentation: http://docs.phonegap.com/en/edge/cordova_file_file.md.html
Method readAsDataURL: Read file and return data as a base64-encoded data URL.

Sample:
Please see the CordovaCameraPreviewApp for a complete working example for Android and iOS platforms.

Android Screenshots:

cordovacamerapreview's People

Contributors

mbppower avatar toots avatar eorlov88 avatar jacobweber avatar shark0der avatar scarych avatar squio avatar rabbott2010 avatar

Stargazers

Kshitiz Shankar avatar Fabio Di Sotto avatar DEO avatar adamscybot avatar Michał Wilski avatar Waylon avatar Guillermo Horno avatar Weston Ganger avatar

Watchers

James Cloos avatar Henrik avatar Evgeniy Orlov avatar Michał Wilski avatar Serge Närhi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.