Opt in for ExperimentalUnsignedTypes

This commit is contained in:
Sven Weidauer 2024-12-01 12:16:58 +01:00
parent b0a4f766b4
commit 35ddb2166c

View file

@ -5,6 +5,7 @@ const val BYTES_PER_PIXEL = 4
data class Color(val r: UByte, val g: UByte, val b: UByte, val alpha: UByte = UByte.MAX_VALUE) data class Color(val r: UByte, val g: UByte, val b: UByte, val alpha: UByte = UByte.MAX_VALUE)
@OptIn(ExperimentalUnsignedTypes::class)
class Bitmap(val width: Int, val height: Int) { class Bitmap(val width: Int, val height: Int) {
val data = UByteArray(width * height * BYTES_PER_PIXEL) val data = UByteArray(width * height * BYTES_PER_PIXEL)
@ -27,6 +28,7 @@ class Bitmap(val width: Int, val height: Int) {
} }
} }
@OptIn(ExperimentalUnsignedTypes::class)
fun File.writeBitmap(bitmap: Bitmap) { fun File.writeBitmap(bitmap: Bitmap) {
outputStream().use { stream -> outputStream().use { stream ->
stream.write(0) // ID length stream.write(0) // ID length