In combine images, something is going wrong

Discussion in 'iOS Programming' started by vavdiyaharesh, Nov 28, 2008.

  1. macrumors newbie

    May 15, 2008

    I have one image of size(320x200) an d one another image size of (100x50).

    now i want to put means overwrite this smaller image on big image with size(100x80)... i have code for that like... a

    CGImageRef imageRef = [[UIImage imageNamed:mad:"UserImage9.png"] CGImage];
    CGImageRef maskRef = [[UIImage imageNamed:mad:"Monster.png"] CGImage];
    CGImageRef mySubimage = CGImageCreateWithImageInRect (maskRef, CGRectMake(10,10,200,100));
    CGImageRef combinedImage=CGImageCreateWithMask(mySubimage, imageRef);

    NSString *compname = @"compImage.png";

    UIImage *tempComp = [UIImage imageWithCGImage:combinedImage];

    NSData *imageData = UIImagePNGRepresentation(tempComp);

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

    NSString *appFile = [documentsDirectory stringByAppendingPathComponent:compname];

    [imageData writeToFile:appFile atomically:YES];


    It is not giving me any error but also not creating combine image so anyone can tell me where i m wrong.


Share This Page