Skip to content

Commit

Permalink
renderscript consider yuv type
Browse files Browse the repository at this point in the history
  • Loading branch information
gordinmitya committed Aug 1, 2020
1 parent 5760011 commit 2ecaab9
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ class RenderScriptConverter(context: Context) : ImageConverter {
|| input!!.type.yuv != converted.type.format
|| bytes.size != converted.buffer.capacity()
) {
val yuvFormat = when (converted.type) {
Yuv.Type.YUV_I420 -> ImageFormat.YUV_420_888
Yuv.Type.YUV_NV21 -> ImageFormat.NV21
}
val yuvType: Type.Builder = Type.Builder(rs, Element.U8(rs))
.setX(image.width)
.setY(image.height)
.setYuvFormat(ImageFormat.NV21)
.setYuvFormat(yuvFormat)
input = Allocation.createTyped(rs, yuvType.create(), Allocation.USAGE_SCRIPT)
bytes = ByteArray(converted.buffer.capacity())
val rgbaType: Type.Builder = Type.Builder(rs, Element.RGBA_8888(rs))
Expand Down

0 comments on commit 2ecaab9

Please sign in to comment.