Skip to content

Commit

Permalink
Merge pull request NSHipster#339 from Broich/patch-1
Browse files Browse the repository at this point in the history
Update 2014-09-15-image-resizing.md
  • Loading branch information
natecook1000 committed Oct 13, 2015
2 parents 73d6f9d + 3e26029 commit 6254b6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 2014-09-15-image-resizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ CGContextSetInterpolationQuality(context, kCGInterpolationHigh)

CGContextDrawImage(context, CGRect(origin: CGPointZero, size: CGSize(width: CGFloat(width), height: CGFloat(height))), cgImage)

let scaledImage = CGBitmapContextCreateImage(context).flatMap { UIImage(CGImage: $0 }
let scaledImage = CGBitmapContextCreateImage(context).flatMap { UIImage(CGImage: $0) }
```

`CGBitmapContextCreate` takes several arguments to construct a context with desired dimensions and amount of memory for each channel within a given colorspace. In the example, these values are fetched from the `CGImage`. Next, `CGContextSetInterpolationQuality` allows for the context to interpolate pixels at various levels of fidelity. In this case, `kCGInterpolationHigh` is passed for best results. `CGContextDrawImage` allows for the image to be drawn at a given size and position, allowing for the image to be cropped on a particular edge or to fit a set of image features, such as faces. Finally, `CGBitmapContextCreateImage` creates a `CGImage` from the context.
Expand Down

0 comments on commit 6254b6b

Please sign in to comment.