Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change a typecast in -colorAtPixel:

  • Loading branch information...
commit 7b740d933ca514b872e2fc62f786467ff65004a1 1 parent 8e2588f
@ole ole authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 UIImage+ColorAtPixel/UIImage+ColorAtPixel.m
View
6 UIImage+ColorAtPixel/UIImage+ColorAtPixel.m
@@ -57,8 +57,8 @@ - (UIColor *)colorAtPixel:(CGPoint)point {
NSInteger pointX = trunc(point.x);
NSInteger pointY = trunc(point.y);
CGImageRef cgImage = self.CGImage;
- NSUInteger width = CGImageGetWidth(cgImage);
- NSUInteger height = CGImageGetHeight(cgImage);
+ NSUInteger width = self.size.width;
+ NSUInteger height = self.size.height;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
int bytesPerPixel = 4;
int bytesPerRow = bytesPerPixel * 1;
@@ -75,7 +75,7 @@ - (UIColor *)colorAtPixel:(CGPoint)point {
CGContextSetBlendMode(context, kCGBlendModeCopy);
// Draw the pixel we are interested in onto the bitmap context
- CGContextTranslateCTM(context, -pointX, pointY-(NSInteger)height);
+ CGContextTranslateCTM(context, -pointX, pointY-(CGFloat)height);
CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, (CGFloat)width, (CGFloat)height), cgImage);
CGContextRelease(context);
Please sign in to comment.
Something went wrong with that request. Please try again.