Wiki

Clone wiki

ios-image-utils / Create_white_alpha_PNG

/* Using ImageMagick to turn icon into white and preserve alpha mask. convert grid.png -fill White -colorize 100% grid2.png http://www.imagemagick.org/Usage/canvas/#specific

  • /

/* Programmatic way http://stackoverflow.com/questions/4324764/iphone-uibarbuttonitem-alpha-of-button-image

  • / UIImage *inImage = [UIImage imageNamed:@"glyphicons_154_show_big_thumbnails.png"]; CGRect imageRect = CGRectMake(0, 0, inImage.size.width, inImage.size.height); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

CGContextRef context = CGBitmapContextCreate(NULL, imageRect.size.width, imageRect.size.height, 8, imageRect.size.width * 4, colorSpace, kCGImageAlphaPremultipliedLast); CGContextClipToMask(context, imageRect, inImage.CGImage); CGContextSetRGBFillColor(context, 1, 1, 1, 1); CGContextFillRect(context, imageRect);

CGImageRef finalImage = CGBitmapContextCreateImage(context); UIImage *returnImage = [UIImage imageWithCGImage:finalImage];

CGContextRelease(context); CGColorSpaceRelease(colorSpace); CGImageRelease(finalImage);

Updated