@onekeyfe/react-native-image 3.0.130 → 3.0.131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -145,7 +145,8 @@ internal data class OneKeyImageDecodeDimensions(
145
145
  /**
146
146
  * Downsamples static bitmaps for the target while independently enforcing the
147
147
  * 16 MiB area cap. `override()` alone cannot enforce an area cap for very wide
148
- * or tall sources because Glide's default strategy follows target edges.
148
+ * or tall sources because Glide's default strategy follows target edges. Quality
149
+ * rounding keeps Glide's power-of-two sample from decoding below the target.
149
150
  */
150
151
  internal object OneKeyImageSafeDownsampleStrategy : DownsampleStrategy() {
151
152
  override fun getScaleFactor(
@@ -165,5 +166,5 @@ internal object OneKeyImageSafeDownsampleStrategy : DownsampleStrategy() {
165
166
  sourceHeight: Int,
166
167
  requestedWidth: Int,
167
168
  requestedHeight: Int,
168
- ): SampleSizeRounding = SampleSizeRounding.MEMORY
169
+ ): SampleSizeRounding = SampleSizeRounding.QUALITY
169
170
  }
@@ -1,5 +1,6 @@
1
1
  package com.margelo.nitro.onekeyimage
2
2
 
3
+ import com.bumptech.glide.load.resource.bitmap.DownsampleStrategy.SampleSizeRounding
3
4
  import org.junit.Assert.assertEquals
4
5
  import org.junit.Assert.assertTrue
5
6
  import org.junit.Test
@@ -69,6 +70,14 @@ class OneKeyImageDecodeDimensionsTest {
69
70
  assertTrue(decodedBytes <= OneKeyImageDecodeDimensions.MAX_DECODE_BYTES)
70
71
  }
71
72
 
73
+ @Test
74
+ fun safeDownsampleStrategyPrefersQualityOverUndersizedDecodes() {
75
+ assertEquals(
76
+ SampleSizeRounding.QUALITY,
77
+ OneKeyImageSafeDownsampleStrategy.getSampleSizeRounding(160, 160, 55, 55),
78
+ )
79
+ }
80
+
72
81
  @Test
73
82
  fun safeDownsampleStrategyIsSingletonForStableMemoryCacheIdentity() {
74
83
  val strategyClass = Class.forName(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-image",
3
- "version": "3.0.130",
3
+ "version": "3.0.131",
4
4
  "description": "High-performance native image view for OneKey",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -81,7 +81,7 @@
81
81
  "typescript": "^5.9.2"
82
82
  },
83
83
  "peerDependencies": {
84
- "@onekeyfe/react-native-skeleton": "3.0.130",
84
+ "@onekeyfe/react-native-skeleton": "3.0.131",
85
85
  "react": "*",
86
86
  "react-native": "*",
87
87
  "react-native-nitro-modules": "0.37.0"