Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions DashWallet/DWPhoneWCSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ - (void)session:(WCSession *)session
}

if (! image && req.data) {
image = [UIImage imageWithQRCodeData:req.data color:[CIColor colorWithRed:0.0 green:141.0/255.0 blue:228.0/255.0]];
image = [UIImage dw_imageWithQRCodeData:req.data color:[CIColor colorWithRed:0.0 green:141.0/255.0 blue:228.0/255.0]];
}

UIImage *resizedImage = [image resize:CGSizeMake(150, 150) withInterpolationQuality:kCGInterpolationNone];
UIImage *overlayLogo = [[UIImage imageNamed:@"dashQROverlay"] resize:CGSizeMake(37.0, 37.0) withInterpolationQuality:kCGInterpolationMedium];
__unused UIImage *result = [resizedImage imageByMergingWithImage:overlayLogo];
UIImage *resizedImage = [image dw_resize:CGSizeMake(150, 150) withInterpolationQuality:kCGInterpolationNone];
UIImage *overlayLogo = [[UIImage imageNamed:@"dashQROverlay"] dw_resize:CGSizeMake(37.0, 37.0) withInterpolationQuality:kCGInterpolationMedium];
__unused UIImage *result = [resizedImage dw_imageByMergingWithImage:overlayLogo];
// TODO: figure out if it's mistype below or styled QR-code is not used intentionally

replyHandler(image ? @{AW_QR_CODE_BITS_KEY: UIImagePNGRepresentation(image)} : @{});
Expand Down Expand Up @@ -294,12 +294,12 @@ - (UIImage *)qrCode
}

if (! image && req) {
image = [UIImage imageWithQRCodeData:req color:[CIColor colorWithRed:0.0 green:0.0 blue:0.0]];
image = [UIImage dw_imageWithQRCodeData:req color:[CIColor colorWithRed:0.0 green:0.0 blue:0.0]];
}

UIImage *resizedImage = [image resize:CGSizeMake(150, 150) withInterpolationQuality:kCGInterpolationNone];
UIImage *overlayLogo = [[UIImage imageNamed:@"dashQROverlay"] resize:CGSizeMake(37.0, 37.0) withInterpolationQuality:kCGInterpolationMedium];
UIImage *result = [resizedImage imageByMergingWithImage:overlayLogo];
UIImage *resizedImage = [image dw_resize:CGSizeMake(150, 150) withInterpolationQuality:kCGInterpolationNone];
UIImage *overlayLogo = [[UIImage imageNamed:@"dashQROverlay"] dw_resize:CGSizeMake(37.0, 37.0) withInterpolationQuality:kCGInterpolationMedium];
UIImage *result = [resizedImage dw_imageByMergingWithImage:overlayLogo];

return result;
}
Expand Down
10 changes: 5 additions & 5 deletions DashWallet/DWReceiveViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ - (void)viewDidLoad
if (req.isValid) {
if (! _qrImage) {
_qrImage = [[UIImage imageWithData:[self.groupDefs objectForKey:APP_GROUP_QR_IMAGE_KEY]]
resize:self.qrView.bounds.size withInterpolationQuality:kCGInterpolationNone];
dw_resize:self.qrView.bounds.size withInterpolationQuality:kCGInterpolationNone];
}

self.qrView.image = _qrImage;
Expand Down Expand Up @@ -123,15 +123,15 @@ - (void)updateAddress
}

if (! image && req.data) {
image = [UIImage imageWithQRCodeData:req.data color:[CIColor colorWithRed:0.0 green:141.0/255.0 blue:228.0/255.0]];
image = [UIImage dw_imageWithQRCodeData:req.data color:[CIColor colorWithRed:0.0 green:141.0/255.0 blue:228.0/255.0]];
CGSize holeSize = CGSizeMake(5.0, 5.0);
image = [image imageByCuttingHoleInCenterWithSize:holeSize];
image = [image dw_imageByCuttingHoleInCenterWithSize:holeSize];
}

UIImage *overlayLogo = [UIImage imageNamed:@"dashQROverlay"];
UIImage *resizedImage = [image resize:qrViewBounds withInterpolationQuality:kCGInterpolationNone];
UIImage *resizedImage = [image dw_resize:qrViewBounds withInterpolationQuality:kCGInterpolationNone];

self.qrImage = [resizedImage imageByMergingWithImage:overlayLogo];
self.qrImage = [resizedImage dw_imageByMergingWithImage:overlayLogo];

if (req.amount == 0) {
if (req.isValid) {
Expand Down
4 changes: 2 additions & 2 deletions DashWallet/DWRootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ -(void)setObserversWithDeviceIsJailbroken:(BOOL)jailbroken {
else img = [UIImage imageNamed:@"wallpaper-default"];

[self.blur removeFromSuperview];
self.blur = [[UIImageView alloc] initWithImage:[img blurWithRadius:3]];
self.blur = [[UIImageView alloc] initWithImage:[img dw_blurWithRadius:3]];
[keyWindow.subviews.lastObject addSubview:self.blur];
}];

Expand Down Expand Up @@ -1225,7 +1225,7 @@ - (void)showBuyAlert
afterScreenUpdates:NO];
UIImage *bgImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImage *blurredBgImg = [bgImg blurWithRadius:3];
UIImage *blurredBgImg = [bgImg dw_blurWithRadius:3];

// display the popup
__weak BREventConfirmView *view =
Expand Down
13 changes: 6 additions & 7 deletions DashWallet/UIImage+Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@

@interface UIImage (Utils)

