SDWebImageCoder.m 961 B

12345678910111213141516171819202122232425262728293031
  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 "SDWebImageCoder.h"
  9. NSString * const SDWebImageCoderScaleDownLargeImagesKey = @"scaleDownLargeImages";
  10. CGColorSpaceRef SDCGColorSpaceGetDeviceRGB(void) {
  11. static CGColorSpaceRef colorSpace;
  12. static dispatch_once_t onceToken;
  13. dispatch_once(&onceToken, ^{
  14. colorSpace = CGColorSpaceCreateDeviceRGB();
  15. });
  16. return colorSpace;
  17. }
  18. BOOL SDCGImageRefContainsAlpha(CGImageRef imageRef) {
  19. if (!imageRef) {
  20. return NO;
  21. }
  22. CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef);
  23. BOOL hasAlpha = !(alphaInfo == kCGImageAlphaNone ||
  24. alphaInfo == kCGImageAlphaNoneSkipFirst ||
  25. alphaInfo == kCGImageAlphaNoneSkipLast);
  26. return hasAlpha;
  27. }