Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-21-2011, 06:18 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 16
Sketchiie is on a distinguished road
Default iPhone merge and save overlay

I've got a code for merging two UIImageViews. The first UIImageView (theimageView) is the background, and the second UIImageView (Birdie) is an image overlaying the first UIImageView. You can load the first UIImageView from a map or take a picture. After this you can drag, rotate and scale the second UIImageView over the first one. I want the output (saved image) to look the same as what I see on the screen. I got that working, but I get borders and the quality is bad and the size too. I want the size to be the image which's chosen, and the quality to be good. Also I get a crash if I save it the second time, fast after the first time.
Code:
    - (UIImage *)combineImages{
    	
        // Draw image1
        [theimageView.image drawInRect:CGRectMake(0,0, theimageView.image.size.width,theimageView.image.size.height)];
    	
        // Draw image2
        [Birdie.image drawInRect:CGRectMake(Birdie.frame.origin.x, Birdie.frame.origin.y, Birdie.frame.size.width, Birdie.frame.size.height)];
        //have you added Birdie over theimageView if not than do this. If your size is already set as you want then there is no need for above two lines of drawInRect.
        UIGraphicsBeginImageContext(theimageView.bounds.size);
        [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    	
        UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
    	
        UIGraphicsEndImageContext();
    	
        return resultingImage;
    }
Thanks in advanced!
Sketchiie is offline   Reply With Quote
Old 04-21-2011, 08:02 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Code:
- (UIImage*) addImageToImage:(UIImage*)img:(UIImage*)img2{
   CGSize size = CGSizeMake(img.size.height, img.size.width);
   UIGraphicsBeginImageContext(size);

   CGPoint pointImg1 = CGPointMake(0,0);
   [img drawAtPoint:pointImg1 ];

   CGPoint pointImage2 = CGPointMake(0, 0);
   [img2 drawAtPoint:pointImage2 ];

   UIImage* result = UIGraphicsGetImageFromCurrentImageContext();
   UIGraphicsEndImageContext();

   return result;
}

UIImage *complete = [self addImageToImage:myImage1:myImage2];
__________________
dany_dev is offline   Reply With Quote
Old 04-21-2011, 12:18 PM   #3 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 16
Sketchiie is on a distinguished road
Default

Thanks for the answer, but I can't seem to get it to work.

I've also changed my saving code from:

Code:
//save actual design in photo library
- (void)captureScreen {
    UIImage *myImage = [self addImage:theImageView ToImage:Birdie];
    [myImage retain];
    UIImageWriteToSavedPhotosAlbum(myImage, self, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), self); 
}
I've changed the rest of the code to:
Code:
- (UIImage*) addImage:(UIImage*)theimageView toImage:(UIImage*)Birdie{
   CGSize size = CGSizeMake(theimageView.size.height, theimageView.size.width);
   UIGraphicsBeginImageContext(size);

   CGPoint pointImg1 = CGPointMake(0,0);
   [theimageView drawAtPoint:pointImg1 ];

   CGPoint pointImage2 = CGPointMake(0, 0);
   [Birdie drawAtPoint:pointImage2 ];

   UIImage* result = UIGraphicsGetImageFromCurrentImageContext();
   UIGraphicsEndImageContext();

   return result;
}
I've changed the first line (addImagetoImage) to addImage:.. toImage...

Thanks in advanced!
Sketchiie is offline   Reply With Quote
Old 04-23-2011, 11:32 AM   #4 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 16
Sketchiie is on a distinguished road
Default

Can someone help me with this code?
Sketchiie is offline   Reply With Quote
Old 04-27-2011, 05:52 PM   #5 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 16
Sketchiie is on a distinguished road
Default

Please, I really need some help.
Sketchiie is offline   Reply With Quote
Old 04-28-2011, 11:57 AM   #6 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

for me work, what I obtain is the background image img as background and img2 over that.
__________________
dany_dev is offline   Reply With Quote
Old 02-10-2012, 12:26 AM   #7 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 1
vidyasagar is on a distinguished road
Question merging of two images into one image and saveing it

Quote:
Originally Posted by Sketchiie View Post
Please, I really need some help.
Hi sir here also same problem.i have selected the one image from albums or take picture from cam and editing the selected image with another image with touches/zooming/scaling and save the same as editing image....how can solve.please sir help me

-(IBaction)done
{
UIGraphicsBeginImageContext(imageView.image.size);

CGRect rect1 = CGRectMake(0,0
maskimage.image.size.width , maskimage.image.size.height);
NSLog(@"net translation are %f,%f",netTranslation.x/translation.x,netTranslation.y/translation.y);

CGRect rect = CGRectMake(0,0, imageView.image.size.width, imageView.image.size.height);

[imageView.image drawInRect:rect];
[maskimage.image drawInRect:rect1];

UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[editingimage setImage:resultingImage];
[editingimage setTransform:CGAffineTransformMakeScale(1, 1)];
[myview addSubview:editingimage];
[self.view addSubview:myview];
}

Thanking you sir
vidyasagar is offline   Reply With Quote
Old 03-26-2012, 06:00 AM   #8 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 9
Aalok is on a distinguished road
Default

sorry
Aalok is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, merge, save, uiimageview, xcode

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 350
13 members and 337 guests
dansparrow, dre, iOS.Lover, LezB44, lorrettaui53, Nobbsy, Objective Zero, oztemel, pbart, samdanielblr, sledzeppelin, thephotographer, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:50 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0