project_files/HedgewarsMobile/Classes/UIImageExtra.m
changeset 4446 3093791dc620
parent 4356 d1d26f8963a3
child 4461 2f4f5d649bcd
--- a/project_files/HedgewarsMobile/Classes/UIImageExtra.m	Thu Dec 02 00:25:26 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/UIImageExtra.m	Thu Dec 02 00:51:56 2010 +0100
@@ -24,6 +24,13 @@
 
 @implementation UIImage (extra)
 
+CGFloat getScreenScale(void) {
+    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
+        return [UIScreen mainScreen].scale;
+    else
+        return 1.0f;
+}
+
 -(UIImage *)scaleToSize:(CGSize) size {
     DLog(@"warning - this is a very expensive operation, you should avoid using it");
 
@@ -193,8 +200,9 @@
 -(UIImage *)makeRoundCornersOfSize:(CGSize) sizewh {
     CGFloat cornerWidth = sizewh.width;
     CGFloat cornerHeight = sizewh.height;
-    CGFloat w = self.size.width;
-    CGFloat h = self.size.height;
+    CGFloat theScale = getScreenScale();
+    CGFloat w = self.size.width * theScale;
+    CGFloat h = self.size.height * theScale;
 
     CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
     CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
@@ -211,7 +219,7 @@
     CGContextRelease(context);
     CGColorSpaceRelease(colorSpace);
 
-    UIImage *newImage = [UIImage imageWithCGImage:imageMasked];
+    UIImage *newImage = [UIImage imageWithCGImage:imageMasked scale:theScale orientation:UIImageOrientationUp];
     CGImageRelease(imageMasked);
 
     return newImage;