diff --git a/LEColorPicker/LEColorPicker.m b/LEColorPicker/LEColorPicker.m index 0032ea6..489bd92 100755 --- a/LEColorPicker/LEColorPicker.m +++ b/LEColorPicker/LEColorPicker.m @@ -42,9 +42,9 @@ @implementation LEColorPicker // LEColor structure typedef struct { - unsigned int red; - unsigned int green; - unsigned int blue; + NSUInteger red; + NSUInteger green; + NSUInteger blue; } LEColor; // Add texture coordinates to Vertices as follows @@ -137,7 +137,7 @@ void main(void) { @param colorB Another RGB color. @return The square of euclidian distance in RGB space. */ -unsigned int squareDistanceInRGBSpaceBetweenColor(LEColor colorA, LEColor colorB); +NSUInteger squareDistanceInRGBSpaceBetweenColor(LEColor colorA, LEColor colorB); #pragma mark - C internal functions implementation void freeImageData(void *info, const void *data, size_t size) @@ -146,7 +146,7 @@ void freeImageData(void *info, const void *data, size_t size) free((void*)data); } -unsigned int squareDistanceInRGBSpaceBetweenColor(LEColor colorA, LEColor colorB) +NSUInteger squareDistanceInRGBSpaceBetweenColor(LEColor colorA, LEColor colorB) { NSUInteger squareDistance = ((colorA.red - colorB.red)*(colorA.red - colorB.red))+ ((colorA.green - colorB.green) * (colorA.green - colorB.green))+ @@ -293,8 +293,8 @@ - (GLuint)setupTextureFromImage:(UIImage*)image LELog(@"Failed to load image for texture"); } - size_t width = CGImageGetWidth(inputTextureImage); - size_t height = CGImageGetHeight(inputTextureImage); + NSUInteger width = CGImageGetWidth(inputTextureImage); + NSUInteger height = CGImageGetHeight(inputTextureImage); GLubyte *inputTextureData = (GLubyte*)calloc(width*height*4, sizeof(GLubyte)); CGColorSpaceRef inputTextureColorSpace = CGImageGetColorSpace(inputTextureImage); @@ -314,7 +314,7 @@ - (GLuint)setupTextureFromImage:(UIImage*)image glBindTexture(GL_TEXTURE_2D, inputTexName); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA , width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, inputTextureData); + glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA , (int)width, (int)height, 0, GL_RGBA, GL_UNSIGNED_BYTE, inputTextureData); free(inputTextureData); return inputTexName; } @@ -519,7 +519,7 @@ - (BOOL)validateProgram:(GLuint)prog -(UIImage *)dumpImageWithWidth:(NSUInteger)width height:(NSUInteger)height biggestAlphaColorReturn:(UIColor**)returnColor { GLubyte *buffer = (GLubyte *) malloc(width * height * 4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)buffer); + glReadPixels(0, 0, (int)width, (int)height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)buffer); /* Find bigger Alpha color*/ NSUInteger biggerR = 0; @@ -551,7 +551,7 @@ -(UIImage *)dumpImageWithWidth:(NSUInteger)width height:(NSUInteger)height bigge // set up for CGImage creation int bitsPerComponent = 8; int bitsPerPixel = 32; - int bytesPerRow = 4 * width; + int bytesPerRow = 4 * (int)width; CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault; // Use this to retain alpha @@ -569,7 +569,7 @@ -(UIImage *)dumpImageWithWidth:(NSUInteger)width height:(NSUInteger)height bigge -(UIColor *)colorWithBiggerCountFromImageWidth:(NSUInteger)width height:(NSUInteger)height { GLubyte *buffer = (GLubyte *) malloc(width * height * 4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)buffer); + glReadPixels(0, 0, (int)width, (int)height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)buffer); /* Find bigger Alpha color*/ NSUInteger biggerR = 0; @@ -605,7 +605,7 @@ -(UIColor *)colorFromImageWithWidth:(NSUInteger)width { GLubyte *buffer = (GLubyte *) malloc(width * height * 4); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)buffer); + glReadPixels(0, 0, (int)width, (int)height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *)buffer); /* Find bigger Alpha color*/ NSUInteger biggerR = 0; @@ -662,8 +662,8 @@ -(UIColor *)colorFromImageWithWidth:(NSUInteger)width -(void)findTextColorsTaskForColorScheme:(LEColorScheme*)colorScheme { //Set sizes for buffer index calculations - NSUInteger width = LECOLORPICKER_GPU_DEFAULT_SCALED_SIZE; - NSUInteger height = LECOLORPICKER_GPU_DEFAULT_SCALED_SIZE; + int width = LECOLORPICKER_GPU_DEFAULT_SCALED_SIZE; + int height = LECOLORPICKER_GPU_DEFAULT_SCALED_SIZE; //Read Render buffer GLubyte *buffer = (GLubyte *) malloc(width * height * 4); @@ -790,7 +790,7 @@ - (BOOL)isSufficienteContrastBetweenBackground:(UIColor*)backgroundColor andForg float foregroundGreen = 0.0; float foregroundBlue = 0.0; - int numComponents = CGColorGetNumberOfComponents(backgroundColor.CGColor); + size_t numComponents = CGColorGetNumberOfComponents(backgroundColor.CGColor); if (numComponents == 4) { const CGFloat *components = CGColorGetComponents(backgroundColor.CGColor); diff --git a/LEColorPicker/UIColor+YUVSpace.m b/LEColorPicker/UIColor+YUVSpace.m index 48e1a7a..c27f448 100644 --- a/LEColorPicker/UIColor+YUVSpace.m +++ b/LEColorPicker/UIColor+YUVSpace.m @@ -20,7 +20,7 @@ + (float)yComponentFromColor:(UIColor *)color float y = 0.0; if (color) { - int numComponents = CGColorGetNumberOfComponents(color.CGColor); + size_t numComponents = CGColorGetNumberOfComponents(color.CGColor); if (numComponents == 4) { const CGFloat *components = CGColorGetComponents(color.CGColor); @@ -46,7 +46,7 @@ + (float)uComponentFromColor:(UIColor *)color float u = 0.0; if (color) { - int numComponents = CGColorGetNumberOfComponents(color.CGColor); + size_t numComponents = CGColorGetNumberOfComponents(color.CGColor); if (numComponents == 4) { const CGFloat *components = CGColorGetComponents(color.CGColor); @@ -71,7 +71,7 @@ + (float)vComponentFromColor:(UIColor *)color float v = 0.0; if (color) { - int numComponents = CGColorGetNumberOfComponents(color.CGColor); + size_t numComponents = CGColorGetNumberOfComponents(color.CGColor); if (numComponents == 4) { const CGFloat *components = CGColorGetComponents(color.CGColor); diff --git a/LEColorPickerDemo.xcodeproj/project.pbxproj b/LEColorPickerDemo.xcodeproj/project.pbxproj index 7b14803..fc0fc9b 100644 --- a/LEColorPickerDemo.xcodeproj/project.pbxproj +++ b/LEColorPickerDemo.xcodeproj/project.pbxproj @@ -347,9 +347,15 @@ A0883543167814CC006D6F0F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO; + CLANG_WARN_INT_CONVERSION = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "LEColorPickerDemo/LEColorPickerDemo-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; INFOPLIST_FILE = "LEColorPickerDemo/LEColorPickerDemo-Info.plist"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; @@ -359,8 +365,14 @@ A0883544167814CC006D6F0F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO; + CLANG_WARN_INT_CONVERSION = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "LEColorPickerDemo/LEColorPickerDemo-Prefix.pch"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; INFOPLIST_FILE = "LEColorPickerDemo/LEColorPickerDemo-Info.plist"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app;