1

I'm getting trouble with an image from front camera. I resize and edit an image when a user takes a picture using CGBitmapContextCreate method. It works perfectly when I take a picture using rear camera, but front camera said error message like below.
Error: CGBitmapContextCreate: invalid data bytes/row: should be at least 3412 for 8 integer bits/component, 3 components, kCGImageAlphaPremultipliedFirst.
I'm using these codes.

-(UIImage *) imageFlip:(UIImage *)img
{

CGSize size = img.size;
UIGraphicsBeginImageContext(size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(ctx,size.width,size.height);
CGContextScaleCTM(ctx, -1, -1);
CGContextDrawImage(ctx, CGRectMake(0, 0, size.width, size.height),img.CGImage);
img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return img;
}

I tried normalize method from this iPhone: Changing CGImageAlphaInfo of CGImage but it still says same error. Please help me.

Community
  • 1
  • 1
user1471568
  • 309
  • 1
  • 5
  • 13

0 Answers0