SoZoomy sample ported to 64-bits

This commit is contained in:
Paola Villarreal 2014-07-28 13:38:04 -05:00
Родитель 80b61d38e0
Коммит de54dd9023
7 изменённых файлов: 44 добавлений и 41 удалений

Просмотреть файл

@ -1,6 +1,6 @@
using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace SoZoomy {

Просмотреть файл

@ -1,6 +1,6 @@
using System;
using MonoTouch.UIKit;
using System.Drawing;
using UIKit;
using CoreGraphics;
namespace SoZoomy
{
@ -15,12 +15,12 @@ namespace SoZoomy
ExclusiveTouch = true;
}
public FaceView (RectangleF frame) : base (frame)
public FaceView (CGRect frame) : base (frame)
{
ExclusiveTouch = true;
}
public override void TouchesEnded (MonoTouch.Foundation.NSSet touches, UIEvent evt)
public override void TouchesEnded (Foundation.NSSet touches, UIEvent evt)
{
if (Bounds.Contains ((touches.AnyObject as UITouch).LocationInView (this))) {
base.TouchesEnded (touches, evt);

Просмотреть файл

@ -1,9 +1,9 @@
using System;
using System.Drawing;
using MonoTouch.AVFoundation;
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;
using MonoTouch.UIKit;
using CoreGraphics;
using AVFoundation;
using Foundation;
using ObjCRuntime;
using UIKit;
namespace SoZoomy
{
@ -22,7 +22,7 @@ namespace SoZoomy
{
}
public PreviewView (RectangleF frame) : base (frame)
public PreviewView (CGRect frame) : base (frame)
{
}
*/

2
SoZoomy/SoZoomy/PreviewView.designer.cs сгенерированный
Просмотреть файл

@ -4,7 +4,7 @@
// actions made in the UI designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using MonoTouch.Foundation;
using Foundation;
using System.CodeDom.Compiler;
namespace SoZoomy

Просмотреть файл

@ -17,7 +17,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<DefineConstants>DEBUG;XAMCORE_2_0;ARCH_64</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<MtouchLink>None</MtouchLink>
@ -26,6 +26,7 @@
<MtouchI18n>
</MtouchI18n>
<MtouchArch>ARMv7</MtouchArch>
<MtouchExtraArgs>--registrar:static --nofastsim --override-abi x86_64</MtouchExtraArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>full</DebugType>
@ -85,7 +86,9 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="monotouch" />
<Reference Include="Xamarin.iOS">
<HintPath>\Developer\MonoTouch\usr\lib\mono\Xamarin.iOS\Xamarin.iOS.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
@ -146,4 +149,4 @@
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-Portrait%402x~ipad.png" />
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-Landscape%402x~ipad.png" />
</ItemGroup>
</Project>
</Project>

Просмотреть файл

@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using CoreGraphics;
using System.Linq;
using MonoTouch.AVFoundation;
using MonoTouch.CoreAnimation;
using MonoTouch.CoreFoundation;
using MonoTouch.CoreMedia;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using AVFoundation;
using CoreAnimation;
using CoreFoundation;
using CoreMedia;
using Foundation;
using UIKit;
namespace SoZoomy
{
@ -17,8 +17,8 @@ namespace SoZoomy
AVCaptureDevice device;
AVCaptureMetadataOutput metadataOutput;
Dictionary <int, FaceView> faceViews;
int? lockedFaceID;
float lockedFaceSize;
nint? lockedFaceID;
nfloat lockedFaceSize;
double lockTime;
AVPlayer memeEffect;
AVPlayer beepEffect;
@ -56,7 +56,7 @@ namespace SoZoomy
updateCameraSelection ();
CALayer rootLayer = previewView.Layer;
rootLayer.MasksToBounds = true;
(previewView.Layer as AVCaptureVideoPreviewLayer).VideoGravity = AVLayerVideoGravity.ResizeAspectFill.ToString ();
(previewView.Layer as AVCaptureVideoPreviewLayer).VideoGravity = AVLayerVideoGravity.ResizeAspectFill;
previewView.Layer.BackgroundColor = UIColor.Black.CGColor;
setupAVFoundationFaceDetection ();
@ -184,7 +184,7 @@ namespace SoZoomy
CATransaction.SetValueForKey (NSObject.FromObject (true), (NSString) (CATransaction.DisableActions.ToString ()));
foreach (var face in faces) {
int faceId = (face as AVMetadataFaceObject).FaceID;
int faceId = (int)(face as AVMetadataFaceObject).FaceID;
unseen.Remove (faceId);
seen.Add (faceId);
@ -217,10 +217,10 @@ namespace SoZoomy
}
if (lockedFaceID != null) {
FaceView view = faceViews [lockedFaceID.GetValueOrDefault ()];
float size = (float)Math.Max (view.Frame.Size.Width, view.Frame.Size.Height) / device.VideoZoomFactor;
float zoomDelta = lockedFaceSize / size;
float lockTime = (float)(CATransition.CurrentMediaTime () - this.lockTime);
FaceView view = faceViews [(int)lockedFaceID.GetValueOrDefault ()];
nfloat size = (nfloat)Math.Max (view.Frame.Size.Width, view.Frame.Size.Height) / device.VideoZoomFactor;
nfloat zoomDelta = lockedFaceSize / size;
nfloat lockTime = (nfloat)(CATransition.CurrentMediaTime () - this.lockTime);
float zoomRate = (float)(Math.Log (zoomDelta) / lockTime);
if (Math.Abs (zoomDelta) > 0.1)
device.RampToVideoZoom (zoomRate > 0 ? MaxZoom : 1, zoomRate);
@ -232,7 +232,7 @@ namespace SoZoomy
void TouchCallBack (int faceId, FaceView view)
{
lockedFaceID = faceId;
lockedFaceSize = Math.Max (view.Frame.Size.Width, view.Frame.Size.Height) / device.VideoZoomFactor;
lockedFaceSize = (nfloat)Math.Max (view.Frame.Size.Width, view.Frame.Size.Height) / device.VideoZoomFactor;
lockTime = CATransition.CurrentMediaTime ();
UIView.BeginAnimations (null, IntPtr.Zero);
@ -270,7 +270,7 @@ namespace SoZoomy
clearLockedFace ();
else {
UITouch touch = (UITouch)touches.AnyObject;
PointF point = touch.LocationInView (previewView);
CGPoint point = touch.LocationInView (previewView);
point = (previewView.Layer as AVCaptureVideoPreviewLayer).CaptureDevicePointOfInterestForPoint (point);
if (device.FocusPointOfInterestSupported)
@ -337,8 +337,8 @@ namespace SoZoomy
memeEffect.Seek (CMTime.Zero);
memeEffect.Play ();
NSObject.CancelPreviousPerformRequest (this);
PerformSelector (new MonoTouch.ObjCRuntime.Selector ("flash"), null, MEME_FLASH_DELAY);
PerformSelector (new MonoTouch.ObjCRuntime.Selector ("startZoom:"), NSNumber.FromFloat (getZoomSliderValue ()), MEME_ZOOM_DELAY);
PerformSelector (new ObjCRuntime.Selector ("flash"), null, MEME_FLASH_DELAY);
PerformSelector (new ObjCRuntime.Selector ("startZoom:"), NSNumber.FromFloat (getZoomSliderValue ()), MEME_ZOOM_DELAY);
device.VideoZoomFactor = 1;
foreach (var faceId in faceViews.Keys) {
FaceView view = faceViews [faceId];
@ -389,7 +389,7 @@ namespace SoZoomy
return (float)Math.Pow (MaxZoom, slider.Value);
}
void setZoomSliderValue (float value)
void setZoomSliderValue (nfloat value)
{
slider.Value = (float)Math.Log (value) / (float)Math.Log (MaxZoom);
}

10
SoZoomy/SoZoomy/ViewController.designer.cs сгенерированный
Просмотреть файл

@ -4,7 +4,7 @@
// actions made in the UI designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using MonoTouch.Foundation;
using Foundation;
using System.CodeDom.Compiler;
namespace SoZoomy
@ -13,19 +13,19 @@ namespace SoZoomy
partial class ViewController
{
[Outlet]
MonoTouch.UIKit.UIButton memeButton { get; set; }
UIKit.UIButton memeButton { get; set; }
[Outlet]
SoZoomy.PreviewView previewView { get; set; }
[Outlet]
MonoTouch.UIKit.UISlider slider { get; set; }
UIKit.UISlider slider { get; set; }
[Action ("meme:")]
partial void meme (MonoTouch.Foundation.NSObject sender);
partial void meme (Foundation.NSObject sender);
[Action ("sliderChanged:")]
partial void sliderChanged (MonoTouch.Foundation.NSObject sender);
partial void sliderChanged (Foundation.NSObject sender);
void ReleaseDesignerOutlets ()
{