walkzzz/image.core/types does not have a README file
pub(open) trait ImageLike {
fn width(Self) -> Int
fn height(Self) -> Int
fn channels(Self) -> Int
fn data(Self) -> Bytes
fn bytes_per_pixel(Self) -> Int
fn pixel_count(Self) -> Int = _
fn byte_count(Self) -> Int = _
fn is_grayscale(Self) -> Bool = _
fn is_rgb(Self) -> Bool = _
fn is_rgba(Self) -> Bool = _
}pub(all) suberror LoadError {
FileIO(String)
UnsupportedFormat(String)
DecodeFailed(String)
EncodeFailed(String)
}pub(all) struct AllocBudget {
max_bytes : Int64
}fn AllocBudget::check_image(self : AllocBudget, width : Int64, height : Int64, channels : Int64, what : String) -> Unit raise ImageErrorpub(all) struct DecodeLimits {
max_pixels : Int64
max_bytes : Int64
max_ms : Int64
}fn DecodeLimits::check_pixels(self : DecodeLimits, width : Int64, height : Int64) -> Unit raise ImageErrorlet DOC_TEST_BMP_1X1 : Byteslet DOC_TEST_PNG_1X1_RGBA : Byteslet DOC_TEST_PNM_1X1 : Byteslet DOC_TEST_QOI_1X1 : Byteslet MAX_IMAGE_DIMENSION : Intlet MAX_TOTAL_PIXELS : Inttest "doc_check_dims_valid" {
@types.check_dims(1, 1, 3)
assert_true(true)
}test "doc_check_dims_total_pixels_ok" {
@types.check_dims(25000, 20000, 3) // 5e8 边界内(总像素上限 5 亿)
assert_true(true)
}test "doc_check_dims_total_pixels_exceeded" {
try {
@types.check_dims(25001, 20000, 3) // 500,020,000 > 5e8
assert_true(false)
} catch {
@types.LoadError::DecodeFailed(_) => assert_true(true)
_ => assert_true(false)
}
}fn clamp_byte(Int) -> Bytefn clamp_coord(Int, Int) -> Intfn clamp_double(Double, Double, Double) -> Doublefn clamp_float(Float, Float, Float) -> Floatfn clamp_int(Int, Int, Int) -> Intfn clamp_pixel_value(Int) -> Intfn dims_valid_check(Int, Int, Int) -> Boolfn image_error_hint(code : String) -> Stringfn int_max(Int, Int) -> Intfn int_min(Int, Int) -> Intfn safe_mul(Int, Int) -> Int?fn safe_mul3(Int, Int, Int) -> Int?Install
Download zipMoonBit image core types: Image, Image16, ImageF, LoadError, traits.