RCTImageDataDecoder.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <UIKit/UIKit.h>
  8. #import <React/RCTBridge.h>
  9. #import <React/RCTResizeMode.h>
  10. #import <React/RCTURLRequestHandler.h>
  11. #import <React/RCTImageURLLoader.h>
  12. /**
  13. * Provides the interface needed to register an image decoder. Image decoders
  14. * are also bridge modules, so should be registered using RCT_EXPORT_MODULE().
  15. */
  16. @protocol RCTImageDataDecoder <RCTBridgeModule>
  17. /**
  18. * Indicates whether this handler is capable of decoding the specified data.
  19. * Typically the handler would examine some sort of header data to determine
  20. * this.
  21. */
  22. - (BOOL)canDecodeImageData:(NSData *)imageData;
  23. /**
  24. * Decode an image from the data object. The method should call the
  25. * completionHandler when the decoding operation has finished. The method
  26. * should also return a cancellation block, if applicable.
  27. *
  28. * If you provide a custom image decoder, you most implement scheduling yourself,
  29. * to avoid decoding large amounts of images at the same time.
  30. */
  31. - (RCTImageLoaderCancellationBlock)decodeImageData:(NSData *)imageData
  32. size:(CGSize)size
  33. scale:(CGFloat)scale
  34. resizeMode:(RCTResizeMode)resizeMode
  35. completionHandler:(RCTImageLoaderCompletionBlock)completionHandler;
  36. @optional
  37. /**
  38. * If more than one RCTImageDataDecoder responds YES to `-canDecodeImageData:`
  39. * then `decoderPriority` is used to determine which one to use. The decoder
  40. * with the highest priority will be selected. Default priority is zero.
  41. * If two or more valid decoders have the same priority, the selection order is
  42. * undefined.
  43. */
  44. - (float)decoderPriority;
  45. @end