Giter Club home page Giter Club logo

concorde's Introduction

Concorde

Version License Platform Build Status Coverage Status

This is a framework for downloading and decoding progressive JPEGs easily on iOS and OS X. It uses libjpeg-turbo as underlying JPEG implementation. We vendor version 1.4.0 of the static library from libjpeg-turbo's official release for convenience.

Usage

Simply install it via CocoaPods:

pod 'Concorde'

and then use CCBufferedImageView which progressively downloads and shows an image:

let imageView = CCBufferedImageView(frame: ...)
if let url = NSURL(string: "http://example.com/yolo.jpg") {
	imageView.load(url)
}

If you use Contentful, install the subspec:

pod 'Concorde/Contentful'

and replace your usage of UIImageView with CCBufferedImageView to automatically use progressive JPEGs if you have been using the UIImageView category before. This will work regardless of the original format of your files due to the image transformation functionality of the delivery API.

Manual integration

You can also integrate Concorde as a subproject or download a binary build from the releases section. Please note that those are only provided for iOS at the moment.

License

Copyright (c) 2015 Contentful GmbH. See LICENSE for further details.

CCBufferedImageDecoder is derived from WebKit, see comments in its file for further copyright details.

The examples use http://pooyak.com/p/progjpeg/, which artificially slows the connection down to 0.5 Kilobyte/second to demonstrate the differences between regular and progressive JPEGs.

concorde's People

Contributors

hfossli avatar loudmouth avatar neonichu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

concorde's Issues

Freezes main thread

I have a tinder-like stack of images. Touch events are not delivered while big images gets loaded/decode.
Thats because you decode image with dispatch_sync and it stops main_thread.

Doesn't Progressively Download and Decode JPEGs on iOS.

The title of this github repository is "Download and decode progressive JPEGs on iOS." But it doesn't do the very thing that Progressive JPEG was invented to do:

Progressively download and decode JPEGs on iOS

It misuses NSURLSession to grab ALL the data (a process that takes 99% of the total time) then decodes it.

Please rewrite to use NSURLSession in stream mode, so that is passed to your CGDataProvider in bursts, decoding what you can and writing it to the screen as the data comes in.

In CCBufferedImageDecoder , you create your CGDataProvider with an NSData, but by the time you have the NSData, 99% of the time of fetching and displaying the image has already elapsed, making progressive jpeg decoding pointless.

Add support for caching

Calling the .load method seems to add some significant latency for images that should be cached.

Grey Placeholders forever?

Hello!

I have been trying to use Concorde in a iOS project with the following code:

if let url = NSURL(string: produto.imagem!.url!){
        let imagem = CCBufferedImageView(frame: cell.imageView!.frame)
        imagem.load(url)
        cell.addSubview(imagem)
}

produto.imagem is a Contentful Asset and url value currently is:
url NSURL "https://images.contentful.com/765kywdqo8as/1u0UQOzrSEyAIYoY8CgaiU/743112ca52714a9739b7550fb83a43e2/3479738_wallsPetroleum_01.png" 0x00007feba3861590

When I execute my code I only get grey placeholders and never an image.

On the other hand I have tried using ContentfulPersistence with the following code:

let imagem = CCBufferedImageView(frame: cell.imageView!.frame)
imagem.cda_setImageWithPersistedAsset(produto.imagem!, client: source!.client, size: imagem.frame.size, placeholderImage: nil)
cell.addSubview(imagem)

Then I get the following error:
fatal error: should never be called: file /Users/rafael/Trabalho/Bier Leverpilsen/Pods/Concorde/Code/CCBufferedImageView+Contentful.swift, line 18

Any help would be appreciated! I have been struggling for a while!

Efficiency?

Currently, a new instance of CCBufferedImageDecoder is created for each new chunk of data received. Works, but we could be more efficient, especially considering that it'll allocate a new output buffer each time.

Add support for bitcode

When I try to include this in an iOS 9 project, I get errors about bitcode support not being available on a certain ARM architecture. As a result, I have to disable bitcode for my entire app.

CCDecodingStatusNextIteration

Hello Boris!

What does CCDecodingStatusNextIteration mean? Does it simply mean that there's isn't enough information to fill the whole canvas and given more data it probably will?

Add support for iOS7

Is it possible to add support for iOS7? When doing pod install, I see this lib only works on 8+. Thank you.

Crash while loading jpeg

Crashed: com.contentful.Concorde
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x00000000

