You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/05/09 00:23:52 UTC
[1/2] git commit: CB-6612 camera.getPicture now always returns
encoded JPEG image
Repository: cordova-plugin-camera
Updated Branches:
refs/heads/master 30a75e3fa -> 10e545535
CB-6612 camera.getPicture now always returns encoded JPEG image
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/9e0d9439
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/9e0d9439
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/9e0d9439
Branch: refs/heads/master
Commit: 9e0d9439714b54540685f7daa23f713ca17d28f6
Parents: 0c9de56
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Fri May 2 10:51:32 2014 +0400
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Mon May 5 09:27:45 2014 +0400
----------------------------------------------------------------------
src/wp/Camera.cs | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/9e0d9439/src/wp/Camera.cs
----------------------------------------------------------------------
diff --git a/src/wp/Camera.cs b/src/wp/Camera.cs
index b76929b..30bb5e8 100644
--- a/src/wp/Camera.cs
+++ b/src/wp/Camera.cs
@@ -343,18 +343,8 @@ namespace WPCordovaClassLib.Cordova.Commands
try
{
- //use photo's actual width & height if user doesn't provide width & height
- if (cameraOptions.TargetWidth < 0 && cameraOptions.TargetHeight < 0)
- {
- int streamLength = (int)stream.Length;
- imageContent = new byte[streamLength + 1];
- stream.Read(imageContent, 0, streamLength);
- }
- else
- {
- // resize photo
- imageContent = ResizePhoto(stream);
- }
+ // Resize photo and convert to JPEG
+ imageContent = ResizePhoto(stream);
}
finally
{
@@ -368,7 +358,6 @@ namespace WPCordovaClassLib.Cordova.Commands
/// Resize image
/// </summary>
/// <param name="stream">Image stream</param>
- /// <param name="fileData">File data</param>
/// <returns>resized image</returns>
private byte[] ResizePhoto(Stream stream)
{
@@ -382,10 +371,22 @@ namespace WPCordovaClassLib.Cordova.Commands
WriteableBitmap objWB = new WriteableBitmap(objBitmap);
objBitmap.UriSource = null;
- //Keep proportionally
- double ratio = Math.Min((double)cameraOptions.TargetWidth / objWB.PixelWidth, (double)cameraOptions.TargetHeight / objWB.PixelHeight);
- int width = Convert.ToInt32(ratio * objWB.PixelWidth);
- int height = Convert.ToInt32(ratio * objWB.PixelHeight);
+ // Calculate resultant image size
+ int width, height;
+ if (cameraOptions.TargetWidth >= 0 && cameraOptions.TargetHeight >= 0)
+ {
+ // Keep proportionally
+ double ratio = Math.Min(
+ (double)cameraOptions.TargetWidth / objWB.PixelWidth,
+ (double)cameraOptions.TargetHeight / objWB.PixelHeight);
+ width = Convert.ToInt32(ratio * objWB.PixelWidth);
+ height = Convert.ToInt32(ratio * objWB.PixelHeight);
+ }
+ else
+ {
+ width = objWB.PixelWidth;
+ height = objWB.PixelHeight;
+ }
//Hold the result stream
using (MemoryStream objBitmapStreamResized = new MemoryStream())
[2/2] git commit: Merge branch 'CB-6612' of
https://github.com/MSOpenTech/cordova-plugin-camera
Posted by pu...@apache.org.
Merge branch 'CB-6612' of https://github.com/MSOpenTech/cordova-plugin-camera
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/10e54553
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/10e54553
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/10e54553
Branch: refs/heads/master
Commit: 10e5455356ef658789b1a238bc14f5b38414a18d
Parents: 30a75e3 9e0d943
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 8 15:06:17 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 8 15:06:17 2014 -0700
----------------------------------------------------------------------
src/wp/Camera.cs | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------