pub enum Error {
TooLarge,
NormalFormRequired(NormalForm),
ChannelCountMismatch(u8, u8),
WrongColor(ColorType),
}
Expand description
Denotes invalid flat sample buffers when trying to convert to stricter types.
The biggest use case being ImageBuffer
which expects closely packed
samples in a row major matrix representation. But this error type may be
resused for other import functions. A more versatile user may also try to
correct the underlying representation depending on the error variant.
Variants§
TooLarge
The represented image was too large.
The optional value denotes a possibly accepted maximal bound.
NormalFormRequired(NormalForm)
The represented image can not use this representation.
Has an additional value of the normalized form that would be accepted.
ChannelCountMismatch(u8, u8)
The color format did not match the channel count.
In some cases you might be able to fix this by lowering the reported pixel count of the buffer without touching the strides.
In very special circumstances you may do the opposite. This is VERY dangerous but not
directly memory unsafe although that will likely alias pixels. One scenario is when you
want to construct an Rgba
image but have only 3 bytes per pixel and for some reason don’t
care about the value of the alpha channel even though you need Rgba
.
WrongColor(ColorType)
Deprecated - ChannelCountMismatch
is used instead