Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to merge two images?

johnqhjohnqh Posts: 812Registered Users @ @ @
edited October 2009 in iOS SDK Development
There must be some easy way with the blending mode and core graphics, but I haven't been able to get it to work correctly.

How do I merge two images 50-50?
Post edited by johnqh on

Replies

  • DenVogDenVog Posts: 625Registered Users
    edited March 2009
    johnqh wrote: »
    There must be some easy way with the blending mode and core graphics, but I haven't been able to get it to work correctly.

    How do I merge two images 50-50?

    Not sure if I completely understand what you're trying to do, but can't you just set their alpha to .5 and display one on top of the other?
  • johnqhjohnqh Posts: 812Registered Users @ @ @
    edited March 2009
    DenVog wrote: »
    Not sure if I completely understand what you're trying to do, but can't you just set their alpha to .5 and display one on top of the other?

    I have no problem with displaying. However, I want a new UIImage from two.

    I have played with the 0.5 alpha but it didn't come out right. It looks the 2nd image is more obvious.
  • ScubaScuba Posts: 208Registered Users
    edited March 2009
    Well, you definitely don't want the bottom one % 0.5 - just the top one. If you can get it working that way it is much easier. Otherwise you have to draw the images manually to a context.
  • johnqhjohnqh Posts: 812Registered Users @ @ @
    edited March 2009
    Scuba wrote: »
    Well, you definitely don't want the bottom one % 0.5 - just the top one. If you can get it working that way it is much easier. Otherwise you have to draw the images manually to a context.

    I am using context and drawing 1st one with alpha of 1, 2nd image with alpha of 0.5. No use, it doesn't come out correctly. The 1st image looks too light.

    I am sure someone here have done similar things on Mac OSX. Please share. Exactly what kind of blending mode and alpha should I use?
  • GeneralGeneral Posts: 47Registered Users
    edited March 2009
    johnqh wrote: »
    I am using context and drawing 1st one with alpha of 1, 2nd image with alpha of 0.5. No use, it doesn't come out correctly. The 1st image looks too light.

    I am sure someone here have done similar things on Mac OSX. Please share. Exactly what kind of blending mode and alpha should I use?

    have you tried drawing one image over another image with Opaque set to NO?

    We accidentally did this once when we wanted to remove the old image and it drew on top of the old one. Not really sure how it came out because they were similar images and there were only slight differences that showed up where we could tell they were overlapping, but you might want to try that instead of changing the alpha setting.

    Not really sure how to duplicate this since it was a bug and we corrected it, but we basically loaded image views into an array and then we used the array to draw the images on the screen and we accidentally overlapped the images instead of removing the old ones.
  • HardyMaciaHardyMacia Posts: 23Registered Users
    edited September 2009
    UIGraphicsBeginImageContext(firstImage.size);
    [firstImage drawAtPoint:CGPointMake(0,0)];
    [secondImage drawAtPoint:CGPointMake(0,0)];
    	
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
  • vikysaranvikysaran Posts: 132Registered Users @ @
    edited October 2009
    HardyMacia wrote: »
    UIGraphicsBeginImageContext(firstImage.size);
    [firstImage drawAtPoint:CGPointMake(0,0)];
    [secondImage drawAtPoint:CGPointMake(0,0)];
    	
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    this will capture current screen into 'newImage' from co-ordinates (0, 0)
    <font size="2">Thanx & Regards-<br />
    <font color="SeaGreen"><b>Vaibhav Saran | Software Engineer</b></font><br />
    <font color="Navy">Neo Sypher Systems Pvt. Ltd.<br />
    New Delhi | India<br />
    Websites:<br />
    </font></font><font size="2"><font color="
Sign In or Register to comment.