project_files/HedgewarsMobile/Classes/UIImageExtra.m
changeset 4356 d1d26f8963a3
parent 3978 9660600e43cb
child 4446 3093791dc620
equal deleted inserted replaced
4354:c4e1820fa792 4356:d1d26f8963a3
   230     UIGraphicsEndImageContext();
   230     UIGraphicsEndImageContext();
   231     return result;
   231     return result;
   232 }
   232 }
   233 
   233 
   234 +(UIImage *)whiteImage:(CGSize) ofSize {
   234 +(UIImage *)whiteImage:(CGSize) ofSize {
   235     UIGraphicsBeginImageContext(ofSize);
   235     CGFloat w = ofSize.width;
   236     CGContextRef context = UIGraphicsGetCurrentContext();
   236     CGFloat h = ofSize.height;
   237     UIGraphicsPushContext(context);
   237 
   238 
   238     CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
       
   239     CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
       
   240 
       
   241     CGContextBeginPath(context);
   239     CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
   242     CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
   240     CGContextFillRect(context,CGRectMake(0,0,ofSize.width,ofSize.height));
   243     CGContextFillRect(context,CGRectMake(0,0,ofSize.width,ofSize.height));
   241 
   244 
   242     UIGraphicsPopContext();
   245     CGImageRef image = CGBitmapContextCreateImage(context);
   243     UIImage *bkgImg = UIGraphicsGetImageFromCurrentImageContext();
   246     CGContextRelease(context);
   244     UIGraphicsEndImageContext();
   247     CGColorSpaceRelease(colorSpace);
       
   248 
       
   249     UIImage *bkgImg = [UIImage imageWithCGImage:image];
       
   250     CGImageRelease(image);
   245     return bkgImg;
   251     return bkgImg;
   246 }
   252 }
   247 
   253 
   248 @end
   254 @end