+ (instancetype)imageWithQRCodeData:(NSData *)data color:(CIColor *)color;
+ (instancetype)dw_imageWithQRCodeData:(NSData *)data color:(CIColor *)color;

- (UIImage *)resize:(CGSize)size withInterpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)blurWithRadius:(CGFloat)radius;
- (UIImage *)imageWithTintColor:(UIColor *)tintColor;
- (UIImage *)imageByMergingWithImage:(UIImage *)secondImage;
- (UIImage *)imageByMergingWithImage:(UIImage *)secondImage secondImageRect:(CGRect)secondImageRect;
- (UIImage *)imageByCuttingHoleInCenterWithSize:(CGSize)holeSize;
- (UIImage *)dw_resize:(CGSize)size withInterpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)dw_blurWithRadius:(CGFloat)radius;
- (UIImage *)dw_imageByMergingWithImage:(UIImage *)secondImage;
- (UIImage *)dw_imageByMergingWithImage:(UIImage *)secondImage secondImageRect:(CGRect)secondImageRect;
- (UIImage *)dw_imageByCuttingHoleInCenterWithSize:(CGSize)holeSize;

@end
36 changes: 7 additions & 29 deletions DashWallet/UIImage+Utils.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

@implementation UIImage (Utils)

+ (instancetype)imageWithQRCodeData:(NSData *)data color:(CIColor *)color
+ (instancetype)dw_imageWithQRCodeData:(NSData *)data color:(CIColor *)color
{
UIImage *image;
CGImageRef cgImg;
Expand Down Expand Up @@ -66,7 +66,7 @@ + (instancetype)imageWithQRCodeData:(NSData *)data color:(CIColor *)color
return image;
}

- (UIImage *)resize:(CGSize)size withInterpolationQuality:(CGInterpolationQuality)quality
- (UIImage *)dw_resize:(CGSize)size withInterpolationQuality:(CGInterpolationQuality)quality
{
UIGraphicsBeginImageContext(size);

Expand All @@ -85,7 +85,7 @@ - (UIImage *)resize:(CGSize)size withInterpolationQuality:(CGInterpolationQualit
return image;
}

- (UIImage *)blurWithRadius:(CGFloat)radius
- (UIImage *)dw_blurWithRadius:(CGFloat)radius
{
UIGraphicsBeginImageContext(self.size);

Expand Down Expand Up @@ -144,38 +144,16 @@ - (UIImage *)blurWithRadius:(CGFloat)radius
return image;
}

- (UIImage *)imageWithTintColor:(UIColor *)tintColor
{
UIGraphicsBeginImageContextWithOptions(self.size, NO, [UIScreen mainScreen].scale);
CGContextRef context = UIGraphicsGetCurrentContext();

CGContextTranslateCTM(context, 0, self.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);

CGContextSetBlendMode(context, kCGBlendModeNormal);
CGContextDrawImage(context, rect, self.CGImage);
CGContextSetBlendMode(context, kCGBlendModeSourceIn);
[tintColor setFill];
CGContextFillRect(context, rect);


UIImage *coloredImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return coloredImage;
}

- (UIImage *)imageByMergingWithImage:(UIImage *)secondImage {
- (UIImage *)dw_imageByMergingWithImage:(UIImage *)secondImage {
CGRect r = CGRectMake(roundf((self.size.width - secondImage.size.width) / 2.0),
roundf((self.size.height - secondImage.size.height) / 2.0),
secondImage.size.width,
secondImage.size.height);

return [self imageByMergingWithImage:secondImage secondImageRect:r];
return [self dw_imageByMergingWithImage:secondImage secondImageRect:r];
}

- (UIImage *)imageByMergingWithImage:(UIImage *)secondImage secondImageRect:(CGRect)secondImageRect {
- (UIImage *)dw_imageByMergingWithImage:(UIImage *)secondImage secondImageRect:(CGRect)secondImageRect {
UIImage *firstImage = self;
CGSize imageSize = self.size;
UIGraphicsBeginImageContextWithOptions(imageSize, NO, [UIScreen mainScreen].scale);
Expand All @@ -188,7 +166,7 @@ - (UIImage *)imageByMergingWithImage:(UIImage *)secondImage secondImageRect:(CGR
return result;
}

- (UIImage *)imageByCuttingHoleInCenterWithSize:(CGSize)holeSize {
- (UIImage *)dw_imageByCuttingHoleInCenterWithSize:(CGSize)holeSize {
CGSize size = self.size;
CGPoint centerPoint = CGPointMake((size.width - holeSize.width) / 2.0, (size.height - holeSize.height) / 2.0);

Expand Down
4 changes: 2 additions & 2 deletions TodayExtension/BRTodayViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ - (void)updateReceiveMoneyUI
if (self.qrCodeData && self.qrImage.bounds.size.width > 0) {
NSData *imageData = [self.appGroupUserDefault objectForKey:APP_GROUP_QR_IMAGE_KEY];
UIImage *image = [UIImage imageWithData:imageData];
UIImage *resizedImage = [image resize:CGSizeMake(240, 240) withInterpolationQuality:kCGInterpolationNone];
UIImage *resizedImage = [image dw_resize:CGSizeMake(240, 240) withInterpolationQuality:kCGInterpolationNone];
UIImage *overlayLogo = [UIImage imageNamed:@"dashQROverlay"];
UIImage *result = [resizedImage imageByMergingWithImage:overlayLogo];
UIImage *result = [resizedImage dw_imageByMergingWithImage:overlayLogo];

self.qrOverlay.image = result;
self.qrImage.image = result;
Expand Down