PhotoEditRenderer
@available(iOS 9.0, *)
@objcMembers
@objc(PESDKPhotoEditRenderer)
open class PhotoEditRenderer : NSObject
A PhotoEditRenderer
takes a CIImage
and a PhotoEditModel
as input and takes care of
applying all necessary effects and filters to the image. The output image can then be rendered
into an EAGLContext
or converted into a CGImage
instance.
-
The input image.
Declaration
Swift
open var originalImage: CIImage? { get set }
-
The photo edit model that describes all effects that should be applied to the input image.
Declaration
Swift
open var photoEditModel: PhotoEditModel
-
The render mode describes which effects should be applied to the input image.
Declaration
Swift
open var renderMode: PESDKRenderMode { get set }
-
The asset manager that is associated with this renderer. It is used to fetch the resources for sprites like stickers, brush and frames.
Declaration
Swift
open var assetManager: AssetManager?
-
A
CIImage
instance with all effects and filters applied to it.Declaration
Swift
open var outputImage: CIImage { get }
-
The size of the output image.
Declaration
Swift
open var outputImageSize: CGSize { get }
-
Invalidates the cache. You can call this prior to rendering to force a complete rerender.
Declaration
Swift
open func invalidateCache()
-
Applies all necessary filters and effects to the input image and converts it to an instance of
CGImage
.Declaration
Swift
open func newOutputImage() -> CGImage
Return Value
A newly created instance of
CGImage
. -
Same as
newOutputImage()
but asynchronously.Declaration
Swift
@objc(createOutputImageWithCompletion:) open func createOutputImage(with completion: @escaping (_ outputImage: CGImage) -> Void)
Parameters
completion
A completion handler that receives the newly created instance of
CGImage
once rendering is complete. -
Applies all necessary filters and effects to the input image and converts it to a
Data
object containing the specified image file format and the given compressoin quality (if applicable).Declaration
Swift
@objc(generateOutputImageDataWithFormat:compressionQuality:metadataSourcePhoto:completionHandler:) open func generateOutputImageData(withFormat imageFormat: ImageFileFormat, compressionQuality: CGFloat, metadataSourcePhoto: Photo?, completionHandler: @escaping (_ outputImageData: Data?, _ imageWidth: CGFloat, _ imageHeight: CGFloat) -> Void)
Parameters
imageFormat
The image file format to generate.
compressionQuality
The compression quality to apply. This will only be used for lossy image formats.
metadataSourcePhoto
The photo of which the metadata should be copied to the new image. If
nil
it uses the metadata of the original image, if available.completionHandler
A completion handler that receives the newly created instance of
Data
once rendering is complete.
-
Draws the output image into the given
EAGLContext
.Declaration
Swift
@objc(drawOutputImageInContext:toRect:viewportWidth:viewportHeight:) open func drawOutputImage(in context: EAGLContext, to rect: CGRect, viewportWidth: Int, viewportHeight: Int)
Parameters
context
An instance of
EAGLContext
to draw into.rect
The
CGRect
in which the output image should be drawn.viewportWidth
The width of the view that displays the framebuffer’s content.
viewportHeight
The height of the view that displays the framebuffer’s content.
-
Draws the output image into the given
CAMetalDrawable
.Declaration
Swift
open func drawOutputImage(for device: MTLDevice, in drawable: CAMetalDrawable, to rect: CGRect, commandQueue: MTLCommandQueue)
Parameters
device
The
MTLDevice
to use.drawable
The drawable to draw into.
rect
The rectangle to draw into.
commandQueue
The
MTLCommandQueue
to use.