MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / resize

Method resize

packages/core/image-source/index.ios.ts:445–458  ·  view source on GitHub ↗
(maxSize: number, options?: any)

Source from the content-addressed store, hash-verified

443 }
444
445 public resize(maxSize: number, options?: any): ImageSource {
446 const size: CGSize = this.ios.size;
447 const dim = getScaledDimensions(size.width, size.height, maxSize);
448
449 const newSize: CGSize = CGSizeMake(dim.width, dim.height);
450
451 UIGraphicsBeginImageContextWithOptions(newSize, options?.opaque ?? false, this.ios.scale);
452 this.ios.drawInRect(CGRectMake(0, 0, newSize.width, newSize.height));
453
454 const resizedImage = UIGraphicsGetImageFromCurrentImageContext();
455 UIGraphicsEndImageContext();
456
457 return new ImageSource(resizedImage);
458 }
459
460 public resizeAsync(maxSize: number, options?: any): Promise<ImageSource> {
461 return new Promise((resolve, reject) => {

Callers 1

testResizeFunction · 0.45

Calls 1

getScaledDimensionsFunction · 0.90

Tested by

no test coverage detected