2014-12-06 22:27:43 +01:00
|
|
|
//
|
|
|
|
// PresentIdentityQRCodeViewController.m
|
|
|
|
// Signal-iOS
|
|
|
|
//
|
|
|
|
// Created by Christine Corbett Moran on 3/30/14.
|
|
|
|
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "PresentIdentityQRCodeViewController.h"
|
|
|
|
#import "NSData+Base64.h"
|
2014-12-31 19:31:27 +01:00
|
|
|
#import "UIImage+normalizeImage.h"
|
|
|
|
|
2014-12-06 22:27:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
@implementation PresentIdentityQRCodeViewController
|
|
|
|
|
|
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
|
[super didReceiveMemoryWarning];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void) viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
|
|
CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
|
|
|
|
|
|
|
|
[filter setDefaults];
|
|
|
|
|
|
|
|
[filter setValue:[[self.identityKey base64EncodedString] dataUsingEncoding:NSUTF8StringEncoding] forKey:@"inputMessage"];
|
|
|
|
|
|
|
|
CIImage *outputImage = [filter outputImage];
|
|
|
|
|
|
|
|
CIContext *context = [CIContext contextWithOptions:nil];
|
|
|
|
CGImageRef cgImage = [context createCGImage:outputImage fromRect:[outputImage extent]];
|
|
|
|
|
|
|
|
UIImage *image = [UIImage imageWithCGImage:cgImage scale:1. orientation:UIImageOrientationUp];
|
|
|
|
|
|
|
|
// Resize without interpolating
|
2014-12-31 19:31:27 +01:00
|
|
|
UIImage *resized = [image resizedWithQuality:kCGInterpolationNone rate:5.0];
|
2014-12-06 22:27:43 +01:00
|
|
|
|
|
|
|
self.qrCodeView.image = resized;
|
|
|
|
|
|
|
|
CGImageRelease(cgImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Action
|
|
|
|
- (IBAction)closeButtonAction:(id)sender
|
|
|
|
{
|
|
|
|
[UIView animateWithDuration:0.6 delay:0. options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
|
|
[self.view setAlpha:0];
|
|
|
|
} completion:^(BOOL succeeded){
|
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
}];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|