-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A little bit of updated logic for compression quality
- Loading branch information
1 parent
b5f964a
commit 4deb7cc
Showing
18 changed files
with
93 additions
and
73 deletions.
There are no files selected for viewing
67 changes: 38 additions & 29 deletions
67
Sources/SnapshotTestingHEIC/HEIC/CompressionQuality.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,44 @@ | ||
import Foundation | ||
|
||
public struct CompressionQuality: ExpressibleByFloatLiteral { | ||
public typealias FloatLiteralType = Float | ||
|
||
public let value: Float | ||
|
||
public init(floatLiteral value: Float) { | ||
self.value = value | ||
} | ||
|
||
public init(_ value: Float) { | ||
self.value = value | ||
} | ||
|
||
public static var lossless: CompressionQuality { | ||
return 1.0 | ||
} | ||
public enum CompressionQuality: Hashable, RawRepresentable { | ||
case lossless | ||
case low | ||
case medium | ||
case high | ||
case maximum | ||
case custom(CGFloat) | ||
|
||
public static var low: CompressionQuality { | ||
return 0.8 | ||
public init?(rawValue: CGFloat) { | ||
switch rawValue { | ||
case 1.0: | ||
self = .lossless | ||
case 0.8: | ||
self = .low | ||
case 0.5: | ||
self = .medium | ||
case 0.2: | ||
self = .high | ||
case 0.0: | ||
self = .maximum | ||
default: | ||
self = .custom(rawValue) | ||
} | ||
} | ||
|
||
public static var medium: CompressionQuality { | ||
return 0.5 | ||
} | ||
|
||
public static var high: CompressionQuality { | ||
return 0.2 | ||
} | ||
|
||
public static var maximum: CompressionQuality { | ||
return 0.0 | ||
|
||
public var rawValue: CGFloat { | ||
switch self { | ||
case .lossless: | ||
return 1.0 | ||
case .low: | ||
return 0.8 | ||
case .medium: | ||
return 0.5 | ||
case .high: | ||
return 0.2 | ||
case .maximum: | ||
return 0.0 | ||
case let .custom(value): | ||
return value | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+1.09 KB
(120%)
...s/SnapshotTestingHEICTests/__Snapshots__/SnapshotTestingHEICTests/test_HEIC_NSView.1.heic
Binary file not shown.
Binary file modified
BIN
+11 Bytes
(100%)
...ICTests/__Snapshots__/SnapshotTestingHEICTests/test_HEIC_compressionQuality_custom.1.heic
Binary file not shown.
Binary file added
BIN
+16.4 KB
...s/__Snapshots__/SnapshotTestingHEICTests/test_HEIC_compressionQuality_custom_minus.1.heic
Binary file not shown.
Binary file modified
BIN
-5.76 KB
(74%)
...Tests/__Snapshots__/SnapshotTestingHEICTests/test_HEIC_compressionQuality_lossless.1.heic
Binary file not shown.
Binary file modified
BIN
+11 Bytes
(100%)
...CTests/__Snapshots__/SnapshotTestingHEICTests/test_HEIC_compressionQuality_maximum.1.heic
Binary file not shown.
Binary file modified
BIN
+11 Bytes
(100%)
...ICTests/__Snapshots__/SnapshotTestingHEICTests/test_HEIC_compressionQuality_medium.1.heic
Binary file not shown.
Binary file modified
BIN
-9.73 KB
(65%)
...__Snapshots__/SnapshotTestingHEICTests/test_swiftui_HEIC_compressionQuality_custom.1.heic
Binary file not shown.
Binary file modified
BIN
-20.7 KB
(48%)
...Snapshots__/SnapshotTestingHEICTests/test_swiftui_HEIC_compressionQuality_lossless.1.heic
Binary file not shown.
Binary file modified
BIN
-5.8 KB
(59%)
..._Snapshots__/SnapshotTestingHEICTests/test_swiftui_HEIC_compressionQuality_maximum.1.heic
Binary file not shown.
Binary file modified
BIN
-7.77 KB
(63%)
...__Snapshots__/SnapshotTestingHEICTests/test_swiftui_HEIC_compressionQuality_medium.1.heic
Binary file not shown.
Binary file modified
BIN
-20.7 KB
(48%)
...tTestingHEICTests/__Snapshots__/SnapshotTestingHEICTests/test_swiftui_without_HEIC.1.heic
Binary file not shown.
Binary file modified
BIN
+12 Bytes
(100%)
...TestingHEICTests/__Snapshots__/SnapshotTestingHEICTests/test_without_HEIC.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.