Kumar KL
Kumar KL

Reputation: 15335

Not Rendering properly "UIGraphicsBeginImageContextWithOptions"

I'm just taking a signature and saving with imageMask . Here actually the imageMask rendering properly but the main signature behaves abnormally like 2 lines of it. Here is my code .

UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, 1.0); //retina res
    [self.imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
    [imageView.image drawInRect:CGRectMake(0, 0, 703, 273)];
    [maskImages.image drawAtPoint:CGPointMake(10, 10) blendMode:kCGBlendModeNormal alpha:0.2];
    [lblAckNo drawTextInRect:CGRectMake(320, 230,100,50)];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    [[UIColor redColor] set];
    NSData *imgData =  UIImageJPEGRepresentation(image, 1.0);
     UIGraphicsEndImageContext();
        NSString *jpgPath = @"/Users/kumaralakshmanna/Pictures/Test.jpg";
        [UIImageJPEGRepresentation(image, 1.0) writeToFile:jpgPath atomically:YES];

Here is the screenshots of it.Before Saving && This is what I'm getting -After Saved

Any Solution to overcome from this issue .? Thanks.

Upvotes: 0

Views: 399

Answers (1)

marzapower
marzapower

Reputation: 5611

Make sure that you are drawing using the same CGSize. You are probably using two different size to capture the image and to draw it, so it gets stretched.

Upvotes: 1

Related Questions