Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dazcox5181

Suspended
Original poster
Jun 12, 2005
342
75
Essex, UK
Hi, I could do with some help...

In an app I'm creating I need to be able to add an image onto another image, at a place/size the user specifies.

On my view there is an UIImageView called imageView - this is then setup with buttons to capture a camera image/use one from library, and I even have emailing/twitpic upload for the image working.

What i need to do is allow the user to add something to the image (small logo etc) which is in the app in png format called logo.png before sending it.

I can't find how to do this though!

I could do with the option to drag/drop the logo and also resize would be nice, but not essential for v1...

Could anyone point me in the right direction?

Thanks
 
So what you are saying, in a round about way, is that you want to composite two images together and get the result as an image you can email? If so it's pretty easy:

1) Use UIGraphicsBeginImageContext to create a graphics context to render into
2) Draw the first image
3) Draw the second image
4) Get the resulting composte with UIGraphicsGetImageFromCurrentImageContext.
5) End the context with UIGraphicsEndImageContext

There are a few ways that you could draw the images. If they are already in views the the renderInContext: method of CALayer is pretty handy.

In short all of this is in the documentation.
 
Thanks, where do I handle the drag/drop part?

It may be in the docs but is there a code sample somewhere that would demonstrate?
 
Thanks, where do I handle the drag/drop part?

It may be in the docs but is there a code sample somewhere that would demonstrate?

I've no idea if there is "sample code" for you to copy and paste. Go and read the documentation and work out how you would detect a drag on a view and then use that to reposition it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.