GithubHelp home page GithubHelp logo

artiledimageview's Introduction

ARTiledImageView

Build Status Version Platform

Demo

animated

Francisco De Goya Y Lucientes, Señora Sabasa Garcia, ca. 1806/1811, courtesy of the National Gallery of Art, Washington D.C., via Artsy.

Usage

ARWebTiledImageDataSource *ds = [[ARWebTiledImageDataSource alloc] init];
// height of the full zoomed in image
ds.maxTiledHeight = 2933;
// width of the full zommed in image
ds.maxTiledWidth = 2383;
// width of the full zommed in image
ds.minTileLevel = 10;
// maximum tile level
ds.maxTileLevel = 15;
// side of a square tile
ds.tileSize = 512;
// tile format
ds.tileFormat = @"jpg";
// location of tiles, organized in subfolders, one per level
ds.tileBaseURL = [NSURL URLWithString:@"https://raw.github.com/dblock/ARTiledImageView/master/Demo/Tiles/SenoraSabasaGarcia/tiles"];
// make sure to retain the datasource
_dataSource = ds;

ARTiledImageScrollView *sv = [[ARTiledImageScrollView alloc] initWithFrame:self.view.bounds];
// set datasource
sv.dataSource = ds;
// default background color
sv.backgroundColor = [UIColor grayColor];
// default stretched placeholder image
sv.backgroundImageURL = [NSURL URLWithString:@"https://raw.github.com/dblock/ARTiledImageView/master/Demo/Tiles/SenoraSabasaGarcia/large.jpg"];
// display tile borders, for debugging
sv.displayTileBorders = NO;

// add as a subview to another view
[self.view addSubview:sv];

Tiles and Data Sources

A typical organization for deep zoom map tiles consists of a folder for each zoom level and individual JPG files for each tile. You can see an example of such files here. ARTiledImageView comes with a local ARLocalTiledImageDataSource, which retrieves tile files from local storage, and a remote ARWebTiledImageDataSource data source, which retrieves map tiles from a remote URL and stores them in Library/Caches (NSCachesDirectory).

You can generate tiles using dzt or any other tool listed with the OpenSeadragon project.

Installation

ARTiledImageView is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "ARTiledImageView"

Testing

Try it out with CocoaPods also,

pod try "ARTiledImageView"

Credits

ARTiledImageView was originally written by @orta, with contributions from @speednoisemovement and @dblock. Some of the implementation in ARTiledImageScrollView comes from NAMapKit.

Copyright & License

ARTiledImageView is (c) Artsy Inc., available under the MIT license.

See the LICENSE file for more information.

artiledimageview's People

Contributors

ashfurrow avatar dblock avatar dkhamsing avatar orta avatar segiddins 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

artiledimageview's Issues

Crash in [ARTiledImageView downloadAndRedrawTilesWithURLs:] (ARTiledImageView.m:154)

Somehow this can crash:

