project_files/HedgewarsMobile/Classes/UIImageExtra.m
changeset 6080 ce02ddfe8aa1
parent 6078 8c0cc07731e5
child 6209 074ab6ebcb3e
equal deleted inserted replaced
6079:c10767edcd58 6080:ce02ddfe8aa1
    49         return self;
    49         return self;
    50     }
    50     }
    51     CGFloat screenScale = [[UIScreen mainScreen] scale];
    51     CGFloat screenScale = [[UIScreen mainScreen] scale];
    52     int w = self.size.width * screenScale;
    52     int w = self.size.width * screenScale;
    53     int h = self.size.height * screenScale;
    53     int h = self.size.height * screenScale;
    54     
    54     int yOffset = self.size.height - secondImage.size.height + secondImagePoint.y;
       
    55 
    55     if (w == 0 || h == 0) {
    56     if (w == 0 || h == 0) {
    56         DLog(@"Can have 0 dimesions");
    57         DLog(@"Cannot have 0 dimesions");
    57         return self;
    58         return self;
    58     }
    59     }
    59     
    60     
    60     // Create a bitmap graphics context; this will also set it as the current context
    61     // Create a bitmap graphics context; this will also set it as the current context
    61     CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    62     CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    62     CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
    63     CGContextRef context = CGBitmapContextCreate(NULL, w, h+yOffset, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
    63     
    64     
    64     // draw the two images in the current context
    65     // draw the two images in the current context
    65     CGContextDrawImage(context, CGRectMake(0, 0, self.size.width*screenScale, self.size.height*screenScale), [self CGImage]);
    66     CGContextDrawImage(context, CGRectMake(0, 0, self.size.width*screenScale, self.size.height*screenScale), [self CGImage]);
    66     CGContextDrawImage(context, CGRectMake(secondImagePoint.x*screenScale, secondImagePoint.y*screenScale, secondImage.size.width*screenScale, secondImage.size.height*screenScale), [secondImage CGImage]);
    67     CGContextDrawImage(context, CGRectMake(secondImagePoint.x*screenScale, secondImagePoint.y*screenScale, secondImage.size.width*screenScale, secondImage.size.height*screenScale), [secondImage CGImage]);
    67     
    68