This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (UIImage*)thumbnailOfImage:(UIImage*)image withSize:(CGSize)aSize | |
{ | |
//NSLog(@"create thumbnail image"); | |
if (!image) | |
return nil; | |
CGImageRef imageRef = [image CGImage]; | |
UIImage *thumb = nil; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+(UIImage *)rotateImage:(UIImage *)aImage | |
{ | |
CGImageRef imgRef = aImage.CGImage; | |
CGFloat width = CGImageGetWidth(imgRef); | |
CGFloat height = CGImageGetHeight(imgRef); | |
CGAffineTransform transform = CGAffineTransformIdentity; | |
CGRect bounds = CGRectMake(0, 0, width, height); | |
CGFloat scaleRatio = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGSize size = [view bounds].size; | |
UIGraphicsBeginImageContext(size); | |
[[view layer] renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Cocoa/Cocoa.h> | |
@interface NSMutableArray (variadicMethodExample) | |
- (void) appendObjects:(id) firstObject, ...; // This method takes a nil-terminated list of objects. | |
@end | |
@implementation NSMutableArray (variadicMethodExample) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void insertSort(int num[] , int length) | |
{ | |
for(int i=2 ; i<length ; i++) // We need to start to sort from num[2], because num[0] is the guard. | |
{ // and num[1] is the first sorted value. | |
num[0] = num[i] ; // num[0] is the guard which is the value that will be inserted, num[i] ; | |
int j = i ; | |
while(num[0]<num[j-1]) // We needn't to worry about the ArrayIndex out of bounds, | |
{ // because the first number of array is num[0] that equals | |
num[j] = num[j-1] ; // of num[i]. |