- (UIImage *)testImageWithColor:(UIColor *)color { CGRect rect = CGRectMake(0.0f, 0.0f, 100.0f, 100.0f); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]); CGContextFillRect(context, rect); UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; } UIImage *testImage = [self testImageWithColor: [UIColor blueColor]]; NSData *jpgTestImageData = UIImageJPEGRepresentation(testImage, 1.0);
(UIImage *)testImageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 100.0f, 100.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
UIImage *testImage = [self testImageWithColor: [UIColor blueColor]];
NSData *jpgTestImageData = UIImageJPEGRepresentation(testImage, 1.0);