Skip to content

Commit

Permalink
make scale non optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Amol Prabhu committed Jul 8, 2024
1 parent 4bde068 commit bd15e13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions Sources/Nuke/Decoding/ImageDecoders+Default.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension ImageDecoders {
private var scanner = ProgressiveJPEGScanner()

private var isPreviewForGIFGenerated = false
private var scale: CGFloat?
private var scale: CGFloat = 1.0
private var thumbnail: ImageRequest.ThumbnailOptions?
private let lock = NSLock()

Expand All @@ -38,7 +38,7 @@ extension ImageDecoders {
/// Returns `nil` if progressive decoding is not allowed for the given
/// content.
public init?(context: ImageDecodingContext) {
self.scale = context.request.scale.map { CGFloat($0) }
self.scale = context.request.scale.map { CGFloat($0) } ?? 1.0
self.thumbnail = context.request.thumbnail

if !context.isCompleted && !isProgressiveDecodingAllowed(for: context.data) {
Expand All @@ -52,9 +52,9 @@ extension ImageDecoders {

func makeImage() -> PlatformImage? {
if let thumbnail {
return makeThumbnail(data: data,
return makeThumbnail(data: data,
options: thumbnail,
scale: scale ?? 1.0)
scale: scale)
}
return ImageDecoders.Default._decode(data, scale: scale)
}
Expand Down Expand Up @@ -164,11 +164,11 @@ private struct ProgressiveJPEGScanner: Sendable {
}

extension ImageDecoders.Default {
private static func _decode(_ data: Data, scale: CGFloat?) -> PlatformImage? {
private static func _decode(_ data: Data, scale: CGFloat) -> PlatformImage? {
#if os(macOS)
return NSImage(data: data)
#else
return UIImage(data: data, scale: scale ?? 1)
return UIImage(data: data, scale: scale)
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Nuke/Internal/Graphics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func makeThumbnail(data: Data, options: ImageRequest.ThumbnailOptions, scale: CG
} else {
orientation = .up
}
return PlatformImage(cgImage: image,
return PlatformImage(cgImage: image,
scale: scale,
orientation: orientation)
#else
Expand Down

0 comments on commit bd15e13

Please sign in to comment.