forked from vfr/Reader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPDFTiledLayer.m
More file actions
68 lines (47 loc) · 1.5 KB
/
PDFTiledLayer.m
File metadata and controls
68 lines (47 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// PDFTiledLayer.m
// Reader
//
// Created by Julius Oklamcak on 2010-09-01.
// Copyright © 2010-2011 Julius Oklamcak. All rights reserved.
//
// This work is being made available under a Creative Commons Attribution license:
// «http://creativecommons.org/licenses/by/3.0/»
// You are free to use this work and any derivatives of this work in personal and/or
// commercial products and projects as long as the above copyright is maintained and
// the original author is attributed.
//
#import "PDFTiledLayer.h"
@implementation PDFTiledLayer
#pragma mark Constants
#define ZOOM_LEVELS 5
#pragma mark Properties
//@synthesize ;
#pragma mark PDFTiledLayer class methods
+ (CFTimeInterval)fadeDuration
{
return 0.0; // No fading wanted
}
#pragma mark PDFTiledLayer instance methods
- (id)init
{
if ((self = [super init]))
{
self.levelsOfDetail = ZOOM_LEVELS;
self.levelsOfDetailBias = (ZOOM_LEVELS - 1);
CGFloat screenScale; // Points to pixels
UIScreen *mainScreen = [UIScreen mainScreen];
if ([mainScreen respondsToSelector:@selector(scale)])
screenScale = [mainScreen scale];
else
screenScale = 1.0f;
CGRect screenBounds = [mainScreen bounds]; // Is in points
CGFloat w_pixels = (screenBounds.size.width * screenScale);
CGFloat h_pixels = (screenBounds.size.height * screenScale);
CGFloat max = (w_pixels < h_pixels) ? h_pixels : w_pixels;
CGFloat sizeOfTiles = (max < 512.0f) ? 512.0f : 1024.0f;
self.tileSize = CGSizeMake(sizeOfTiles, sizeOfTiles);
}
return self;
}
@end