equal
deleted
inserted
replaced
|
1 // |
|
2 // UIImageScale.m |
|
3 // HedgewarsMobile |
|
4 // |
|
5 // Created by Vittorio on 08/04/10. |
|
6 // Copyright 2010 __MyCompanyName__. All rights reserved. |
|
7 // |
|
8 |
|
9 #import "UIImageScale.h" |
|
10 |
|
11 |
|
12 @implementation UIImage (scale) |
|
13 |
|
14 -(UIImage*)scaleToSize:(CGSize)size |
|
15 { |
|
16 // Create a bitmap graphics context |
|
17 // This will also set it as the current context |
|
18 UIGraphicsBeginImageContext(size); |
|
19 |
|
20 // Draw the scaled image in the current context |
|
21 [self drawInRect:CGRectMake(0, 0, size.width, size.height)]; |
|
22 |
|
23 // Create a new image from current context |
|
24 UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext(); |
|
25 |
|
26 // Pop the current context from the stack |
|
27 UIGraphicsEndImageContext(); |
|
28 |
|
29 // Return our new scaled image |
|
30 return scaledImage; |
|
31 } |
|
32 |
|
33 @end |