Parsing webp file header in Kotlin to get its height and width, but getting unexpected results

前端 未结 1 1199
旧时难觅i
旧时难觅i 2021-01-26 13:38

I am trying to read the WebP image header, according to the WebP Container Specification of Extended File Format.

fun g         


        
相关标签:
1条回答
  • 2021-01-26 14:29

    Don't know the Spec was incomplete or something, I logged the byte values and found a pattern somehow. And found that the dimensions are at 24-26 and 27-29 indexes.

    val width = 1 + (get24bit(data, 24))
    val height = 1 + (get24bit(data, 27))
    

    This does the trick! Hopefully it is helpful to note this point as long as documentation is not updated.

    0 讨论(0)
提交回复
热议问题