mirror of
https://github.com/danog/Telegram.git
synced 2024-12-04 02:17:51 +01:00
44 lines
1.2 KiB
Objective-C
44 lines
1.2 KiB
Objective-C
#import "TGBridgeImageInfo+TGImageInfo.h"
|
|
|
|
#import "TGImageInfo.h"
|
|
|
|
@implementation TGBridgeImageInfo (TGImageInfo)
|
|
|
|
+ (TGBridgeImageInfo *)imageInfoWithTGImageInfo:(TGImageInfo *)imageInfo
|
|
{
|
|
if (imageInfo == nil)
|
|
return nil;
|
|
|
|
TGBridgeImageInfo *bridgeImageInfo = [[TGBridgeImageInfo alloc] init];
|
|
NSDictionary *allSizes = imageInfo.allSizes;
|
|
|
|
NSMutableArray *bridgeEntries = [[NSMutableArray alloc] init];
|
|
for (NSString *url in allSizes.allKeys)
|
|
{
|
|
TGBridgeImageSizeInfo *bridgeEntry = [[TGBridgeImageSizeInfo alloc] init];
|
|
bridgeEntry.url = url;
|
|
bridgeEntry.dimensions = [allSizes[url] CGSizeValue];
|
|
|
|
[bridgeEntries addObject:bridgeEntry];
|
|
}
|
|
|
|
bridgeImageInfo->_entries = bridgeEntries;
|
|
|
|
return bridgeImageInfo;
|
|
}
|
|
|
|
+ (TGImageInfo *)tgImageInfoWithBridgeImageInfo:(TGBridgeImageInfo *)bridgeImageInfo
|
|
{
|
|
if (bridgeImageInfo == nil)
|
|
return nil;
|
|
|
|
TGImageInfo *imageInfo = [[TGImageInfo alloc] init];
|
|
|
|
for (TGBridgeImageSizeInfo *entry in bridgeImageInfo.entries)
|
|
[imageInfo addImageWithSize:entry.dimensions url:entry.url];
|
|
|
|
return imageInfo;
|
|
}
|
|
|
|
@end
|