FBScreenshot.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. #import <XCTest/XCTest.h>
  10. @class UTType;
  11. NS_ASSUME_NONNULL_BEGIN
  12. @interface FBScreenshot : NSObject
  13. /**
  14. Retrieves non-scaled screenshot of the whole screen
  15. @param quality The number in range 0-3, where 0 is PNG (lossless), 3 is HEIC (lossless), 1- low quality JPEG and 2 - high quality JPEG
  16. @param error If there is an error, upon return contains an NSError object that describes the problem.
  17. @return Device screenshot as PNG-encoded data or nil in case of failure
  18. */
  19. + (nullable NSData *)takeInOriginalResolutionWithQuality:(NSUInteger)quality
  20. error:(NSError **)error;
  21. /**
  22. Retrieves non-scaled screenshot of the particular screen rectangle
  23. @param quality The number in range 0-3, where 0 is PNG (lossless), 3 is HEIC (lossless), 1- low quality JPEG and 2 - high quality JPEG
  24. @param rect The bounding rectange for the screenshot. The value is expected be non-scaled one.
  25. CGRectNull could be used to take a screenshot of the full screen.
  26. @param error If there is an error, upon return contains an NSError object that describes the problem.
  27. @return Device screenshot as PNG-encoded data or nil in case of failure
  28. */
  29. + (nullable NSData *)takeInOriginalResolutionWithQuality:(NSUInteger)quality
  30. rect:(CGRect)rect
  31. error:(NSError **)error;
  32. /**
  33. Retrieves non-scaled screenshot of the whole screen
  34. @param screenID The screen identifier to take the screenshot from
  35. @param compressionQuality Normalized screenshot quality value in range 0..1, where 1 is the best quality
  36. @param uti UTType... constant, which defines the type of the returned screenshot image
  37. @param timeout how much time to allow for the screenshot to be taken
  38. @param error If there is an error, upon return contains an NSError object that describes the problem.
  39. @return Device screenshot as PNG-, HEIC- or JPG-encoded data or nil in case of failure
  40. */
  41. + (nullable NSData *)takeInOriginalResolutionWithScreenID:(long long)screenID
  42. compressionQuality:(CGFloat)compressionQuality
  43. uti:(UTType *)uti
  44. timeout:(NSTimeInterval)timeout
  45. error:(NSError **)error;
  46. @end
  47. NS_ASSUME_NONNULL_END