AdobeImageEditorContext Class Reference
Inherits from | NSObject |
Declared in | AdobeImageEditorContext.h |
Overview
Photo Editor Contexts are generated by calling the createContextWithImage: or createContextWithImage:maxSize: methods of AFAdobeImageEditorSession. A context encapsulates an input image and an output size. If not specified, the output size defaults to the image size. In the standard Aviary version of this SDK, there was a 3 megapixel size limit on high resolution output. This is no longer the case in the Creative SDK, so all high resolution output will default to the full image size.
Calling render: on a context causes all modifications tracked in the
AdobeImageEditorSession (which tracks user generated photo-editing actions
in an AdobeUXImageEditorViewController) to be replayed on the context’s
input image asynchronously. When rendering is complete, the completion
block passed into render: will be called with the finalized image, whose
size will match the context’s size. If the session contains no tracked
actions (i.e., the user made no edits before pressing “Done” or pressed
“Cancel”), the result image will be nil
. Note: render: may only be
called once per context.
Some things to note about using contexts:
We recommend choosing a maximum output resolution that suits the purposes of your application to provide the best experience for your users.
Processing large images can consume a lot of memory and time. It may be necessary to free up resources and/or display an activity indicator while a context is executing.
To calculate the approximate maximum amount of memory a context could use, multiply the dimensions of the output size and multiply the result by 4. For example, a context with a maximum output size of 1500x1500 will consume approximately 9mb of memory for the processing duration.
Tasks
Compatibility Methods
-
session
property -
size
property -
canceled
property -
modified
property -
progressHandler
property -
hasBegunRendering
property -
– render:
-
– cancelRendering
Properties
canceled
Specifies if the context’s rendering has been cancelled.
@property (nonatomic, assign, readonly, getter=isCanceled) BOOL canceled
Discussion
Specifies if the context’s rendering has been cancelled.
Declared In
AdobeImageEditorContext.h
hasBegunRendering
Specifies whether rendering has begun on the context.
@property (nonatomic, assign, readonly) BOOL hasBegunRendering
Discussion
Specifies whether rendering has begun on the context.
If YES, any render: call will have no effect.
Declared In
AdobeImageEditorContext.h
modified
Specifies if the context’s session has been modified.
@property (nonatomic, assign, readonly, getter=isModified) BOOL modified
Discussion
Specifies if the context’s session has been modified.
Declared In
AdobeImageEditorContext.h
progressHandler
The progress handler is called with an estimate of how far along in completing the render the context is. The handler is guaranteed to be called on the main thread.
@property (nonatomic, copy, nullable) void ( ^ ) ( CGFloat ) progressHandler
Parameters
- progressHandler
The block to be called with progress updates.
Discussion
The progress handler is called with an estimate of how far along in completing the render the context is. The handler is guaranteed to be called on the main thread.
Declared In
AdobeImageEditorContext.h
Instance Methods
cancelRendering
Cancels the context’s rendering.
- (void)cancelRendering
Discussion
Cancels the context’s rendering.
Warning: Calling this method from any thread other in the main thread may result in undefined behavior.
Declared In
AdobeImageEditorContext.h
render:
Replays all actions tracked by the generating AdobeImageEditorSession on the context’s image.
- (void)render:(void ( ^ ) ( UIImage *__nullable result ))completion
Parameters
- completion
The block to be called when the image’s render is complete.
Discussion
Replays all actions tracked by the generating AdobeImageEditorSession on the context’s image.
The completion block will not be called until after the session
is
closed, i.e. until the user has closed the
AdobeUXImageEditorViewController that generated the session
. If the
user pressed “Cancel” or took no actions before pressing “Done”, the
result
UImage in the completion block will be nil. Otherwise, it will
contain the rendered image. The context will try to render the image
on the GPU, but it will fall back to the CPU if necessary. See the
discussion in AdobeImageEditorContext for more details.
Note: This method may be called once per context, as it would not make sense to run the same actions on the same image twice. Check hasBegunRendering to see if render has been called.
Warning: Calling this method from any thread other in the main thread may result in undefined behavior.
Declared In
AdobeImageEditorContext.h