GithubHelp home page GithubHelp logo

cs0811 / flyimage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from northwind/flyimage

0.0 2.0 0.0 470 KB

Download, cache, render small images with UIImageView category

Home Page: https://github.com/northwind/FlyImage

License: MIT License

Ruby 1.03% Objective-C 98.97%

flyimage's Introduction

FlyImage Logo FlyImage

Build Status Pod Version Pod Platform Pod License Carthage compatible

FlyImage takes the advantages of SDWebImage, FastImageCache and AFNetworking, is a simple and high performance image library.

Features:

  • High Performance, reduce memory operations while rendering, avoid Memory warning caused by image
  • Store and retrieve different size of small images in one memory file, smooth scrolling
  • Simple, support UIImageView, CALayer category
  • An asynchronous image downloader
  • Support WebP format
  • Support mmap to improve I/O performace

Installation with CocoaPods

Set the Podfile like this:

platform :ios, '8.0'
pod 'FlyImage', '~>1.0'

If you are using Swift, be sure to add use_frameworks!:

platform :ios, '8.0'
use_frameworks!
pod 'FlyImage', '~>1.0'

If you want to support WebP, just change the Podfile:

platform :ios, '8.0'
pod 'FlyImage/WebP', '~>1.0'

How To Use

Using UIImageView and CALayer Category

#import "FlyImage.h"
...

UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
[imageView setPlaceHolderImageName:@"default"
						thumbnailURL:[NSURL urlWithString:@"http://thumbnail"]
						originalURL:[NSURL urlWithString:@"http://original"]];
[]self.view addSubview:imageView];
...

UIImageView *iconView = [[UIImageView alloc] initWithFrame:frame];
[iconView setIconURL:[NSURL urlWithString:@"http://original"]];
[]self.view addSubview:iconView];
...

Using FlyImageCache

// retrieve a specific key, and get callback
[[FlyImageCache sharedInstance] asyncGetImageWithKey:key
	  									   completed:^(NSString *key, UIImage *image) {
		imageView.image = image;
}];

// remove a image from the cache	
[[FlyImageCache sharedInstance] removeImageWithKey:key];

// delete all images
[[FlyImageCache sharedInstance] purge];

Using FlyImageIconCache

// add a new icon with a specific key
[[FlyImageIconCache sharedInstance] addImageWithKey:key
        size:drawSize
        drawingBlock:^(CGContextRef context, CGRect contextBounds) {
        	UIImage *image = [UIImage imageWithName:@"imageName"];

    		UIGraphicsPushContext(context);
		    [image drawInRect:contextBounds];
		    UIGraphicsPopContext();
        }
        completed:nil];

// retrieve a specific key, and get callback
[[FlyImageCache sharedInstance] asyncGetImageWithKey:key
	  									   completed:^(NSString *key, UIImage *image) {
		imageView.image = image;
}];

More demos in folder Examples

Performance Mesure

Memory when scrolling images

Demo Target: FlyImageView / Device: iPhone6 Plus

Memory FlyImage SDWebImage UIKit
All Heap Allocations 2~7M 2~4M 2~5M
All Anonymous VM 17~30M 310M 17~30M

FPS when more than 170 small images in the same screen

Demo Target: FlyImageIconView / Device: iPhone6 Plus

FlyImage SDWebImage UIKit
58~60FPS 6~7FPS 6~7FPS

FPS

Architecture

FlyImage Struct

License

FlyImage is made available under the MIT license

flyimage's People

Contributors

northwind avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.