|
@@ -1,86 +0,0 @@
|
|
|
-//
|
|
|
-// CPDFListMagnifierView.m
|
|
|
-// compdfkit-tools
|
|
|
-//
|
|
|
-// Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
|
|
|
-//
|
|
|
-// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
|
|
|
-// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
|
|
|
-// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
|
|
|
-// This notice may not be removed from this file.
|
|
|
-//
|
|
|
-
|
|
|
-#import "CPDFListMagnifierView.h"
|
|
|
-
|
|
|
-@implementation CPDFListMagnifierView
|
|
|
-
|
|
|
-#pragma mark - Initializers
|
|
|
-
|
|
|
-- (instancetype)init {
|
|
|
- if (self = [super initWithFrame:CGRectMake(0, 0, 145, 59)]) {
|
|
|
- self.backgroundColor = [UIColor clearColor];
|
|
|
- self.scale = 1.0;
|
|
|
- }
|
|
|
- return self;
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark - Accessors
|
|
|
-
|
|
|
-- (void)setStyle:(CPDFListMagnifierViewStyle)style {
|
|
|
- _style = style;
|
|
|
-
|
|
|
- if (CPDFListMagnifierViewStyleRect == style) {
|
|
|
- self.frame = CGRectMake(0, 0, 145, 59);
|
|
|
- } else if (CPDFListMagnifierViewStyleCircle == style) {
|
|
|
- self.frame = CGRectMake(0, 0, 127, 127);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark - Draw
|
|
|
-
|
|
|
-- (void)drawRect:(CGRect)rect {
|
|
|
- if (CPDFListMagnifierViewStyleRect == self.style) {
|
|
|
- CGContextRef context = UIGraphicsGetCurrentContext();
|
|
|
- UIImage *image = [UIImage imageNamed:@"magnifier-ranged-lo.png" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil];
|
|
|
- [image drawInRect:self.bounds];
|
|
|
-
|
|
|
- UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0);
|
|
|
- CGContextRef mirrorContext = UIGraphicsGetCurrentContext();
|
|
|
- CGContextTranslateCTM(mirrorContext, self.bounds.size.width/2.0, self.bounds.size.height/2.0-2);
|
|
|
- CGContextScaleCTM(mirrorContext, self.scale, -self.scale);
|
|
|
- CGContextTranslateCTM(mirrorContext, -self.pointToMagnify.x, -self.pointToMagnify.y);
|
|
|
- [self.viewToMagnify.layer renderInContext:mirrorContext];
|
|
|
-
|
|
|
- UIImage *maskImage = [UIImage imageNamed:@"CPDFListViewImageNameMagnifierRangedMask" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil];
|
|
|
- CGImageRef imageRef = CGBitmapContextCreateImage(mirrorContext);
|
|
|
- CGImageRef maskImageRef = CGImageCreateWithMask(imageRef, maskImage.CGImage);
|
|
|
- CGImageRelease(imageRef);
|
|
|
- UIGraphicsEndImageContext();
|
|
|
- CGContextDrawImage(context, self.bounds, maskImageRef);
|
|
|
- CGImageRelease(maskImageRef);
|
|
|
-
|
|
|
- image = [UIImage imageNamed:@"CPDFListViewImageNameMagnifierRangedHi" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil];
|
|
|
- [image drawInRect:self.bounds];
|
|
|
- } else if (CPDFListMagnifierViewStyleCircle == self.style) {
|
|
|
- CGContextRef context = UIGraphicsGetCurrentContext();
|
|
|
- UIImage *image = [UIImage imageNamed:@"CPDFListViewImageNameMagnifierLoupeLo" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil];
|
|
|
- [image drawInRect:self.bounds];
|
|
|
-
|
|
|
- UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0);
|
|
|
- CGContextRef mirrorContext = UIGraphicsGetCurrentContext();
|
|
|
- CGContextTranslateCTM(mirrorContext, self.bounds.size.width/2.0, self.bounds.size.height/2.0);
|
|
|
- CGContextScaleCTM(mirrorContext, self.scale, -self.scale);
|
|
|
- CGContextTranslateCTM(mirrorContext, -self.pointToMagnify.x, -self.pointToMagnify.y);
|
|
|
- [self.viewToMagnify.layer renderInContext:mirrorContext];
|
|
|
-
|
|
|
- UIImage *maskImage = [UIImage imageNamed:@"CPDFListViewImageNameMagnifierLoupeHi" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil];
|
|
|
- CGImageRef imageRef = CGBitmapContextCreateImage(mirrorContext);
|
|
|
- CGImageRef maskImageRef = CGImageCreateWithMask(imageRef, maskImage.CGImage);
|
|
|
- CGImageRelease(imageRef);
|
|
|
- UIGraphicsEndImageContext();
|
|
|
- CGContextDrawImage(context, self.bounds, maskImageRef);
|
|
|
- CGImageRelease(maskImageRef);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-@end
|