Skip to content

Instantly share code, notes, and snippets.

View kokousin's full-sized avatar

guoxx kokousin

View GitHub Profile
+ (UIImage*)thumbnailOfImage:(UIImage*)image withSize:(CGSize)aSize
{
//NSLog(@"create thumbnail image");
if (!image)
return nil;
CGImageRef imageRef = [image CGImage];
UIImage *thumb = nil;
+(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;
CGSize size = [view bounds].size;
UIGraphicsBeginImageContext(size);
[[view layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
#import <Cocoa/Cocoa.h>
@interface NSMutableArray (variadicMethodExample)
- (void) appendObjects:(id) firstObject, ...; // This method takes a nil-terminated list of objects.
@end
@implementation NSMutableArray (variadicMethodExample)
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].