DynamicImage::crop()
is slow because to_image()
is slow
#2295
Labels
kind: API
missing or awkward public APIs
next: breaking
Information tag for PRs and ideas that require an interface break
In v0.25.2, the crop operation is implemented as:
image/src/dynimage.rs
Line 422 in e176cd4
which obtains a view into an image, and then calls
to_image()
on it to turn it into a new image buffer. Andto_image()
shuffles pixels one by one in a purely scalar fashion and with bounds checks on every pixel:image/src/image.rs
Lines 1131 to 1136 in e176cd4
A much better way would be iterating over the rows, and copying over entire rows with
slice::copy_from_slice()
. That would both leverage vector instructions and reduce the amount of bounds checks from n^2 to n.The text was updated successfully, but these errors were encountered: