Can't apply GPUImageSwirlFilter filter after using UIGraphicsGetImageFromCurrentImageContext

2 replies [Last post]
lamfan
User offline. Last seen 9 years 29 weeks ago. Offline
Joined: 05/07/2012
Posts:

Hi Brad Larson,

I'm using UIGraphicsGetImageFromCurrentImageContext to crop a uiimage,

after cropping the image and apply the GPUImageSwirlFilter,

the filter effect isn't correct....... the image width and height bigger then before

here is the code for cropping uiimage

-(UIImage *)cropImage:(UIImage *)img withRect:(CGRect)rect {
  UIGraphicsBeginImageContextWithOptions(rect.size, NO, [[UIScreen mainScreen] scale]);
  [img drawRect:CGRectMake(0, 0, img.size.width, img.size.height)];
  UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  return newImage;
}

Please help me, many thanks!

Brad Larson
Brad Larson's picture
User offline. Last seen 4 years 51 weeks ago. Offline
Joined: 05/14/2008
Posts:

What part of this is wrong? The UIImage cropping or the filter? If the filter, what's the input size, output size, and code you use to run the filter?

lamfan
User offline. Last seen 9 years 29 weeks ago. Offline
Joined: 05/07/2012
Posts:

the filter part, my origin image size is 640x480, then I use the script to crop it to 100x100.

after I crop the image and apply the GPUImageSwirlFilter, the return image doesn't correct and also the size is getter bigger than 100x100.

the GPUImageSwirlFilter work fine on any origin image.

here is the filter script

GPUImageSwirlFilter *filter = [[GPUImageSwirlFilter alloc] init];
UIImage *output = [filter imageByFilteringImage:UIImage];

Syndicate content