Skip to content

Commit bef2873

Browse files
committed
added scale parameter
1 parent bae8c01 commit bef2873

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

JxlCoder.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'JxlCoder'
3-
s.version = '1.3.4'
3+
s.version = '1.3.5'
44
s.summary = 'JXL coder for iOS and MacOS'
55
s.description = 'Provides support for JXL files in iOS and MacOS'
66
s.homepage = 'https://github.com/awxkee/jxl-coder-swift'

Sources/JxlCoder/JXLCoder.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ public class JXLCoder {
5555
**/
5656
public static func decode(srcStream: InputStream,
5757
rescale: CGSize = .zero,
58+
scale: Int = 1,
5859
pixelFormat: JXLPreferredPixelFormat = .optimal,
5960
sampler: JxlSampler = .hann) throws -> JXLPlatformImage {
60-
return try shared.decode(srcStream, rescale: rescale, pixelFormat: pixelFormat, sampler: sampler)
61+
return try shared.decode(srcStream, rescale: rescale, pixelFormat: pixelFormat, sampler: sampler, scale: Int32(scale))
6162
}
6263

6364
/***
@@ -66,13 +67,14 @@ public class JXLCoder {
6667
**/
6768
public static func decode(url: URL,
6869
rescale: CGSize = .zero,
70+
scale: Int = 1,
6971
pixelFormat: JXLPreferredPixelFormat = .optimal,
7072
sampler: JxlSampler = .lanczos) throws -> JXLPlatformImage {
7173
guard let srcStream = InputStream(url: url) else {
7274
throw NSError(domain: "JXLCoder", code: 500,
7375
userInfo: [NSLocalizedDescriptionKey: "JXLCoder cannot open provided URL"])
7476
}
75-
return try shared.decode(srcStream, rescale: rescale, pixelFormat: pixelFormat, sampler: sampler)
77+
return try shared.decode(srcStream, rescale: rescale, pixelFormat: pixelFormat, sampler: sampler, scale: Int32(scale))
7678
}
7779

7880
/***
@@ -81,10 +83,11 @@ public class JXLCoder {
8183
**/
8284
public static func decode(data: Data,
8385
rescale: CGSize = .zero,
86+
scale: Int = 1,
8487
pixelFormat: JXLPreferredPixelFormat = .optimal,
8588
sampler: JxlSampler = .lanczos) throws -> JXLPlatformImage {
8689
let srcStream = InputStream(data: data)
87-
return try shared.decode(srcStream, rescale: rescale, pixelFormat: pixelFormat, sampler: sampler)
90+
return try shared.decode(srcStream, rescale: rescale, pixelFormat: pixelFormat, sampler: sampler, scale: Int32(scale))
8891
}
8992

9093
/***

Sources/jxlc/JxlInternalCoder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@
3232
#import "CJpegXLAnimatedDecoder.h"
3333

3434
@interface JxlInternalCoder: NSObject
35-
- (nullable JXLSystemImage *)decode:(nonnull NSInputStream *)inputStream
35+
- (nullable JXLSystemImage *)decode:(nonnull NSInputStream *)inputStream
3636
rescale:(CGSize)rescale
3737
pixelFormat:(JXLPreferredPixelFormat)preferredPixelFormat
3838
sampler:(JxlSampler)sampler
39+
scale:(int)scale
3940
error:(NSError *_Nullable * _Nullable)error;
4041
- (CGSize)getSize:(nonnull NSInputStream *)inputStream error:(NSError *_Nullable * _Nullable)error;
4142
- (nullable NSData *)encode:(nonnull JXLSystemImage *)platformImage

Sources/jxlc/JxlInternalCoder.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ - (nullable JXLSystemImage *)decode:(nonnull NSInputStream *)inputStream
194194
rescale:(CGSize)rescale
195195
pixelFormat:(JXLPreferredPixelFormat)preferredPixelFormat
196196
sampler:(JxlSampler)sampler
197+
scale:(int)scale
197198
error:(NSError *_Nullable * _Nullable)error {
198199
try {
199200
int buffer_length = 30196;
@@ -384,7 +385,7 @@ - (nullable JXLSystemImage *)decode:(nonnull NSInputStream *)inputStream
384385
#if JXL_PLUGIN_MAC
385386
image = [[NSImage alloc] initWithCGImage:imageRef size:CGSizeZero];
386387
#else
387-
image = [UIImage imageWithCGImage:imageRef scale:1 orientation:UIImageOrientationUp];
388+
image = [UIImage imageWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp];
388389
#endif
389390

390391
return image;

0 commit comments

Comments
 (0)