image.codec\lib\region.mbt
100% · 6 / 6 points · 21 linesBackground color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.
- 1
///| - 2
/// # 区域解码入口 Region decode entry - 3
/// - 4
/// 按魔数自动识别 PNG / BMP / QOI,只解码请求矩形。 - 5
pub fn decode_region( - 6
data : Bytes, - 7
x : Int32, - 8
y : Int32, - 9
w : Int32, - 10
h : Int32, - 11
) -> @types.Image raise @types.LoadError { - 12●
match detect_format(data) { - 13●
@types.ImageFormat::Png => @codec.decode_png_region(data, x, y, w, h) - 14●
@types.ImageFormat::Bmp => @codec.decode_bmp_region(data, x, y, w, h) - 15●
@types.ImageFormat::Qoi => @codec.decode_qoi_region(data, x, y, w, h) - 16
_ => - 17●
raise @types.LoadError::DecodeFailed( - 18
"decode_region 暂只支持 PNG / BMP / QOI", - 19
) - 20
} - 21
}