mirror of
https://gitee.com/shuto/customCamera.git
synced 2024-10-06 02:12:07 +08:00
Fix multiples bugs and warning.
This commit is contained in:
parent
856535ee85
commit
e195d3db13
22
src/ios/classes/AVCamViewController.h
Normal file → Executable file
22
src/ios/classes/AVCamViewController.h
Normal file → Executable file
@ -3,28 +3,29 @@
|
||||
|
||||
@interface AVCamViewController : UIViewController
|
||||
{
|
||||
NSData *_imageData;
|
||||
void(^_callback)(UIImage*);
|
||||
NSData *_imageData;
|
||||
void (^_callback)(UIImage *, NSString *, NSString *);
|
||||
|
||||
UIPinchGestureRecognizer *twoFingerPinch;
|
||||
UIPinchGestureRecognizer *twoFingerPinch;
|
||||
|
||||
CGRect frameBtnThumb;
|
||||
|
||||
UIImage *capturedImage;
|
||||
NSData *capturedImageData;
|
||||
CGRect frameBtnThumb;
|
||||
|
||||
BOOL isRotated;
|
||||
UIImage *capturedImage;
|
||||
NSData *capturedImageData;
|
||||
|
||||
BOOL isRotated;
|
||||
|
||||
CGFloat fDist;
|
||||
|
||||
}
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView *saveBgPanel;
|
||||
@property (weak, nonatomic) IBOutlet UIView *topBgPanel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *capturedImageView;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIButton *btnBigDeletePicture;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *btnDeletePicture;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *btnSaveImage;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *btnBigSaveImage;
|
||||
@property (weak, nonatomic) IBOutlet UISlider *opacitySlider;
|
||||
|
||||
|
||||
@ -33,8 +34,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
- (id) initWithParams:(CameraParameter *)parameter WithCallback:(void(^)(UIImage*))callback;
|
||||
- (id)initWithParams:(CameraParameter *)parameter WithCallback:(void (^)(UIImage *, NSString *, NSString *))callback;
|
||||
|
||||
|
||||
|
||||
|
1040
src/ios/classes/AVCamViewController.m
Normal file → Executable file
1040
src/ios/classes/AVCamViewController.m
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
82
src/ios/classes/AVCamViewController_iPad.xib
Normal file → Executable file
82
src/ios/classes/AVCamViewController_iPad.xib
Normal file → Executable file
@ -1,12 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="5056" systemVersion="12F45" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="6254" systemVersion="14A389" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment defaultVersion="1536" identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="AVCamViewController">
|
||||
<connections>
|
||||
<outlet property="btnBigDeletePicture" destination="IqJ-oc-995" id="T1H-10-ESB"/>
|
||||
<outlet property="btnBigSaveImage" destination="EFe-fE-P8a" id="P0Z-Xm-thh"/>
|
||||
<outlet property="btnDeletePicture" destination="S1N-v6-cZw" id="1TW-yQ-2Ul"/>
|
||||
<outlet property="btnFlash" destination="KMs-9J-eHV" id="pdI-VZ-buj"/>
|
||||
<outlet property="btnSaveImage" destination="JJc-KF-LjK" id="att-go-Xq7"/>
|
||||
@ -37,7 +39,7 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</imageView>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="sample.png" id="hb3-4z-EqI">
|
||||
<rect key="frame" x="0.0" y="90" width="768" height="844"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</imageView>
|
||||
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="cxS-Qn-d9p">
|
||||
@ -56,29 +58,51 @@
|
||||
</imageView>
|
||||
<view alpha="0.5" contentMode="scaleToFill" id="xaA-dP-8ce">
|
||||
<rect key="frame" x="0.0" y="934" width="768" height="90"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="IqJ-oc-995">
|
||||
<rect key="frame" x="0.0" y="0.0" width="376" height="90"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
|
||||
<state key="normal">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onDeletePicture:" destination="-1" eventType="touchUpInside" id="XkX-0N-K4g"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="EFe-fE-P8a">
|
||||
<rect key="frame" x="384" y="0.0" width="384" height="90"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" heightSizable="YES"/>
|
||||
<state key="normal">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onSaveImage:" destination="-1" eventType="touchUpInside" id="pMu-f6-poC"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="S1N-v6-cZw">
|
||||
<rect key="frame" x="147" y="20" width="50" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<state key="normal" image="icon_delete.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onDeletePicture:" destination="-1" eventType="touchUpInside" id="7ty-gh-NHC"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="JJc-KF-LjK">
|
||||
<rect key="frame" x="566" y="20" width="50" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
|
||||
<state key="normal" image="icon_submit.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onSaveImage:" destination="-1" eventType="touchUpInside" id="mry-0F-fqI"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="S1N-v6-cZw">
|
||||
<rect key="frame" x="147" y="950" width="50" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<state key="normal" image="icon_delete.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onDeletePicture:" destination="-1" eventType="touchUpInside" id="7ty-gh-NHC"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="JJc-KF-LjK">
|
||||
<rect key="frame" x="566" y="954" width="50" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
|
||||
<state key="normal" image="icon_submit.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onSaveImage:" destination="-1" eventType="touchUpInside" id="mry-0F-fqI"/>
|
||||
</connections>
|
||||
</button>
|
||||
<view alpha="0.5" contentMode="scaleToFill" id="kso-6k-eTa">
|
||||
<rect key="frame" x="0.0" y="0.0" width="768" height="90"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
@ -94,7 +118,7 @@
|
||||
<action selector="onBack:" destination="-1" eventType="touchUpInside" id="zpX-8h-Pcs"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="br3-lo-te3">
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="br3-lo-te3">
|
||||
<rect key="frame" x="480" y="20" width="50" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" image="icon_flip.png">
|
||||
@ -135,7 +159,6 @@
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
@ -150,4 +173,9 @@
|
||||
<image name="icon_submit.png" width="60" height="60"/>
|
||||
<image name="sample.png" width="483" height="263"/>
|
||||
</resources>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination"/>
|
||||
</simulatedMetricsContainer>
|
||||
</document>
|
||||
|
126
src/ios/classes/AVCamViewController_iPhone.xib
Normal file → Executable file
126
src/ios/classes/AVCamViewController_iPhone.xib
Normal file → Executable file
@ -1,13 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="5056" systemVersion="12F45" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment defaultVersion="1536" identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="AVCamViewController">
|
||||
<connections>
|
||||
<outlet property="btnBack" destination="JSx-s3-uHS" id="gtj-U7-7eS"/>
|
||||
<outlet property="btnBigDeletePicture" destination="9ml-dK-r4P" id="v1z-D4-2aN"/>
|
||||
<outlet property="btnBigSaveImage" destination="P2D-hm-Kcg" id="81p-6x-fIz"/>
|
||||
<outlet property="btnDeletePicture" destination="J6B-b3-9jL" id="Odf-du-kBy"/>
|
||||
<outlet property="btnFlash" destination="BRk-mk-jo0" id="JMg-ha-GzP"/>
|
||||
<outlet property="btnSaveImage" destination="gCj-9O-Lhz" id="Tg2-gh-nlr"/>
|
||||
@ -38,7 +40,7 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</imageView>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="sample.png" id="GAn-hK-ROm">
|
||||
<rect key="frame" x="0.0" y="60" width="320" height="448"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</imageView>
|
||||
<button opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="usa-GD-lMO">
|
||||
@ -57,32 +59,79 @@
|
||||
</imageView>
|
||||
<view alpha="0.5" contentMode="scaleToFill" id="AJN-IB-tiU">
|
||||
<rect key="frame" x="0.0" y="508" width="320" height="60"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="9ml-dK-r4P">
|
||||
<rect key="frame" x="0.0" y="0.0" width="160" height="60"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<state key="normal">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onDeletePicture:" destination="-1" eventType="touchUpInside" id="MyT-W6-Zcm"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="P2D-hm-Kcg">
|
||||
<rect key="frame" x="160" y="0.0" width="160" height="60"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<state key="normal">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onSaveImage:" destination="-1" eventType="touchUpInside" id="HXF-We-dau"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="gCj-9O-Lhz">
|
||||
<rect key="frame" x="245" y="15" width="30" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
|
||||
<state key="normal" image="icon_submit.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onSaveImage:" destination="-1" eventType="touchUpInside" id="hLE-rb-Fpv"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="J6B-b3-9jL">
|
||||
<rect key="frame" x="45" y="15" width="30" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<state key="normal" image="icon_delete.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onDeletePicture:" destination="-1" eventType="touchUpInside" id="vby-qq-Okp"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="gCj-9O-Lhz">
|
||||
<rect key="frame" x="245" y="523" width="30" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
|
||||
<state key="normal" image="icon_submit.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onSaveImage:" destination="-1" eventType="touchUpInside" id="hLE-rb-Fpv"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="J6B-b3-9jL">
|
||||
<rect key="frame" x="45" y="523" width="30" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<state key="normal" image="icon_delete.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onDeletePicture:" destination="-1" eventType="touchUpInside" id="vby-qq-Okp"/>
|
||||
</connections>
|
||||
</button>
|
||||
<view alpha="0.5" contentMode="scaleToFill" id="qKn-KP-yGM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="60"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="OWo-yv-W9g">
|
||||
<rect key="frame" x="234" y="17" width="25" height="25"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" image="icon_min.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<state key="selected" image="icon_max.png"/>
|
||||
<connections>
|
||||
<action selector="onTapThumb:" destination="-1" eventType="touchUpInside" id="zSf-cq-fIV"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="jnK-sC-Roz">
|
||||
<rect key="frame" x="180" y="15" width="30" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" image="icon_flip.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="changeCamera:" destination="-1" eventType="touchUpInside" id="UhB-S7-CvX"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="JSx-s3-uHS">
|
||||
@ -95,27 +144,6 @@
|
||||
<action selector="onBack:" destination="-1" eventType="touchUpInside" id="dpX-Bq-HAw"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="jnK-sC-Roz">
|
||||
<rect key="frame" x="180" y="15" width="30" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" image="icon_flip.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="changeCamera:" destination="-1" eventType="touchUpInside" id="UhB-S7-CvX"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="OWo-yv-W9g">
|
||||
<rect key="frame" x="234" y="17" width="25" height="25"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" image="icon_min.png">
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<state key="selected" image="icon_max.png"/>
|
||||
<connections>
|
||||
<action selector="onTapThumb:" destination="-1" eventType="touchUpInside" id="zSf-cq-fIV"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="BRk-mk-jo0">
|
||||
<rect key="frame" x="280" y="15" width="30" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
@ -136,6 +164,7 @@
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<nil key="simulatedStatusBarMetrics"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
@ -150,4 +179,9 @@
|
||||
<image name="icon_submit.png" width="60" height="60"/>
|
||||
<image name="sample.png" width="483" height="263"/>
|
||||
</resources>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination" type="retina4"/>
|
||||
</simulatedMetricsContainer>
|
||||
</document>
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
@implementation CameraParameter
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@synthesize bgImageData;
|
||||
@ -19,42 +18,39 @@
|
||||
@synthesize nDefaultCamera;
|
||||
@synthesize bSwitchCamera;
|
||||
|
||||
-(id) initWithCommand :(CDVInvokedUrlCommand *)command
|
||||
{
|
||||
if(self = [super init])
|
||||
{
|
||||
- (id)initWithCommand:(CDVInvokedUrlCommand *)command {
|
||||
if (self = [super init]) {
|
||||
// imgBackgroundBase64: null, // background picture in base64.
|
||||
// imgBackgroundBase64OtherOrientation: null, // background picture in base64 for second orientation. If it's not defined, imgBackgroundBase64 is used.
|
||||
// miniature: true, // active or disable the miniature function.
|
||||
// saveInGallery: false, // save or not the picture in gallery.
|
||||
// cameraBackgroundColor: "#e26760", // color of the camera button.
|
||||
// cameraBackgroundColorPressed: "#dc453d", // color of the pressed camera button.
|
||||
// // To get supported color formats, go to see method parseColor : http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)
|
||||
// quality: 100, // picture's quality : range 0 - 100 : http://developer.android.com/reference/android/graphics/Bitmap.html#compress(android.graphics.Bitmap.CompressFormat, int, java.io.OutputStream) (parameter "quality")
|
||||
// opacity: true, // active or disable the opacity function.
|
||||
// defaultFlash: this.FlashModes.DISABLE, // default state for flash. See CustomCamera.FlashModes for corrects values.
|
||||
// switchFlash: true, // active or disable the switch flash button.
|
||||
// defaultCamera: this.CameraFacings.BACK, // default camera used. See CustomCamera.CameraFacings for corrects values.
|
||||
// switchCamera: true // active or disable the switch camera button.
|
||||
|
||||
// imgBackgroundBase64: null, // background picture in base64.
|
||||
// imgBackgroundBase64OtherOrientation: null, // background picture in base64 for second orientation. If it's not defined, imgBackgroundBase64 is used.
|
||||
// miniature: true, // active or disable the miniature function.
|
||||
// saveInGallery: false, // save or not the picture in gallery.
|
||||
// cameraBackgroundColor: "#e26760", // color of the camera button.
|
||||
// cameraBackgroundColorPressed: "#dc453d", // color of the pressed camera button.
|
||||
// // To get supported color formats, go to see method parseColor : http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)
|
||||
// quality: 100, // picture's quality : range 0 - 100 : http://developer.android.com/reference/android/graphics/Bitmap.html#compress(android.graphics.Bitmap.CompressFormat, int, java.io.OutputStream) (parameter "quality")
|
||||
// opacity: true, // active or disable the opacity function.
|
||||
// defaultFlash: this.FlashModes.DISABLE, // default state for flash. See CustomCamera.FlashModes for corrects values.
|
||||
// switchFlash: true, // active or disable the switch flash button.
|
||||
// defaultCamera: this.CameraFacings.BACK, // default camera used. See CustomCamera.CameraFacings for corrects values.
|
||||
// switchCamera: true // active or disable the switch camera button.
|
||||
|
||||
|
||||
NSString *strData = [command argumentAtIndex:0];
|
||||
if(strData)
|
||||
{
|
||||
bgImageData = [[NSData alloc] initWithBase64Encoding:strData];
|
||||
if (strData) {
|
||||
bgImageData = [[NSData alloc] initWithBase64EncodedString:strData options:0];
|
||||
//bgImageData = [[NSData alloc] initWithBase64Encoding:strData ];
|
||||
}
|
||||
else{
|
||||
else {
|
||||
bgImageData = nil;
|
||||
}
|
||||
|
||||
|
||||
NSString *strData1 = [command argumentAtIndex:1];
|
||||
if(strData1)
|
||||
{
|
||||
bgImageData1 = [[NSData alloc] initWithBase64Encoding:strData1];
|
||||
if (strData1) {
|
||||
bgImageData1 = [[NSData alloc] initWithBase64EncodedString:strData1 options:0];
|
||||
//bgImageData1 = [[NSData alloc] initWithBase64Encoding:strData1];
|
||||
}
|
||||
else{
|
||||
else {
|
||||
bgImageData1 = nil;
|
||||
}
|
||||
|
||||
@ -63,7 +59,7 @@
|
||||
bSaveInGallery = [[command argumentAtIndex:3] boolValue];
|
||||
strCameraBGColor = [command argumentAtIndex:4];
|
||||
strCameraPressedBG = [command argumentAtIndex:5];
|
||||
|
||||
|
||||
fQuality = [[command argumentAtIndex:6] intValue];
|
||||
bOpacity = [[command argumentAtIndex:7] boolValue];
|
||||
nDefaultFlash = [[command argumentAtIndex:8] intValue];
|
||||
|
0
src/ios/classes/CustomCamera.h
Normal file → Executable file
0
src/ios/classes/CustomCamera.h
Normal file → Executable file
164
src/ios/classes/CustomCamera.m
Normal file → Executable file
164
src/ios/classes/CustomCamera.m
Normal file → Executable file
@ -4,13 +4,12 @@
|
||||
|
||||
@implementation CustomCamera
|
||||
|
||||
- (void)startCamera:(CDVInvokedUrlCommand*)command {
|
||||
|
||||
- (void)startCamera:(CDVInvokedUrlCommand *)command {
|
||||
lastCommand = command;
|
||||
|
||||
NSString *guid = [[NSUUID new] UUIDString];
|
||||
NSString *uniqueFileName = [NSString stringWithFormat:@"%@.jpg", guid];
|
||||
|
||||
|
||||
filename = uniqueFileName;
|
||||
nSourceType = 1;
|
||||
nDestType = 0;
|
||||
@ -20,86 +19,93 @@
|
||||
|
||||
|
||||
|
||||
// NSString * strPhotoName = @"sample.png";
|
||||
if(nSourceType == 0)
|
||||
{
|
||||
// NSString * strPhotoName = @"sample.png";
|
||||
if (nSourceType == 0) {
|
||||
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
|
||||
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
|
||||
imagePickerController.delegate = self;
|
||||
[self.viewController presentViewController:imagePickerController animated:YES completion:nil];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (![UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) {
|
||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No rear camera detected"];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
||||
} else if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
|
||||
}
|
||||
else if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
|
||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Camera is not accessible"];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
||||
} else {
|
||||
AVCamViewController *cameraViewController = [[AVCamViewController alloc] initWithParams:param WithCallback:^(UIImage *image) {
|
||||
}
|
||||
else {
|
||||
AVCamViewController *cameraViewController = [[AVCamViewController alloc] initWithParams:param WithCallback: ^(UIImage *image, NSString *errorCode, NSString *message) {
|
||||
@autoreleasepool {
|
||||
if(nDestType == 0)
|
||||
{
|
||||
NSData *imageData = UIImageJPEGRepresentation(image, quality / 100);
|
||||
NSString* strEncodeData = [imageData base64EncodedStringWithOptions:0];
|
||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsString:strEncodeData];
|
||||
if (image) {
|
||||
if (nDestType == 0) {
|
||||
NSData *imageData = UIImageJPEGRepresentation(image, quality / 100);
|
||||
|
||||
NSString *strEncodeData = [imageData base64EncodedStringWithOptions:0];
|
||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsString:strEncodeData];
|
||||
[self.viewController dismissViewControllerAnimated:YES completion:nil];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
||||
}
|
||||
else {
|
||||
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
||||
NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:filename];
|
||||
NSData *imageData = UIImageJPEGRepresentation(image, quality / 100);
|
||||
//[self deleteFileWithName:imagePath];
|
||||
[imageData writeToFile:imagePath atomically:YES];
|
||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsString:[[NSURL fileURLWithPath:imagePath] absoluteString]];
|
||||
[self.viewController dismissViewControllerAnimated:YES completion:nil];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
||||
}
|
||||
}
|
||||
else {
|
||||
//error
|
||||
NSDictionary *error = @{ @"code":errorCode, @"message":message };
|
||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:error];
|
||||
[self.viewController dismissViewControllerAnimated:YES completion:nil];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
||||
} else {
|
||||
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
||||
NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:filename];
|
||||
NSData *imageData = UIImageJPEGRepresentation(image, quality / 100);
|
||||
//[self deleteFileWithName:imagePath];
|
||||
[imageData writeToFile:imagePath atomically:YES];
|
||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsString:[[NSURL fileURLWithPath:imagePath] absoluteString]];
|
||||
[self.viewController dismissViewControllerAnimated:YES completion:nil];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
||||
}
|
||||
}
|
||||
}
|
||||
} ];
|
||||
}];
|
||||
[self.viewController presentViewController:cameraViewController animated:YES completion:nil];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// This method is called when an image has been chosen from the library or taken from the camera.
|
||||
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
|
||||
{
|
||||
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
|
||||
//You can retrieve the actual UIImage
|
||||
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
|
||||
//Or you can get the image url from AssetsLibrary
|
||||
// NSURL *path = [info valueForKey:UIImagePickerControllerReferenceURL];
|
||||
// NSURL *path = [info valueForKey:UIImagePickerControllerReferenceURL];
|
||||
|
||||
[picker dismissViewControllerAnimated:YES completion:^{
|
||||
[picker dismissViewControllerAnimated:YES completion: ^{
|
||||
@autoreleasepool {
|
||||
if(nDestType == 0)
|
||||
{
|
||||
NSData *imageData = UIImageJPEGRepresentation(image, quality / 100);
|
||||
|
||||
NSString* strEncodeData = [imageData base64EncodedStringWithOptions:0];
|
||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsString:strEncodeData];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:lastCommand.callbackId];
|
||||
|
||||
} else {
|
||||
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
||||
NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:filename];
|
||||
NSData *imageData = UIImageJPEGRepresentation(image, quality / 100);
|
||||
//[self deleteFileWithName:imagePath];
|
||||
[imageData writeToFile:imagePath atomically:YES];
|
||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsString:[[NSURL fileURLWithPath:imagePath] absoluteString]];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:lastCommand.callbackId];
|
||||
}
|
||||
if (nDestType == 0) {
|
||||
NSData *imageData = UIImageJPEGRepresentation(image, quality / 100);
|
||||
|
||||
NSString *strEncodeData = [imageData base64EncodedStringWithOptions:0];
|
||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsString:strEncodeData];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:lastCommand.callbackId];
|
||||
}
|
||||
else {
|
||||
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
||||
NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:filename];
|
||||
NSData *imageData = UIImageJPEGRepresentation(image, quality / 100);
|
||||
//[self deleteFileWithName:imagePath];
|
||||
[imageData writeToFile:imagePath atomically:YES];
|
||||
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsString:[[NSURL fileURLWithPath:imagePath] absoluteString]];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:lastCommand.callbackId];
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)deleteFileWithName:(NSString *)fileName
|
||||
{
|
||||
- (void)deleteFileWithName:(NSString *)fileName {
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
// Need to check if the to be deleted file exists.
|
||||
if ([manager fileExistsAtPath:fileName]) {
|
||||
@ -110,31 +116,33 @@
|
||||
if (error) {
|
||||
NSLog(@"There is an Error: %@", error);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
NSLog(@"File %@ doesn't exists", fileName);
|
||||
}
|
||||
}
|
||||
|
||||
- (UIImage*)scaleImage:(UIImage*)image toSize:(CGSize)targetSize {
|
||||
if (targetSize.width <= 0 && targetSize.height <= 0) {
|
||||
return image;
|
||||
}
|
||||
|
||||
CGFloat aspectRatio = image.size.height / image.size.width;
|
||||
CGSize scaledSize;
|
||||
if (targetSize.width > 0 && targetSize.height <= 0) {
|
||||
scaledSize = CGSizeMake(targetSize.width, targetSize.width * aspectRatio);
|
||||
} else if (targetSize.width <= 0 && targetSize.height > 0) {
|
||||
scaledSize = CGSizeMake(targetSize.height / aspectRatio, targetSize.height);
|
||||
} else {
|
||||
scaledSize = CGSizeMake(targetSize.width, targetSize.height);
|
||||
}
|
||||
|
||||
UIGraphicsBeginImageContext(scaledSize);
|
||||
[image drawInRect:CGRectMake(0, 0, scaledSize.width, scaledSize.height)];
|
||||
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
return scaledImage;
|
||||
}
|
||||
//- (UIImage*)scaleImage:(UIImage*)image toSize:(CGSize)targetSize {
|
||||
// if (targetSize.width <= 0 && targetSize.height <= 0) {
|
||||
// return image;
|
||||
// }
|
||||
//
|
||||
// CGFloat aspectRatio = image.size.height / image.size.width;
|
||||
// CGSize scaledSize;
|
||||
// if (targetSize.width > 0 && targetSize.height <= 0) {
|
||||
// scaledSize = CGSizeMake(targetSize.width, targetSize.width * aspectRatio);
|
||||
// } else if (targetSize.width <= 0 && targetSize.height > 0) {
|
||||
// scaledSize = CGSizeMake(targetSize.height / aspectRatio, targetSize.height);
|
||||
// } else {
|
||||
// scaledSize = CGSizeMake(targetSize.width, targetSize.height);
|
||||
// }
|
||||
//
|
||||
// UIGraphicsBeginImageContext(scaledSize);
|
||||
// [image drawInRect:CGRectMake(0, 0, scaledSize.width, scaledSize.height)];
|
||||
// UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
// UIGraphicsEndImageContext();
|
||||
// return scaledImage;
|
||||
//}
|
||||
|
||||
@end
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user