Thread : Crashed: com.contentful.Concorde
0  libobjc.A.dylib                0x31e2af78 lookUpImpOrForward + 47
1  libobjc.A.dylib                0x31e2af3f _class_lookupMethodAndLoadCache3 + 34
2  libobjc.A.dylib                0x31e2af3f _class_lookupMethodAndLoadCache3 + 34
3  libobjc.A.dylib                0x31e311f9 _objc_msgSend_uncached + 24
4  Concorde                       0x001f7a64 _TFFC8Concorde19CCBufferedImageView10connectionFS0_FTCSo15NSURLConnection14didReceiveDataCSo6NSData_T_U_FT_T_ + 372
5  libdispatch.dylib              0x3238540f _dispatch_client_callout + 22
6  libdispatch.dylib              0x3238e861 _dispatch_barrier_sync_f_invoke + 48
7  Concorde                       0x001f62a8 _TToFC8Concorde19CCBufferedImageView10connectionfS0_FTCSo15NSURLConnection14didReceiveDataCSo6NSData_T_ + 304
8  CFNetwork                      0x2410aeed __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 56
9  CFNetwork                      0x2410aea7 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 182
10 CFNetwork                      0x2410af99 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 36
11 CFNetwork                      0x240f8a11 _NSURLConnectionDidReceiveData(_CFURLConnection*, __CFData const*, long, void const*) + 80
12 CFNetwork                      0x2401deab ___ZN27URLConnectionClient_Classic29_delegate_didReceiveDataArrayEv_block_invoke + 158
13 CFNetwork                      0x240bc76d ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 60
14 CFNetwork                      0x24010d71 RunloopBlockContext::_invoke_block(void const*, void*) + 60
15 CoreFoundation                 0x244c35a1 CFArrayApplyFunction + 36
16 CFNetwork                      0x24010c2b RunloopBlockContext::perform() + 182
17 CFNetwork                      0x24010af1 MultiplexerSource::perform() + 216
18 CFNetwork                      0x2401098d MultiplexerSource::_perform(void*) + 48
19 CoreFoundation                 0x24578fd7 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
20 CoreFoundation                 0x245783eb __CFRunLoopDoSources0 + 222
21 CoreFoundation                 0x24576a69 __CFRunLoopRun + 768
22 CoreFoundation                 0x244c3b31 CFRunLoopRunSpecific + 476
23 CoreFoundation                 0x244c3943 CFRunLoopRunInMode + 106
24 GraphicsServices               0x2b8a1051 GSEventRunModal + 136
25 UIKit                          0x27ab5f21 UIApplicationMain + 1440
26 Chata de Galocha               0x00043e34 main (AppDelegate.swift:19)

Add support for CYMK JPEGs

Can be based off this:

template <J_COLOR_SPACE colorSpace>
void setPixel(ImageFrame& buffer, ImageFrame::PixelData* currentAddress, JSAMPARRAY samples, int column)
{
    JSAMPLE* jsample = *samples + column * (colorSpace == JCS_RGB ? 3 : 4);

    switch (colorSpace) {
        case JCS_RGB:
            buffer.setRGBA(currentAddress, jsample[0], jsample[1], jsample[2], 0xFF);
            break;
        case JCS_CMYK:
            // Source is 'Inverted CMYK', output is RGB.
            // See: http://www.easyrgb.com/math.php?MATH=M12#text12
            // Or: http://www.ilkeratalay.com/colorspacesfaq.php#rgb
            // From CMYK to CMY:
            // X =   X    * (1 -   K   ) +   K  [for X = C, M, or Y]
            // Thus, from Inverted CMYK to CMY is:
            // X = (1-iX) * (1 - (1-iK)) + (1-iK) => 1 - iX*iK
            // From CMY (0..1) to RGB (0..1):
            // R = 1 - C => 1 - (1 - iC*iK) => iC*iK  [G and B similar]
            unsigned k = jsample[3];
            buffer.setRGBA(currentAddress, jsample[0] * k / 255, jsample[1] * k / 255, jsample[2] * k / 255, 0xFF);
            break;
    }
}

Help~

I want to develop the component in Java.But I can't find detailed description of ProgressiveJpeg format when searching on Google.Please guide me where I can get detailed information about ProgressiveJpeg.

Move swift code into subspec

Hi! We love your library! Very nice. The most interesting part in this project for me is the CCBufferedImageDecoder in pair with the library. In my eyes the CCBufferedImageView.swift is more like an example of how to integrate. Therefore I created this https://github.com/agens-no/CCBufferedImageDecoder

Ideally for me we would just change the podspec in this repo to either a) move the swift stuff into a subspec or b) remove the swift stuff or c) use one of the [ports].(https://github.com/ljfantin/Concorde/blob/feature/support_ios_7/Code/CCBufferedImageView.m).

Anyways, just though I should let you know.

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.