-->

Picture frames - iPhone

2020-07-29 05:16发布

问题:

I'd like to be able to take a picture (camera or library) and overlay something like a picture frame on it, then save it back to the camera roll. Should I be looking into OpenGL?or, what?

Thanks for the pointers.

回答1:

You don't need anything except Quartz for that. Look into CGBitmapContext, CGContext, CGImage, UIImage. There's also a function to store images in the album: UIImageWriteToSavedPhotosAlbum

The way to go is:

  1. Get a UIImage from UIImagePickerController.
  2. Build a context using CGBitmapContextCreate
  3. Draw the image in this context: CGContextDrawImage
  4. Draw whatever you want on top of that
  5. Use CGBitmapContextCreateImage to create a CGImage from the context
  6. Use [UIImage imageWithCGImage:] to get a UIImage from the CGImage
  7. Use UIImageWriteToSavedPhotosAlbum to save the augmented image.