- (void)downloadAndRedrawTilesWithURLs:(NSDictionary *)urls
{
    __weak typeof (self) wself = self;

    for (NSString *tileCacheKey in urls.keyEnumerator) {
        NSURL *tileURL = [urls objectForKey:tileCacheKey];
        if ([self.downloadOperations objectForKey:tileCacheKey]) {
            continue;
        }

In Artsy's Eigen app: https://rink.hockeyapp.net/manage/apps/37029/app_versions/16/crash_reasons/12678564 (requires logon)

Thread 9 Crashed:
0   libobjc.A.dylib                      0x39e03622 objc_msgSend + 1
1   CoreFoundation                       0x2f4be199 -[__NSDictionaryM objectForKey:] + 142
2   Artsy                                0x001bec5d -[ARTiledImageView downloadAndRedrawTilesWithURLs:] (ARTiledImageView.m:154)
3   Artsy                                0x001bea51 -[ARTiledImageView drawRect:] (ARTiledImageView.m:130)
4   UIKit                                0x31e1bda5 -[UIView drawLayer:inContext:] + 372
5   QuartzCore                           0x31a492c1 -[CALayer drawInContext:] + 100
6   QuartzCore                           0x31b19cb9 tiled_layer_render(_CAImageProvider*, unsigned int, unsigned int, unsigned int, unsigned int, void*) + 1458
7   QuartzCore                           0x31a76f33 CAImageProviderThread(unsigned int*, bool) + 464
8   libdispatch.dylib                    0x3a2e8ad7 _dispatch_root_queue_drain + 220
9   libdispatch.dylib                    0x3a2e8d29 _dispatch_worker_thread2 + 54
10  libsystem_pthread.dylib              0x3a423bd3 _pthread_wqthread + 298
11  libsystem_pthread.dylib              0x3a423a98 start_wqthread + 8

AV: crashes with tileSize = nil

From a test that wasn't setting tileSize, still needs a proper repro within ARTiledImageView.

Thread 2 Crashed:: com.apple.CoreAnimation.render-server
0   QuartzCore                      0x0086c7ac CA::OGL::TiledImageGeometry::TiledImageGeometry(CA::Render::TiledTexture*, CA::OGL::Context&, unsigned int, CA::OGL::TextureFilter, CA::OGL::TextureFilter, float, CA::OGL::ContentsGeometry const*) + 1650
1   QuartzCore                      0x0086e4fe CA::OGL::draw_tiled_image(CA::OGL::Context&, CA::Render::TiledTexture*, CA::OGL::TextureFilter, CA::OGL::TextureFilter, float, CA::OGL::ContentsGeometry const&, bool) + 80
2   QuartzCore                      0x00831860 CA::OGL::render_contents_background(CA::OGL::Renderer&, CA::OGL::Layer const*) + 1858
3   QuartzCore                      0x00829350 CA::OGL::LayerNode::apply(float, CA::OGL::Surface**, float*) + 56
4   QuartzCore                      0x00827f10 CA::OGL::ImagingNode::render(CA::OGL::ImagingNode::RenderClosure*, unsigned int) + 480
5   QuartzCore                      0x00834d08 CA::OGL::render_layers(CA::OGL::Renderer&, CA::OGL::Layer*) + 160
6   QuartzCore                      0x008293f7 CA::OGL::LayerNode::apply(float, CA::OGL::Surface**, float*) + 223
7   QuartzCore                      0x00827f10 CA::OGL::ImagingNode::render(CA::OGL::ImagingNode::RenderClosure*, unsigned int) + 480
8   QuartzCore                      0x00834d08 CA::OGL::render_layers(CA::OGL::Renderer&, CA::OGL::Layer*) + 160
9   QuartzCore                      0x008293f7 CA::OGL::LayerNode::apply(float, CA::OGL::Surface**, float*) + 223
10  QuartzCore                      0x00827f10 CA::OGL::ImagingNode::render(CA::OGL::ImagingNode::RenderClosure*, unsigned int) + 480
11  QuartzCore                      0x00834d08 CA::OGL::render_layers(CA::OGL::Renderer&, CA::OGL::Layer*) + 160
12  QuartzCore                      0x008293f7 CA::OGL::LayerNode::apply(float, CA::OGL::Surface**, float*) + 223
13  QuartzCore                      0x00827f10 CA::OGL::ImagingNode::render(CA::OGL::ImagingNode::RenderClosure*, unsigned int) + 480
14  QuartzCore                      0x00834d08 CA::OGL::render_layers(CA::OGL::Renderer&, CA::OGL::Layer*) + 160
15  QuartzCore                      0x008293f7 CA::OGL::LayerNode::apply(float, CA::OGL::Surface**, float*) + 223
16  QuartzCore                      0x00827f10 CA::OGL::ImagingNode::render(CA::OGL::ImagingNode::RenderClosure*, unsigned int) + 480
17  QuartzCore                      0x00834d08 CA::OGL::render_layers(CA::OGL::Renderer&, CA::OGL::Layer*) + 160
18  QuartzCore                      0x008293f7 CA::OGL::LayerNode::apply(float, CA::OGL::Surface**, float*) + 223
19  QuartzCore                      0x00827f10 CA::OGL::ImagingNode::render(CA::OGL::ImagingNode::RenderClosure*, unsigned int) + 480
20  QuartzCore                      0x00834d08 CA::OGL::render_layers(CA::OGL::Renderer&, CA::OGL::Layer*) + 160
21  QuartzCore                      0x008293f7 CA::OGL::LayerNode::apply(float, CA::OGL::Surface**, float*) + 223
22  QuartzCore                      0x00827f10 CA::OGL::ImagingNode::render(CA::OGL::ImagingNode::RenderClosure*, unsigned int) + 480
23  QuartzCore                      0x00834d08 CA::OGL::render_layers(CA::OGL::Renderer&, CA::OGL::Layer*) + 160
24  QuartzCore                      0x00834ef6 CA::OGL::render_root_layers(CA::OGL::Renderer&, x_link_struct const*, CA::OGL::Gstate const&) + 352
25  QuartzCore                      0x0084aaa5 CA::OGL::Renderer::render(CA::Render::Update const*) + 583
26  QuartzCore                      0x0087c44b CA::WindowServer::Display::render_display(CA::OGL::Renderer&, CA::Render::Update*) + 363
27  QuartzCore                      0x0087fe5a CA::WindowServer::Server::render_update(CA::Render::Update*, unsigned int&) + 44
28  QuartzCore                      0x0087f8de CA::WindowServer::Server::render_for_time(double, CVTimeStamp const*) + 1786
29  QuartzCore                      0x0087f1de CA::WindowServer::Server::timer_callback(double, void*) + 34
30  QuartzCore                      0x0080e5ac CA::Render::Server::run_callbacks() + 156
31  QuartzCore                      0x0080e122 CA::Render::Server::server_thread(void*) + 155
32  QuartzCore                      0x008e0ad4 thread_fun + 29
33  libsystem_pthread.dylib         0x01a595fb _pthread_body + 144
34  libsystem_pthread.dylib         0x01a59485 _pthread_start + 130
35  libsystem_pthread.dylib         0x01a5ecf2 thread_start + 34

Change scale to fit to stretch to fill for image in tiles.

Last row and last column tiles are being scaled to fit. I have tiles of 512x512. The resolution of whole images are not multiples of 512 i.e, whole image is of resolution 1030x1030. Therefore, there are 9 tiles. last column tiles in server are in 512x512 by adding a black portion to the rest of the image portion. I need the last image to be in stretch to fill. The image that I get from server should be drawn from 1024 to 1536. I'm not sure if you would understand the situation. But I've added two images that show this issue. That show the border before tiles are loaded and after tiles are load. The last tiles get shrunken.

Before tiles are rendered
after tiles are rendered

Custom zoom step

I created a project that requires to load webp tiled images from server and render it on catiledlayer. But, I'm facing a huge performance issue while zooming and panning. A lib in android named tileview has really good performance. I tried using your library on a new project. But, I'm stuck at two places. 1. Loading webp images from url.
2. Tiles available only at 4x zoom steps instead of 2x.
Please, help me achieve this.

UIKit work is done on the main thread

In Folio, which may have more things turned on - I get errors about doing UI work on a background thread. This could be the cause of some of our crashes. /cc @alloy

Main Thread Checker: UI API called on a background thread: -[UIView layer]
PID: 67828, TID: 2321153, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4   FolioDev                            0x00000001057cde2b -[ARTiledImageView drawRect:] + 107
5   UIKit                               0x00000001096ab1c5 -[UIView(CALayerDelegate) drawLayer:inContext:] + 487
6   QuartzCore                          0x000000010903e254 -[CALayer drawInContext:] + 267
7   QuartzCore                          0x0000000108f88764 _ZL18tiled_layer_renderP16_CAImageProviderjjjjPv + 1817
8   QuartzCore                          0x000000010901488e _ZL21CAImageProviderThreadPjb + 789
9   libdispatch.dylib                   0x000000010db8533d _dispatch_client_callout + 8
10  libdispatch.dylib                   0x000000010db8a251 _dispatch_queue_override_invoke + 1458
11  libdispatch.dylib                   0x000000010db91102 _dispatch_root_queue_drain + 772
12  libdispatch.dylib                   0x000000010db90da0 _dispatch_worker_thread3 + 132
13  libsystem_pthread.dylib             0x000000010e051169 _pthread_wqthread + 1387
14  libsystem_pthread.dylib             0x000000010e050be9 start_wqthread + 13

2018-03-25 14:42:35.225523-0400 FolioDev[67828:2321153] [reports] Main Thread Checker: UI API called on a background thread: -[UIView layer]
PID: 67828, TID: 2321153, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4   FolioDev                            0x00000001057cde2b -[ARTiledImageView drawRect:] + 107
5   UIKit                               0x00000001096ab1c5 -[UIView(CALayerDelegate) drawLayer:inContext:] + 487
6   QuartzCore                          0x000000010903e254 -[CALayer drawInContext:] + 267
7   QuartzCore                          0x0000000108f88764 _ZL18tiled_layer_renderP16_CAImageProviderjjjjPv + 1817
8   QuartzCore                          0x000000010901488e _ZL21CAImageProviderThreadPjb + 789
9   libdispatch.dylib                   0x000000010db8533d _dispatch_client_callout + 8
10  libdispatch.dylib                   0x000000010db8a251 _dispatch_queue_override_invoke + 1458
11  libdispatch.dylib                   0x000000010db91102 _dispatch_root_queue_drain + 772
12  libdispatch.dylib                   0x000000010db90da0 _dispatch_worker_thread3 + 132
13  libsystem_pthread.dylib             0x000000010e051169 _pthread_wqthread + 1387
14  libsystem_pthread.dylib             0x000000010e050be9 start_wqthread + 13
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView bounds]
PID: 67828, TID: 2321098, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4   FolioDev                            0x00000001057ce3a8 -[ARTiledImageView drawRect:] + 1512
5   UIKit                               0x00000001096ab1c5 -[UIView(CALayerDelegate) drawLayer:inContext:] + 487
6   QuartzCore                          0x000000010903e254 -[CALayer drawInContext:] + 267
7   QuartzCore                          0x0000000108f88764 _ZL18tiled_layer_renderP16_CAImageProviderjjjjPv + 1817
8   QuartzCore                          0x000000010901488e _ZL21CAImageProviderThreadPjb + 789
9   libdispatch.dylib                   0x000000010db8533d _dispatch_client_callout + 8
10  libdispatch.dylib                   0x000000010db8a251 _dispatch_queue_override_invoke + 1458
11  libdispatch.dylib                   0x000000010db91102 _dispatch_root_queue_drain + 772
12  libdispatch.dylib                   0x000000010db90da0 _dispatch_worker_thread3 + 132
13  libsystem_pthread.dylib             0x000000010e051169 _pthread_wqthread + 1387
14  libsystem_pthread.dylib             0x000000010e050be9 start_wqthread + 13

Include a script for generating tiles from an image

Mainly to answer this question:

I've got my big 7000x8000px image, how do I get the right tiles from this?

Ideally it would be something like, ruby ./generate_tiles 512 file.jpg --output target_folder and it would pump out a bunch of jpgs into said folder.

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.