Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to merge 2 images without using set alpha?

I am a Fresher Developer in iPhone .

I want Merge Two Images and Get Only One Image In UIImageView without set alpha.

This is my code. This code is working using alpha, but I want set without set alpha.

MYCODE:-

-(UIImage *)maskingImage:(UIImage *)image
{

    CGSize sizeR = CGSizeMake(200, 220);
   // UIImage *textureImage = [UIImage imageNamed:@"tt.png"];
    UIImage *textureImage =imgView2.image;



    UIGraphicsBeginImageContextWithOptions(sizeR, YES, textureImage.scale);
    [textureImage drawInRect:CGRectMake(0.0, 0.0, 200, 220)];

    UIImage *bottomImage = UIGraphicsGetImageFromCurrentImageContext();

    UIImage *upperImage = image;


    CGSize newSize = sizeR ;
    UIGraphicsBeginImageContext(newSize);
    [bottomImage drawInRect:CGRectMake(0.0, 0.0, 200, 220)];
    [upperImage drawInRect:CGRectMake(0.0, 0.0, 200, 220) blendMode:kCGBlendModeNormal alpha:0.5];



    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage; 
}

Thanks in advance.

like image 472
The Rock Avatar asked Oct 08 '12 09:10

The Rock


People also ask

How do I manually merge photos in Photoshop?

The first step is to open the two images that you want to merge in Photoshop. Once both images are open, select the Merge tool from the Tools palette. You can also access the Merge tool by pressing the “M” key on your keyboard. With the Merge tool selected, click and drag over the area that you want to merge.


1 Answers

UIGraphicsBeginImageContext(YOUR SIZE);

//FIRST IMAGE
[FIRST_IMAGE drawInRect:CGRectMake(0, 0, YOUR_SIZE_WIDTH/2, YOUR_SIZE_HEIGHT)];
//SECOND IMAGE
[SECOND_IMAGE drawInRect:CGRectMake(YOUR_SIZE_WIDTH/2, 0, YOUR_SIZE_WIDTH/2, YOUR_SIZE_HEIGHT)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();
like image 178
SachinVsSachin Avatar answered Sep 30 '22 14:09

SachinVsSachin