Skip to content

Commit 8e6702d

Browse files
committed
fix orietntation
1 parent 1979a47 commit 8e6702d

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

.swiftpm/xcode/xcuserdata/radzivonbartoshyk.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>JxlCoder.xcscheme_^#shared#^_</key>
1818
<dict>
1919
<key>orderHint</key>
20-
<integer>1</integer>
20+
<integer>0</integer>
2121
</dict>
2222
<key>jxlcoder.xcscheme_^#shared#^_</key>
2323
<dict>

Sources/jxlc/JxlInternalCoder.mm

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ static void JXLCGData8ProviderReleaseDataCallback(void *info, const void *data,
4141
delete dataWrapper;
4242
}
4343

44+
static inline float JXLGetDistance(const int quality)
45+
{
46+
if (quality == 0)
47+
return(1.0f);
48+
if (quality >= 30)
49+
return(0.1f+(float) (100-std::min(100.0f, (float)quality))*0.09f);
50+
return(6.24f+(float) pow(2.5f,(30.0-(float)quality)/5.0)/6.25f);
51+
}
52+
4453

4554
@implementation JxlInternalCoder
4655
- (nullable NSData *)encode:(nonnull JXLSystemImage *)platformImage
@@ -215,10 +224,18 @@ - (nullable JXLSystemImage *)decode:(nonnull NSInputStream *)inputStream
215224
return nil;
216225
}
217226

227+
if (jxlExposedOrientation == Rotate90CW || jxlExposedOrientation == Rotate90CCW
228+
|| jxlExposedOrientation == AntiTranspose
229+
|| jxlExposedOrientation == OrientTranspose) {
230+
size_t xz = xSize;
231+
xSize = ySize;
232+
ySize = xz;
233+
}
234+
218235
if (sampleSize.width > 0 && sampleSize.height > 0) {
219236
auto scaleResult = [RgbaScaler scaleData:outputData width:(int)xSize height:(int)ySize
220-
newWidth:(int)sampleSize.width newHeight:(int)sampleSize.height
221-
components:components pixelFormat:useFloats ? kF16 : kU8];
237+
newWidth:(int)sampleSize.width newHeight:(int)sampleSize.height
238+
components:components pixelFormat:useFloats ? kF16 : kU8];
222239
if (!scaleResult) {
223240
*error = [[NSError alloc] initWithDomain:@"JXLCoder" code:500 userInfo:@{ NSLocalizedDescriptionKey: @"Rescale image has failed" }];
224241
return nil;

Sources/jxlc/JxlWorker.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ bool DecodeJpegXlOneShot(const uint8_t *jxl, size_t size,
5858
return false;
5959
}
6060

61-
JxlDecoderSetKeepOrientation(dec.get(), JXL_TRUE);
6261
JxlDecoderSetUnpremultiplyAlpha(dec.get(), JXL_TRUE);
6362

6463
JxlBasicInfo info;

0 commit comments

Comments
 (0)