UI: always square images before rounding

This commit is contained in:
Gautier Pelloux-Prayer 2015-12-09 14:45:06 +01:00
parent 2813422b79
commit c3a5ae91b3
2 changed files with 4 additions and 4 deletions

View file

@ -45,7 +45,7 @@ INIT_WITH_COMMON {
- (void)setImage:(UIImage *)image bordered:(BOOL)bordered withRoundedRadius:(BOOL)rounded {
// We have to scale image to layers limits so that when we round image, we have a proper circle
[super setImage:image];
[super setImage:[image squareCrop]];
[self setBordered:bordered];
[self setRoundRadius];
}

View file

@ -457,10 +457,10 @@ void linphone_iphone_log_handler(int lev, const char *fmt, va_list args) {
- (UIImage *)squareCrop {
// This calculates the crop area.
float originalWidth = self.size.width;
float originalHeight = self.size.height;
size_t originalWidth = CGImageGetWidth(self.CGImage);
size_t originalHeight = CGImageGetHeight(self.CGImage);
float edge = fminf(originalWidth, originalHeight);
size_t edge = MIN(originalWidth, originalHeight);
float posX = (originalWidth - edge) / 2.0f;
float posY = (originalHeight - edge) / 2.0f;