Closed carmocca closed 7 years ago
@carmocca hey, I'm glad you've found my library useful!
I've found the source of this bug for some time ago, just haven't enough time was too lazy to fix it. You're more than welcome to send the PR with this(or any other) fix any time you want, I'll be happy to merge it and close one of the issues.
And also thank you for your contribution!
First of all, i would like to thank you for such a nice library.
I have found the source for the error you talk about in #6, specifically the one about files bigger than ~10MB. It is caused by an integer overflow in the line
val currentDataIndex = targetSize * index / data.size
from here. Specifically thetargetSize * index
multiplication. I'm not sure about why doesn't an IndexOutOfBoundsException appear when accesing the arraytargetSized[prevDataIndex]
but i don't know much Kotlin.It can be easily solved by casting index to long and the result to int as in
(targetSize * index.toLong() / data.size).toInt()
if you don't want to tweak the algorithm behindindex
values.I would like to create the pull request if you are fine with it.
As a side note, the purpose of
setScaledData()
could be explained a little better, to me, it wasn't clear if you meant scaled as in values or size.Thank you.