-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix calling toBitmap with an underlying hardware bitmap. (#2645)
- Loading branch information
1 parent
dd7ddf3
commit d019ce1
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
coil-core/src/androidInstrumentedTest/kotlin/coil3/ImageAndroidTest.kt
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package coil3 | ||
|
||
import android.graphics.Bitmap | ||
import android.graphics.BitmapFactory | ||
import android.os.Build.VERSION.SDK_INT | ||
import coil3.core.test.R | ||
import coil3.test.utils.assumeTrue | ||
import coil3.test.utils.context | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertSame | ||
import org.junit.Test | ||
|
||
class ImageAndroidTest { | ||
|
||
/** Regression test: https://github.com/coil-kt/coil/issues/2644 */ | ||
@Test | ||
fun toBitmap_hardware() { | ||
assumeTrue(SDK_INT >= 26) | ||
|
||
// Decode a resource since we can't create a test hardware bitmap directly. | ||
val options = BitmapFactory.Options().apply { | ||
inPreferredConfig = Bitmap.Config.HARDWARE | ||
} | ||
val bitmap = BitmapFactory.decodeResource(context.resources, R.drawable.normal, options) | ||
|
||
assertEquals(Bitmap.Config.HARDWARE, bitmap.config) | ||
assertSame(bitmap, bitmap.asImage().toBitmap()) | ||
} | ||
} |
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