image-rs / canvas

An experimental allocated buffer suitable for image data (Rust library).
27 stars 3 forks source link

"Pitch"? #3

Closed crlf0710 closed 4 years ago

crlf0710 commented 5 years ago

Currently the code assumes that the rows are continuous. In reality, there might be Layouts that want to align the start of each row somehow, leaving some small gap between rows and at the end?

HeroicKatora commented 5 years ago

Gaps that are multiples of the element size may as well be handled through increasing the logical image size. But for other gaps, the elements no longer form a single slice as they are not contiguous in memory. As current DSTs in Rust can only represent contiguous memory, I have not yet found any way to nicely represent a reference to such a memory region that is as generic as a [T]-slice.

I realized a different variant of this problem: It could be very useful to view a rgba-image as an rgb-image without an alpha channel in some cases. Skipping the alpha channel to make this zerocopy leads to the exact same problem, as mem::size_of::<[u8; 3]> == 3 but the gap should have size 1.

crlf0710 commented 5 years ago

I think i see your position.