문제

I am Working on Photo Editing App and I have to merge two Images one Over another like this.

enter image description here

I have implemented the following code to do so:
Here imgedit is the background image and
imgEdit is the UIImageView containing imgedit.

        UIImage *tempImg = [UIImage imageNamed:[NSString stringWithFormat:@"borderImg"]];
        CIImage *inputBackgroundImage = [[CIImage alloc] initWithImage:imgedit];
        CIImage *inputImage = [[CIImage alloc]initWithImage:tempImg] ;

        CIFilter *filter = [CIFilter filterWithName:@"CISourceOverCompositing"];
        [filter setDefaults];
        [filter setValue:inputImage forKey:@"inputImage"];
        [filter setValue:inputBackgroundImage forKey:@"inputBackgroundImage"];

        CIImage *outputImage1 = [filter valueForKey:@"outputImage"];
        CIContext *context = [CIContext contextWithOptions:nil];
        imgEdit.image = [UIImage imageWithCGImage:[context createCGImage:outputImage1 fromRect:outputImage1.extent]];

But the outputImage I am getting after implementing above code is:
enter image description here

I have also tried to resize the input white frame image, by using following code:

        tempImg=[tempImg resizedImageToSize:CGSizeMake(imgEdit.image.size.width,imgEdit.image.size.height)];  

By using above code image get resized properly but But that is also not working.

Please help me out from here.
Your valuable help will be highly appreciated.
Thankyou in advance.

도움이 되었습니까?

해결책

A better way to resize is as follows:

inputImage = [inputImage imageByApplyingTransform:CGAffineTransformMakeScale(inputBackgroundImage.extent.size.width/inputImage.extent.size.with, inputBackgroundImage.extent.size.height/inputImage.extent.size.height)];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top