くうと徒然なるままに

モバイルアプリを作りながらバックエンドも作っています。

Bitmap を ByteArray に変換する拡張関数を書いた

   fun Bitmap.toByteArray(): ByteArray {
        val buffer = ByteBuffer.allocate(this.byteCount)
        this.copyPixelsToBuffer(buffer)
        return buffer.array()
    }