forked from mirrors/linphone-iphone
Fix the images being squeezed
This commit is contained in:
parent
84c92835bc
commit
f4841da4eb
2 changed files with 11 additions and 4 deletions
|
|
@ -340,15 +340,18 @@
|
|||
- (CGImageRef)cropImageFromRepresentation:(ALAssetRepresentation*)rep {
|
||||
CGImageRef newImage = [rep fullResolutionImage];
|
||||
CGSize originalSize = [rep dimensions];
|
||||
float originalAspectRatio = originalSize.width / originalSize.height;
|
||||
// We resize in width and crop in height
|
||||
if (originalSize.width > imageSize.width) {
|
||||
int height = originalSize.height * imageSize.width / originalSize.width;
|
||||
int height = imageSize.width / originalAspectRatio;
|
||||
newImage = [self.class resizeCGImage:newImage toWidth:imageSize.width andHeight:height];
|
||||
originalSize.height = height;
|
||||
}
|
||||
CGRect cropRect = CGRectMake(0, 0, imageSize.width, imageSize.height);
|
||||
if (imageSize.height < originalSize.height) cropRect.origin.y = (originalSize.height - imageSize.height)/2;
|
||||
newImage = CGImageCreateWithImageInRect(newImage, cropRect);
|
||||
LOGD([NSString stringWithFormat:@"Image size : width = %g, height = %g", imageSize.width, imageSize.height]);
|
||||
LOGD([NSString stringWithFormat:@"Bubble size : width = %g, height = %g", super.bubbleView.frame.size.width, super.bubbleView.frame.size.height]);
|
||||
return newImage;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -343,6 +343,8 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 52; // 44;
|
|||
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
|
||||
|
||||
size = [self getMediaMessageSizefromOriginalSize:originalImageSize withWidth:width];
|
||||
//This fixes the image being too small. I think the issue comes form the fact that the display is retina. This should probably be changed in the future.
|
||||
size.height += CELL_MESSAGE_Y_MARGIN;
|
||||
}
|
||||
size.width = MAX(size.width + CELL_MESSAGE_X_MARGIN, CELL_MIN_WIDTH);
|
||||
size.height = MAX(size.height + CELL_MESSAGE_Y_MARGIN, CELL_MIN_HEIGHT);
|
||||
|
|
@ -396,11 +398,13 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 52; // 44;
|
|||
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
|
||||
availableWidth = availableWidth /3;
|
||||
}
|
||||
int height = originalSize.height;
|
||||
int newHeight = originalSize.height;
|
||||
float originalAspectRatio = originalSize.width / originalSize.height;
|
||||
// We resize in width and crop in height
|
||||
if (originalSize.width > availableWidth) {
|
||||
height = originalSize.height * availableWidth / originalSize.width;
|
||||
newHeight = availableWidth / originalAspectRatio;
|
||||
}
|
||||
mediaSize.height = MIN(height, availableWidth);
|
||||
mediaSize.height = MIN(newHeight, availableWidth);
|
||||
mediaSize.width = MIN(availableWidth, originalSize.width);
|
||||
return mediaSize;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue