Skip to content

Commit

Permalink
Update to SDWebImage 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtrujy committed Apr 6, 2017
1 parent 046c1b0 commit 678fa36
Show file tree
Hide file tree
Showing 43 changed files with 2,132 additions and 2,363 deletions.
2 changes: 1 addition & 1 deletion DKCarouselView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Pod::Spec.new do |s|
s.source_files = "DKCarouselView/*.{h,m}"
s.frameworks = "Foundation", "UIKit"
s.requires_arc = true
s.dependency "SDWebImage", "~> 3.8.1"
s.dependency "SDWebImage", '~> 4.0'
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3.0' }
end
222 changes: 112 additions & 110 deletions DKCarouselViewDemo/DKCarouselViewDemo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Empty file modified DKCarouselViewDemo/SDWebImage/LICENSE
100755 → 100644
Empty file.
307 changes: 94 additions & 213 deletions DKCarouselViewDemo/SDWebImage/README.md
100755 → 100644

Large diffs are not rendered by default.

124 changes: 0 additions & 124 deletions DKCarouselViewDemo/SDWebImage/SDWebImage/MKAnnotationView+WebCache.h

This file was deleted.

135 changes: 0 additions & 135 deletions DKCarouselViewDemo/SDWebImage/SDWebImage/MKAnnotationView+WebCache.m

This file was deleted.

37 changes: 22 additions & 15 deletions DKCarouselViewDemo/SDWebImage/SDWebImage/NSData+ImageContentType.h
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
//
// Created by Fabrice Aneche on 06/01/14.
// Copyright (c) 2014 Dailymotion. All rights reserved.
//
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
* (c) Fabrice Aneche
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

#import <Foundation/Foundation.h>
#import "SDWebImageCompat.h"

typedef NS_ENUM(NSInteger, SDImageFormat) {
SDImageFormatUndefined = -1,
SDImageFormatJPEG = 0,
SDImageFormatPNG,
SDImageFormatGIF,
SDImageFormatTIFF,
SDImageFormatWebP
};

@interface NSData (ImageContentType)

/**
* Compute the content type for an image data
* Return image format
*
* @param data the input data
* @param data the input image data
*
* @return the content type as string (i.e. image/jpeg, image/gif)
* @return the image format as `SDImageFormat` (enum)
*/
+ (NSString *)sd_contentTypeForImageData:(NSData *)data;

@end


@interface NSData (ImageContentTypeDeprecated)

+ (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`");
+ (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data;

@end
47 changes: 22 additions & 25 deletions DKCarouselViewDemo/SDWebImage/SDWebImage/NSData+ImageContentType.m
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,49 +1,46 @@
//
// Created by Fabrice Aneche on 06/01/14.
// Copyright (c) 2014 Dailymotion. All rights reserved.
//
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
* (c) Fabrice Aneche
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

#import "NSData+ImageContentType.h"


@implementation NSData (ImageContentType)

+ (NSString *)sd_contentTypeForImageData:(NSData *)data {
+ (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data {
if (!data) {
return SDImageFormatUndefined;
}

uint8_t c;
[data getBytes:&c length:1];
switch (c) {
case 0xFF:
return @"image/jpeg";
return SDImageFormatJPEG;
case 0x89:
return @"image/png";
return SDImageFormatPNG;
case 0x47:
return @"image/gif";
return SDImageFormatGIF;
case 0x49:
case 0x4D:
return @"image/tiff";
return SDImageFormatTIFF;
case 0x52:
// R as RIFF for WEBP
if ([data length] < 12) {
return nil;
if (data.length < 12) {
return SDImageFormatUndefined;
}

NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding];
if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) {
return @"image/webp";
return SDImageFormatWebP;
}

return nil;
}
return nil;
}

@end


@implementation NSData (ImageContentTypeDeprecated)

+ (NSString *)contentTypeForImageData:(NSData *)data {
return [self sd_contentTypeForImageData:data];
return SDImageFormatUndefined;
}

@end
Loading

0 comments on commit 678fa36

Please sign in to comment.