From 11aef69bf30649394380cff7115cd26e668abc09 Mon Sep 17 00:00:00 2001 From: Tommy Sparber Date: Wed, 7 Sep 2016 09:59:34 +0200 Subject: [PATCH] Fix some warnings by adding explicit typecasts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If more warnings are enable in Xcode these warnings are shown: * `Implicit conversion turns floating-point number into integer: 'float' to 'size_t' (aka 'unsigned long’)` * `Implicit conversion loses floating-point precision: 'double' to 'CGFloat' (aka 'float’)` This commit fixes these by adding explicit typecasts. --- UIImage+PDF/UIImage+PDF.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/UIImage+PDF/UIImage+PDF.m b/UIImage+PDF/UIImage+PDF.m index e934715..e676050 100755 --- a/UIImage+PDF/UIImage+PDF.m +++ b/UIImage+PDF/UIImage+PDF.m @@ -193,7 +193,7 @@ +(UIImage *)imageWithPDFData:(NSData *)data atWidth:(CGFloat)width atPage:(NSUIn CGRect mediaRect = [ PDFView mediaRectForData:data atPage:page ]; CGFloat aspectRatio = mediaRect.size.width / mediaRect.size.height; - CGSize size = CGSizeMake( width, ceil( width / aspectRatio )); + CGSize size = CGSizeMake( width, (CGFloat) ceil( width / aspectRatio )); return [ UIImage imageWithPDFData:data atSize:size atPage:page ]; } @@ -210,7 +210,7 @@ +(UIImage *)imageWithPDFData:(NSData *)data atHeight:(CGFloat)height atPage:(NSU CGRect mediaRect = [ PDFView mediaRectForData:data atPage:page ]; CGFloat aspectRatio = mediaRect.size.width / mediaRect.size.height; - CGSize size = CGSizeMake( ceil( height * aspectRatio ), height ); + CGSize size = CGSizeMake( (CGFloat) ceil( height * aspectRatio ), height ); return [ UIImage imageWithPDFData:data atSize:size atPage:page ]; } @@ -251,7 +251,7 @@ +(UIImage *)imageWithPDFData:(NSData *)data atSize:(CGSize)size atPage:(NSUInteg else { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGContextRef ctx = CGBitmapContextCreate(NULL, size.width * screenScale, size.height * screenScale, 8, 0, colorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); + CGContextRef ctx = CGBitmapContextCreate(NULL, (size_t)(size.width * screenScale), (size_t)(size.height * screenScale), 8, 0, colorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); CGContextScaleCTM(ctx, screenScale, screenScale); [PDFView renderIntoContext:ctx url:nil data:data size:size page:page preserveAspectRatio:preserveAspectRatio]; @@ -305,7 +305,7 @@ +(UIImage *) imageWithPDFURL:(NSURL *)URL atSize:(CGSize)size atPage:(NSUInteger else { CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGContextRef ctx = CGBitmapContextCreate(NULL, size.width * screenScale, size.height * screenScale, 8, 0, colorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); + CGContextRef ctx = CGBitmapContextCreate(NULL, (size_t)(size.width * screenScale), (size_t)(size.height * screenScale), 8, 0, colorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); CGContextScaleCTM(ctx, screenScale, screenScale); [PDFView renderIntoContext:ctx url:URL data:nil size:size page:page preserveAspectRatio:preserveAspectRatio]; @@ -353,7 +353,7 @@ +(UIImage *) imageWithPDFURL:(NSURL *)URL atWidth:(CGFloat)width atPage:(NSUInte CGRect mediaRect = [ PDFView mediaRectForURL:URL atPage:page ]; CGFloat aspectRatio = mediaRect.size.width / mediaRect.size.height; - CGSize size = CGSizeMake( width, ceil( width / aspectRatio )); + CGSize size = CGSizeMake( width, (CGFloat) ceil( width / aspectRatio )); return [ UIImage imageWithPDFURL:URL atSize:size atPage:page ]; } @@ -372,7 +372,7 @@ +(UIImage *) imageWithPDFURL:(NSURL *)URL atHeight:(CGFloat)height atPage:(NSUIn CGRect mediaRect = [ PDFView mediaRectForURL:URL atPage:page ]; CGFloat aspectRatio = mediaRect.size.width / mediaRect.size.height; - CGSize size = CGSizeMake( ceil( height * aspectRatio ), height ); + CGSize size = CGSizeMake( (CGFloat) ceil( height * aspectRatio ), height ); return [ UIImage imageWithPDFURL:URL atSize:size atPage:page ]; }