(maxSize: number, options?: any)
| 458 | } |
| 459 | |
| 460 | public resizeAsync(maxSize: number, options?: any): Promise<ImageSource> { |
| 461 | return new Promise((resolve, reject) => { |
| 462 | if (!this.ios) { |
| 463 | reject(null); |
| 464 | } |
| 465 | const main_queue = dispatch_get_current_queue(); |
| 466 | const background_queue = dispatch_get_global_queue(qos_class_t.QOS_CLASS_DEFAULT, 0); |
| 467 | dispatch_async(background_queue, () => { |
| 468 | const size: CGSize = this.ios.size; |
| 469 | const dim = getScaledDimensions(size.width, size.height, maxSize); |
| 470 | |
| 471 | const newSize: CGSize = CGSizeMake(dim.width, dim.height); |
| 472 | |
| 473 | UIGraphicsBeginImageContextWithOptions(newSize, options?.opaque ?? false, this.ios.scale); |
| 474 | this.ios.drawInRect(CGRectMake(0, 0, newSize.width, newSize.height)); |
| 475 | |
| 476 | const resizedImage = UIGraphicsGetImageFromCurrentImageContext(); |
| 477 | UIGraphicsEndImageContext(); |
| 478 | dispatch_async(main_queue, () => { |
| 479 | resolve(new ImageSource(resizedImage)); |
| 480 | }); |
| 481 | }); |
| 482 | }); |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | function getFileName(path: string): string { |
no test coverage detected