UIImage+ForceDecode.m 923 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import "UIImage+ForceDecode.h"
  9. #import "SDWebImageCodersManager.h"
  10. @implementation UIImage (ForceDecode)
  11. + (UIImage *)decodedImageWithImage:(UIImage *)image {
  12. if (!image) {
  13. return nil;
  14. }
  15. NSData *tempData;
  16. return [[SDWebImageCodersManager sharedInstance] decompressedImageWithImage:image data:&tempData options:@{SDWebImageCoderScaleDownLargeImagesKey: @(NO)}];
  17. }
  18. + (UIImage *)decodedAndScaledDownImageWithImage:(UIImage *)image {
  19. if (!image) {
  20. return nil;
  21. }
  22. NSData *tempData;
  23. return [[SDWebImageCodersManager sharedInstance] decompressedImageWithImage:image data:&tempData options:@{SDWebImageCoderScaleDownLargeImagesKey: @(YES)}];
  24. }
  25. @end