cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [9/11] spec commit: [CB-2213] Added native URI display tests.
Date Tue, 12 Feb 2013 03:15:59 GMT
[CB-2213] Added native URI display tests.

Also fixed some formatting.


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/49efc5d4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/49efc5d4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/49efc5d4

Branch: refs/heads/master
Commit: 49efc5d4764209a4f0f439e5b06e63904b3610d6
Parents: 5569edc
Author: Max Woghiren <max.woghiren@gmail.com>
Authored: Thu Jan 24 14:27:07 2013 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Feb 11 21:22:58 2013 -0500

----------------------------------------------------------------------
 camera/index.html |   57 ++++++++++++++++++++++++++++++++++-------------
 1 files changed, 41 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/49efc5d4/camera/index.html
----------------------------------------------------------------------
diff --git a/camera/index.html b/camera/index.html
index 8a48860..ef8e834 100644
--- a/camera/index.html
+++ b/camera/index.html
@@ -67,8 +67,9 @@
     function getPicture() {
         clearStatus();
         navigator.camera.getPicture(getPictureWin, getPictureFail,
-            { quality: 50, destinationType:
-            Camera.DestinationType.FILE_URI, sourceType : Camera.PictureSourceType.CAMERA});
+            { quality: 50,
+              destinationType: Camera.DestinationType.FILE_URI,
+              sourceType : Camera.PictureSourceType.CAMERA });
     }
 
     function uploadImage(srcUrl) {
@@ -102,8 +103,8 @@
                     uploadImage(data);
                 }
             }, getPictureFail,
-            { quality: 50, destinationType:
-            Camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
+            { destinationType: Camera.DestinationType.FILE_URI,
+              sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
     };
 
     /**
@@ -193,8 +194,8 @@
                 fileEntry.file(onFileReceived, onGetFileError);
             },
             onGetPictureError,
-            { quality: 50, destinationType:
-            Camera.DestinationType.NATIVE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
+            { destinationType: Camera.DestinationType.NATIVE_URI,
+              sourceType: Camera.PictureSourceType.PHOTOLIBRARY });
     };
 
     function copyImageUsingNativeUri() {
@@ -225,8 +226,8 @@
                     fileEntry.copyTo(destDirEntry, 'copied_file.png', onFileCopied, onFileCopyError);
                 },
                 onGetPictureError,
-                { quality: 50, destinationType:
-                Camera.DestinationType.NATIVE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
+                { destinationType: Camera.DestinationType.NATIVE_URI,
+                  sourceType: Camera.PictureSourceType.PHOTOLIBRARY });
         };
 
         clearStatus();
@@ -276,8 +277,8 @@
                 fileEntry.createWriter(onFileTruncateWriterReceived, onCreateWriterError);
             },
             onGetPictureError,
-            { quality: 50, destinationType:
-            Camera.DestinationType.NATIVE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
+            { destinationType: Camera.DestinationType.NATIVE_URI,
+              sourceType: Camera.PictureSourceType.PHOTOLIBRARY });
     };
 
     function uploadImageUsingNativeUri() {
@@ -300,9 +301,30 @@
                 fileTransfer.upload(data, "http://cordova-filetransfer.jitsu.com/upload",
onFileUploaded, onFileUploadError, options);
             },
             onGetPictureError,
-            { quality: 50, destinationType:
-            Camera.DestinationType.NATIVE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
+            { destinationType: Camera.DestinationType.NATIVE_URI,
+              sourceType: Camera.PictureSourceType.PHOTOLIBRARY });
+    };
 
+    function displayImageUsingNativeUri() {
+        clearStatus();
+        navigator.camera.getPicture(
+            function(data) {
+                // First, we display the image using the img tag.
+                document.getElementById('camera_status').innerHTML += "img tag: <img src=\""
+ data + "\" /><br />";
+
+                // Next, the canvas tag.
+                document.getElementById('camera_status').innerHTML += "canvas tag: <canvas
id=\"nativeUriCanvas\" width=\"300\" height=\"300\"></canvas>";
+                var canvas = document.getElementById('nativeUriCanvas');
+                var context = canvas.getContext('2d');
+                var image = new Image();
+                image.onload = function() {
+                    context.drawImage(image, 0, 0);
+                };
+                image.src = data;
+            },
+            onGetPictureError,
+            { destinationType: Camera.DestinationType.NATIVE_URI,
+              sourceType: Camera.PictureSourceType.PHOTOLIBRARY });
     };
 
     function testNativeFile(inputEl) {
@@ -398,10 +420,13 @@
     </div>
     <h2>Action</h2>
     <div class="btn large" onclick="getPicture();">Take Picture</div>
-    <div class="btn large" onclick="getImageUsingNativeUri();">Select Image Using Native
URI</div>
-    <div class="btn large" onclick="copyImageUsingNativeUri();">Copy Image Using Native
URI</div>
-    <div class="btn large" onclick="writeImageUsingNativeUri();">Write Image Using
Native URI</div>
-    <div class="btn large" onclick="uploadImageUsingNativeUri();">Upload Image Using
Native URI</div>
+    <div class="btn large" onclick="getImageUsingFileUri();">Select Image Using File
URI</div>
+    <h2>Native URI</h2>
+    <div class="btn large" onclick="getImageUsingNativeUri();">Select Image</div>
+    <div class="btn large" onclick="copyImageUsingNativeUri();">Copy Image</div>
+    <div class="btn large" onclick="writeImageUsingNativeUri();">Write Image</div>
+    <div class="btn large" onclick="uploadImageUsingNativeUri();">Upload Image</div>
+    <div class="btn large" onclick="displayImageUsingNativeUri();">Display Image</div>
     <h3>input type=file</h3>
     <input type="file" onchange="testNativeFile(this)">
     <h3>capture=camera</h3>


Mime
View raw message