Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge images as assets #1

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions DoImagePickerController.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Pod::Spec.new do |s|

s.name = "DoImagePickerController"
s.version = "0.0.1"
s.summary = "An image picker controller with single selection and multiple selection. Support to select lots photos with panning gesture."
s.description = <<-DESC
A longer description of DoImagePickerController in Markdown format.

* Think: Why did you write this? What is the focus? What does it do?
* CocoaPods will be using this to generate tags, and improve search results.
* Try to keep it short, snappy and to the point.
* Finally, don't worry about the indent, CocoaPods strips it!
DESC

s.homepage = "https://github.com/donobono/DoImagePickerController"
s.license = "MIT"
s.author = "donobono"
s.source = { :git => "https://github.com/donobono/DoImagePickerController.git", :commit => "7ffcdd17dc866649f0e32e0220b64e314eee5b7e" }
s.source_files = "Classes", "Classes/**/*.{h,m}"
s.exclude_files = "Classes/Exclude"

end
15 changes: 0 additions & 15 deletions ImagePicker/AppDelegate.h

This file was deleted.

46 changes: 0 additions & 46 deletions ImagePicker/AppDelegate.m

This file was deleted.

101 changes: 0 additions & 101 deletions ImagePicker/Base.lproj/Main.storyboard

This file was deleted.

5 changes: 3 additions & 2 deletions ImagePicker/DoImagePicker/AssetHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#define ASSETHELPER [AssetHelper sharedAssetHelper]

#define ASSET_PHOTO_THUMBNAIL 0
#define ASSET_PHOTO_SCREEN_SIZE 1
#define ASSET_PHOTO_FULL_RESOLUTION 2
#define ASSET_PHOTO_ASPECT_THUMBNAIL 1
#define ASSET_PHOTO_SCREEN_SIZE 2
#define ASSET_PHOTO_FULL_RESOLUTION 3

@interface AssetHelper : NSObject

Expand Down
25 changes: 3 additions & 22 deletions ImagePicker/DoImagePicker/AssetHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,31 +226,12 @@ - (UIImage *)getImageFromAsset:(ALAsset *)asset type:(NSInteger)nType

if (nType == ASSET_PHOTO_THUMBNAIL)
iRef = [asset thumbnail];
else if (nType == ASSET_PHOTO_ASPECT_THUMBNAIL)
iRef = [asset aspectRatioThumbnail];
else if (nType == ASSET_PHOTO_SCREEN_SIZE)
iRef = [asset.defaultRepresentation fullScreenImage];
else if (nType == ASSET_PHOTO_FULL_RESOLUTION)
{
NSString *strXMP = asset.defaultRepresentation.metadata[@"AdjustmentXMP"];
NSData *dXMP = [strXMP dataUsingEncoding:NSUTF8StringEncoding];

CIImage *image = [CIImage imageWithCGImage:asset.defaultRepresentation.fullResolutionImage];

NSError *error = nil;
NSArray *filterArray = [CIFilter filterArrayFromSerializedXMP:dXMP
inputImageExtent:image.extent
error:&error];
if (error) {
NSLog(@"Error during CIFilter creation: %@", [error localizedDescription]);
}

for (CIFilter *filter in filterArray) {
[filter setValue:image forKey:kCIInputImageKey];
image = [filter outputImage];
}

UIImage *iImage = [UIImage imageWithCIImage:image scale:1.0 orientation:(UIImageOrientation)asset.defaultRepresentation.orientation];
return iImage;
}
iRef = [asset.defaultRepresentation fullResolutionImage];

return [UIImage imageWithCGImage:iRef];
}
Expand Down
6 changes: 3 additions & 3 deletions ImagePicker/DoImagePicker/DoImagePickerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#define DO_RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define DO_RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

#define DO_MENU_BACK_COLOR DO_RGBA(57, 185, 238, 0.98)
#define DO_SIDE_BUTTON_COLOR DO_RGBA(57, 185, 238, 0.9)
#define DO_MENU_BACK_COLOR [UIColor colorWithHexString:LightColor]
#define DO_SIDE_BUTTON_COLOR [UIColor colorWithHexString:LightColor]

#define DO_ALBUM_NAME_TEXT_COLOR DO_RGB(57, 185, 238)
#define DO_ALBUM_NAME_TEXT_COLOR [UIColor colorWithHexString:LightColor]
#define DO_ALBUM_COUNT_TEXT_COLOR DO_RGB(247, 200, 142)
#define DO_BOTTOM_TEXT_COLOR DO_RGB(255, 255, 255)

Expand Down
24 changes: 17 additions & 7 deletions ImagePicker/DoImagePicker/DoImagePickerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,26 @@ - (IBAction)onSelectPhoto:(id)sender

if (_nResultType == DO_PICKER_RESULT_UIIMAGE)
{
for (int i = 0; i < _dSelected.count; i++)
[aResult addObject:[ASSETHELPER getImageAtIndex:[aKeys[i] integerValue] type:ASSET_PHOTO_SCREEN_SIZE]];
for (int i = 0; i < _dSelected.count; i++) {
UIImage *img = [ASSETHELPER getImageAtIndex:[aKeys[i] integerValue] type:ASSET_PHOTO_SCREEN_SIZE];
if (img) {
[aResult addObject:img];
}
}
}
else
{
for (int i = 0; i < _dSelected.count; i++)
[aResult addObject:[ASSETHELPER getAssetAtIndex:[aKeys[i] integerValue]]];
for (int i = 0; i < _dSelected.count; i++) {
ALAsset *img = [ASSETHELPER getAssetAtIndex:[aKeys[i] integerValue]];
if (img) {
[aResult addObject:img];
}
}
}

[_delegate didSelectPhotosFromDoImagePickerController:self result:aResult];
if (aResult.count) {
[_delegate didSelectPhotosFromDoImagePickerController:self result:aResult];
}
}

- (IBAction)onCancel:(id)sender
Expand Down Expand Up @@ -282,8 +292,8 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
{
DoPhotoCell *cell = (DoPhotoCell *)[_cvPhotoList dequeueReusableCellWithReuseIdentifier:@"DoPhotoCell" forIndexPath:indexPath];

cell.ivPhoto.image = [ASSETHELPER getImageAtIndex:indexPath.row type:ASSET_PHOTO_THUMBNAIL];

cell.ivPhoto.image = [ASSETHELPER getImageAtIndex:indexPath.row type:ASSET_PHOTO_ASPECT_THUMBNAIL];
if (_dSelected[@(indexPath.row)] == nil)
[cell setSelectMode:NO];
else
Expand Down
19 changes: 13 additions & 6 deletions ImagePicker/DoImagePicker/DoImagePickerController.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6205" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3746"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6198"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="DoImagePickerController">
Expand Down Expand Up @@ -94,7 +94,7 @@
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="qxx-TK-ubw">
<rect key="frame" x="260" y="0.0" width="60" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<state key="normal" image="close.png">
<state key="normal" image="close_picker.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
Expand Down Expand Up @@ -139,15 +139,22 @@
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</view>
</objects>
<resources>
<image name="check.png" width="20" height="20"/>
<image name="close.png" width="20" height="20"/>
<image name="close_picker.png" width="20" height="20"/>
<image name="down.png" width="20" height="20"/>
<image name="show.png" width="10" height="8"/>
<image name="up.png" width="20" height="20"/>
</resources>
</document>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4">
<size key="portraitSize" width="320" height="568"/>
<size key="landscapeSize" width="568" height="320"/>
</simulatedScreenMetrics>
</simulatedMetricsContainer>
</document>
Loading