yackle / CLImageEditor

MIT License
2.22k stars 574 forks source link

Load image from album #115

Closed Tippit closed 9 years ago

Tippit commented 9 years ago

hi,

I return to my previous question regarding the use of "UIImagePickerController" I use "CLEffectTool" to apply a "GPUImageDissolveBlendFilter" filter on the image in the editor.

This filter requires me to provide an additional image (overlay) I wish to load it from my photo album, so I need to use UIImagePickerController instead of Bundle.

I can not find any place I have to call UIImagePickerController and then recover the selected image for use in my filter.

Here is a sample code in my customEffect.m :

Could you help me with some advice or with some sample code I am beginner and I'm struggling to find the right method, thank you in advance for your attention

yackle commented 9 years ago

I asked this before as well, how do it become if you try changing to setup?

Tippit commented 9 years ago

ok I still try and tell you, thank's

Le 12 août 2015 à 02:28, Sho Yakushiji notifications@github.com a écrit :

I asked this before as well, how do it become if you try changing to setup?

— Reply to this email directly or view it on GitHub.

Tippit commented 9 years ago

UIImagePickerController in setup it's ok, so _blendImage = [info objectForKey:UIImagePickerControllerOriginalImage];

_blendImage declared as @property (nonatomic, strong) UIImage *_blendImage; in CLEffectTool

how to pass blendImage to (UIImage)applyEffect:(UIImage_)image in CLCustomEffectTool

yackle commented 9 years ago

I think it's not my issue. It is totally up to you. But if it were me I'd probably do it as below.

- (id)initWithSuperView:(UIView*)superview imageViewFrame:(CGRect)frame toolInfo:(CLImageToolInfo*)info
{
    self = [super initWithSuperView:superview imageViewFrame:frame toolInfo:info];
    if(self){
        // The rest of your method implementation.

        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        UIViewController *vc = [[[UIApplication sharedApplication] keyWindow] rootViewController];
        while (vc.presentedViewController) { vc = vc.presentedViewController; }
        [vc presentViewController:picker animated:YES completion:nil];
    }
    return self;
}
Tippit commented 9 years ago

i tried then

I had in CLCustomEffect.m

@implementation CLCustomEffect { UIImage *_blendImage; ...
}

pragma mark- ImagePicker delegate

}

... GPUImageDissolveBlendFilter *blendFilter = [[GPUImageDissolveBlendFilter alloc]init];

UIImage *quickFilteredImage = [blendFilter imageByFilteringImage:_blendImage];

}

at runtime I get a crash

Assertion failure in -[GPUImagePicture initWithCGImage:smoothlyScaleOutput:],iOS9/_Demo/CLImageEditorDemo/SDKs/GPUImage/framework/Source/iOS/GPUImagePicture.m:74 2015-08-12 11:06:24.404 MyApp[22255:986445] *\ Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Passed image must not be empty - it should be at least 1px tall and wide'

yackle commented 9 years ago

Did you write properly also other part? Sample is a minimum code, so it doesn't available by copy and paste.

Tippit commented 9 years ago

I checked my code but - (id) initWithSuperView: (UIView ) superview imageViewFrame (CGRect) frame TOOLINFO (CLImageToolInfo ) info

thank you is the right solution

yackle commented 9 years ago

?

Tippit commented 9 years ago

it’s ok for me Yackle still have the same issue I will review my code :)

Merci beaucoup :))

Le 12 août 2015 à 12:05, Sho Yakushiji notifications@github.com a écrit :

?

— Reply to this email directly or view it on GitHub https://github.com/yackle/CLImageEditor/issues/115#issuecomment-130246332.