project_files/HedgewarsMobile/Classes/UIImageExtra.m
changeset 3903 db01c37494af
parent 3829 81db3c85784b
child 3910 dd47efbdec46
equal deleted inserted replaced
3902:3aac7ca07b0e 3903:db01c37494af
   205     CGImageRelease(imageMasked);
   205     CGImageRelease(imageMasked);
   206 
   206 
   207     return newImage;
   207     return newImage;
   208 }
   208 }
   209 
   209 
       
   210 // by http://www.sixtemia.com/journal/2010/06/23/uiimage-negative-color-effect/
       
   211 -(UIImage *)convertToNegative {
       
   212     UIGraphicsBeginImageContext(self.size);
       
   213     CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy);
       
   214     [self drawInRect:CGRectMake(0, 0, self.size.width, self.size.height)];
       
   215     CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeDifference);
       
   216     CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),[UIColor whiteColor].CGColor);
       
   217     CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, self.size.width, self.size.height));
       
   218     UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
       
   219     UIGraphicsEndImageContext();
       
   220     return result;
       
   221 }
       
   222 
   210 @end
   223 @end