From 7b02207537d35bfa1714bf8beafc921f717d100a Mon Sep 17 00:00:00 2001 From: 单军华 Date: Wed, 11 Jul 2018 10:47:42 +0800 Subject: [PATCH] 首次上传 --- screendisplay/Pods/YYImage/README.md | 384 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 384 insertions(+), 0 deletions(-) diff --git a/screendisplay/Pods/YYImage/README.md b/screendisplay/Pods/YYImage/README.md new file mode 100755 index 0000000..7051d7f --- /dev/null +++ b/screendisplay/Pods/YYImage/README.md @@ -0,0 +1,384 @@ +YYImage +============== +[](https://raw.githubusercontent.com/ibireme/YYImage/master/LICENSE) +[](https://github.com/Carthage/Carthage) +[](http://cocoapods.org/?q= YYImage) +[](http://cocoapods.org/?q= YYImage) +[](https://www.apple.com/nl/ios/) +[](https://travis-ci.org/ibireme/YYImage) + +Image framework for iOS to display/encode/decode animated WebP, APNG, GIF, and more.<br/> +(It's a component of [YYKit](https://github.com/ibireme/YYKit)) + + + +Features +============== +- Display/encode/decode animated image with these types:<br/> WebP, APNG, GIF. +- Display/encode/decode still image with these types:<br/> WebP, PNG, GIF, JPEG, JP2, TIFF, BMP, ICO, ICNS. +- Baseline/progressive/interlaced image decode with these types:<br/> PNG, GIF, JPEG, BMP. +- Display frame based image animation and sprite sheet animation. +- Dynamic memory buffer for lower memory usage. +- Fully compatible with UIImage and UIImageView class. +- Extendable protocol for custom image animation. +- Fully documented. + +Usage +============== + +###Display animated image + + // File: ani@3x.gif + UIImage *image = [YYImage imageNamed:@"ani.gif"]; + UIImageView *imageView = [[YYAnimatedImageView alloc] initWithImage:image]; + [self.view addSubView:imageView]; + + +###Display frame animation + + // Files: frame1.png, frame2.png, frame3.png + NSArray *paths = @[@"/ani/frame1.png", @"/ani/frame2.png", @"/ani/frame3.png"]; + NSArray *times = @[@0.1, @0.2, @0.1]; + UIImage *image = [YYFrameImage alloc] initWithImagePaths:paths frameDurations:times repeats:YES]; + UIImageView *imageView = [YYAnimatedImageView alloc] initWithImage:image]; + [self.view addSubView:imageView]; + +###Display sprite sheet animation + + // 8 * 12 sprites in a single sheet image + UIImage *spriteSheet = [UIImage imageNamed:@"sprite-sheet"]; + NSMutableArray *contentRects = [NSMutableArray new]; + NSMutableArray *durations = [NSMutableArray new]; + for (int j = 0; j < 12; j++) { + for (int i = 0; i < 8; i++) { + CGRect rect; + rect.size = CGSizeMake(img.size.width / 8, img.size.height / 12); + rect.origin.x = img.size.width / 8 * i; + rect.origin.y = img.size.height / 12 * j; + [contentRects addObject:[NSValue valueWithCGRect:rect]]; + [durations addObject:@(1 / 60.0)]; + } + } + YYSpriteSheetImage *sprite; + sprite = [[YYSpriteSheetImage alloc] initWithSpriteSheetImage:img + contentRects:contentRects + frameDurations:durations + loopCount:0]; + YYAnimatedImageView *imageView = [YYAnimatedImageView new]; + imageView.size = CGSizeMake(img.size.width / 8, img.size.height / 12); + imageView.image = sprite; + [self.view addSubView:imageView]; + +###Animation control + + YYAnimatedImageView *imageView = ...; + // pause: + [imageView stopAnimating]; + // play: + [imageView startAnimating]; + // set frame index: + imageView.currentAnimatedImageIndex = 12; + // get current status + image.currentIsPlayingAnimation; + +###Image decoder + + // Decode single frame: + NSData *data = [NSData dataWithContentsOfFile:@"/tmp/image.webp"]; + YYImageDecoder *decoder = [YYImageDecoder decoderWithData:data scale:2.0]; + UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; + + // Progressive: + NSMutableData *data = [NSMutableData new]; + YYImageDecoder *decoder = [[YYImageDecoder alloc] initWithScale:2.0]; + while(newDataArrived) { + [data appendData:newData]; + [decoder updateData:data final:NO]; + if (decoder.frameCount > 0) { + UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; + // progressive display... + } + } + [decoder updateData:data final:YES]; + UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; + // final display... + +###Image encoder + + // Encode still image: + YYImageEncoder *jpegEncoder = [[YYImageEncoder alloc] initWithType:YYImageTypeJPEG]; + jpegEncoder.quality = 0.9; + [jpegEncoder addImage:image duration:0]; + NSData jpegData = [jpegEncoder encode]; + + // Encode animated image: + YYImageEncoder *webpEncoder = [[YYImageEncoder alloc] initWithType:YYImageTypeWebP]; + webpEncoder.loopCount = 5; + [webpEncoder addImage:image0 duration:0.1]; + [webpEncoder addImage:image1 duration:0.15]; + [webpEncoder addImage:image2 duration:0.2]; + NSData webpData = [webpEncoder encode]; + +###Image type detection + + // Get image type from image data + YYImageType type = YYImageDetectType(data); + if (type == YYImageTypePNG) ... + + +Installation +============== + +### CocoaPods + +1. Update cocoapods to the latest version. +2. Add `pod 'YYImage'` to your Podfile. +3. Run `pod install` or `pod update`. +4. Import \<YYImage/YYImage.h\>. +5. Notice: it doesn't include WebP subspec by default, if you want to support WebP format, you may add `pod 'YYImage/WebP'` to your Podfile. + +### Carthage + +1. Add `github "ibireme/YYImage"` to your Cartfile. +2. Run `carthage update --platform ios` and add the framework to your project. +3. Import \<YYImage/YYImage.h\>. +4. Notice: carthage framework doesn't include WebP component, if you want to support WebP format, use CocoaPods or install manually. + +### Manually + +1. Download all the files in the YYImage subdirectory. +2. Add the source files to your Xcode project. +3. Link with required frameworks: + * UIKit + * CoreFoundation + * QuartzCore + * AssetsLibrary + * ImageIO + * Accelerate + * MobileCoreServices + * libz +4. Import `YYImage.h`. +5. Notice: if you want to support WebP format, you may add `Vendor/WebP.framework`(static library) to your Xcode project. + +FAQ +============== +_Q: Why I can't display WebP image?_ + +A: Make sure you added the `WebP.framework` in your project. You may call `YYImageWebPAvailable()` to check whether the WebP subspec is installed correctly. + +_Q: Why I can't play APNG animation?_ + +A: You should disable the `Compress PNG Files` and `Remove Text Metadata From PNG Files` in your project's build settings. Or you can rename your APNG file's extension name with `apng`. + +Documentation +============== +Full API documentation is available on [CocoaDocs](http://cocoadocs.org/docsets/YYImage/).<br/> +You can also install documentation locally using [appledoc](https://github.com/tomaz/appledoc). + + + +Requirements +============== +This library requires `iOS 6.0+` and `Xcode 7.0+`. + + +License +============== +YYImage is provided under the MIT license. See LICENSE file for details. + + +<br/><br/> +--- +������������ +============== +YYImage: ��������������� iOS ���������������<br/> +(������������ [YYKit](https://github.com/ibireme/YYKit) ������������) + + + +������ +============== +- ���������������������������������������/������/������:<br/> + WebP, APNG, GIF��� +- ���������������������������������������/������/������:<br> + WebP, PNG, GIF, JPEG, JP2, TIFF, BMP, ICO, ICNS��� +- ������������������������������������/������������/������������������:<br/> + PNG, GIF, JPEG, BMP��� +- ������������������������������������������������������������������ sprite sheet ��������� +- ��������������������������������������������������������������������������������� +- ������������ UIImage ��� UIImageView������������������ +- ������������������������������������������������������ +- ������������������������������������������������ + + +������ +============== + +###��������������������������� + + // ������: ani@3x.gif + UIImage *image = [YYImage imageNamed:@"ani.gif"]; + UIImageView *imageView = [[YYAnimatedImageView alloc] initWithImage:image]; + [self.view addSubView:imageView]; + + +###��������������� + + // ������: frame1.png, frame2.png, frame3.png + NSArray *paths = @[@"/ani/frame1.png", @"/ani/frame2.png", @"/ani/frame3.png"]; + NSArray *times = @[@0.1, @0.2, @0.1]; + UIImage *image = [YYFrameImage alloc] initWithImagePaths:paths frameDurations:times repeats:YES]; + UIImageView *imageView = [YYAnimatedImageView alloc] initWithImage:image]; + [self.view addSubView:imageView]; + +###������ sprite sheet ������ + + // 8 * 12 sprites in a single sheet image + UIImage *spriteSheet = [UIImage imageNamed:@"sprite-sheet"]; + NSMutableArray *contentRects = [NSMutableArray new]; + NSMutableArray *durations = [NSMutableArray new]; + for (int j = 0; j < 12; j++) { + for (int i = 0; i < 8; i++) { + CGRect rect; + rect.size = CGSizeMake(img.size.width / 8, img.size.height / 12); + rect.origin.x = img.size.width / 8 * i; + rect.origin.y = img.size.height / 12 * j; + [contentRects addObject:[NSValue valueWithCGRect:rect]]; + [durations addObject:@(1 / 60.0)]; + } + } + YYSpriteSheetImage *sprite; + sprite = [[YYSpriteSheetImage alloc] initWithSpriteSheetImage:img + contentRects:contentRects + frameDurations:durations + loopCount:0]; + YYAnimatedImageView *imageView = [YYAnimatedImageView new]; + imageView.size = CGSizeMake(img.size.width / 8, img.size.height / 12); + imageView.image = sprite; + [self.view addSubView:imageView]; + +###������������������ + + YYAnimatedImageView *imageView = ...; + // ������: + [imageView stopAnimating]; + // ������: + [imageView startAnimating]; + // ������������������: + imageView.currentAnimatedImageIndex = 12; + // ������������������: + image.currentIsPlayingAnimation; + //��������������������������� KVO��� + +###������������ + + // ������������������: + NSData *data = [NSData dataWithContentsOfFile:@"/tmp/image.webp"]; + YYImageDecoder *decoder = [YYImageDecoder decoderWithData:data scale:2.0]; + UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; + + // ��������������������� (���������������������������): + NSMutableData *data = [NSMutableData new]; + YYImageDecoder *decoder = [[YYImageDecoder alloc] initWithScale:2.0]; + while(newDataArrived) { + [data appendData:newData]; + [decoder updateData:data final:NO]; + if (decoder.frameCount > 0) { + UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; + // progressive display... + } + } + [decoder updateData:data final:YES]; + UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; + // final display... + +###������������ + + // ��������������� (������������������������������): + YYImageEncoder *jpegEncoder = [[YYImageEncoder alloc] initWithType:YYImageTypeJPEG]; + jpegEncoder.quality = 0.9; + [jpegEncoder addImage:image duration:0]; + NSData jpegData = [jpegEncoder encode]; + + // ��������������� (������ GIF/APNG/WebP): + YYImageEncoder *webpEncoder = [[YYImageEncoder alloc] initWithType:YYImageTypeWebP]; + webpEncoder.loopCount = 5; + [webpEncoder addImage:image0 duration:0.1]; + [webpEncoder addImage:image1 duration:0.15]; + [webpEncoder addImage:image2 duration:0.2]; + NSData webpData = [webpEncoder encode]; + +###������������������ + + // ������������������ + YYImageType type = YYImageDetectType(data); + if (type == YYImageTypePNG) ... + + +������ +============== + +### CocoaPods + +1. ��� cocoapods ���������������������. +2. ��� Podfile ��������� `pod 'YYImage'`��� +3. ������ `pod install` ��� `pod update`��� +4. ������ \<YYImage/YYImage.h\>��� +5. ���������pod ��������������������� WebP ������, ��������������������� WebP������������ Podfile ��������� `pod 'YYImage/WebP'`��� + +### Carthage + +1. ��� Cartfile ��������� `github "ibireme/YYImage"`��� +2. ������ `carthage update --platform ios` ��������������� framework ������������������������ +3. ������ \<YYImage/YYImage.h\>��� +4. ���������carthage framework ��������������� WebP ������������������������������ WebP������������ CocoaPods ������������������������������ + +### ������������ + +1. ������ YYImage ������������������������������ +2. ��� YYImage ���������������������(������)������������������ +3. ������������ frameworks: + * UIKit + * CoreFoundation + * QuartzCore + * AssetsLibrary + * ImageIO + * Accelerate + * MobileCoreServices + * libz +4. ������ `YYImage.h`��� +5. ������������������������������ WebP������������ `Vendor/WebP.framework`(���������) ��������������������� + +������������ +============== +_Q: ������������������������ WebP ���������_ + +A: ������ `WebP.framework` ������������������������������������������������������ `YYImageWebPAvailable()` ��������������� WebP ������������������������������ + +_Q: ������������������������ APNG ���������_ + +A: ��������������� Build Settings ������ `Compress PNG Files` ��� `Remove Text Metadata From PNG Files`. ��������������������� APNG ������������������������`apng`. + +������ +============== +������������ [CocoaDocs](http://cocoadocs.org/docsets/YYImage/) ������������ API ��������������������� [appledoc](https://github.com/tomaz/appledoc) ��������������������� + + +������������ +============== +��������������������� `iOS 6.0` ��� `Xcode 7.0`��� + + +��������� +============== +YYImage ������ MIT ��������������������� LICENSE ��������� + + +������������ +============== +[���������������������������](http://blog.ibireme.com/2015/11/02/mobile_image_benchmark/)<br/> + +[iOS ������������������������ Tip](http://blog.ibireme.com/2015/11/02/ios_image_tips/) + -- Gitblit v1.8.0