照片增加裁剪
This commit is contained in:
parent
47da7a7c29
commit
6d76d1defe
@ -21,6 +21,10 @@
|
||||
@property(nonatomic, assign) int nDefaultFlash;
|
||||
@property(nonatomic, assign) BOOL bSwitchFlash;
|
||||
|
||||
|
||||
@property(nonatomic, assign) int targetWidth;
|
||||
@property(nonatomic, assign) int targetHeight;
|
||||
|
||||
@property(nonatomic, assign) int nDefaultCamera;
|
||||
@property(nonatomic, assign) BOOL bSwitchCamera;
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
@synthesize strCameraBGColor;
|
||||
@synthesize strCameraPressedBG;
|
||||
@synthesize fQuality;
|
||||
@synthesize targetWidth;
|
||||
@synthesize targetHeight;
|
||||
@synthesize bOpacity;
|
||||
@synthesize nDefaultFlash;
|
||||
@synthesize bSwitchFlash;
|
||||
@ -46,11 +48,17 @@
|
||||
|
||||
|
||||
fQuality = [[command argumentAtIndex:0] intValue];
|
||||
|
||||
targetWidth = [[command argumentAtIndex:3] intValue];
|
||||
targetHeight = [[command argumentAtIndex:4] intValue];
|
||||
|
||||
|
||||
bOpacity = false; //[[command argumentAtIndex:7] boolValue];
|
||||
nDefaultFlash = 2; //[[command argumentAtIndex:8] intValue];
|
||||
bSwitchFlash = true; //[[command argumentAtIndex:9] boolValue];
|
||||
nDefaultCamera = 0; //[[command argumentAtIndex:10] intValue];
|
||||
bSwitchCamera = true; //[[command argumentAtIndex:11] boolValue];
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -515,6 +515,19 @@ static NSString* toBase64(NSData* data) {
|
||||
@autoreleasepool {
|
||||
if (image) {
|
||||
if (nDestType == 0) {
|
||||
CDVPictureOptions* options = [CDVPictureOptions createFromTakePictureArguments:command];
|
||||
UIImage* scaledImage = nil;
|
||||
|
||||
if ((options.targetSize.width > 0) && (options.targetSize.height > 0)) {
|
||||
// if cropToSize, resize image and crop to target size, otherwise resize to fit target without cropping
|
||||
if (options.cropToSize) {
|
||||
scaledImage = [image imageByScalingAndCroppingForSize:options.targetSize];
|
||||
} else {
|
||||
scaledImage = [image imageByScalingNotCroppingForSize:options.targetSize];
|
||||
}
|
||||
}
|
||||
|
||||
image= (scaledImage == nil ? image : scaledImage);
|
||||
NSData *imageData = UIImageJPEGRepresentation(image, quality / 100);
|
||||
|
||||
NSString *strEncodeData = [imageData base64EncodedStringWithOptions:0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user