Skip to content

Commit

Permalink
Merge pull request #13 from mspensieri/compiler_warnings
Browse files Browse the repository at this point in the history
Fix some compiler warnings
  • Loading branch information
luisespinoza committed Mar 15, 2014
2 parents e34edca + 9982f17 commit 4fec4be
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
30 changes: 15 additions & 15 deletions LEColorPicker/LEColorPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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))+
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions LEColorPicker/UIColor+YUVSpace.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions LEColorPickerDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 4fec4be

Please sign in to comment.