mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
map lcms error
This commit is contained in:
parent
50bee86fd5
commit
1429013dd1
3 changed files with 7 additions and 6 deletions
|
@ -365,14 +365,12 @@ where
|
|||
&output_icc_profile,
|
||||
pixel_format,
|
||||
output_icc_profile.header_rendering_intent(),
|
||||
);
|
||||
)
|
||||
.map_err(CanvasError::Lcms)
|
||||
.unwrap();
|
||||
|
||||
for (x, y, mut pixel) in image.pixels() {
|
||||
let pixel = match transformer {
|
||||
Ok(ref transformer) => pixel.transform_color_profile(transformer),
|
||||
// This arm will reach when the ffi call fails.
|
||||
Err(_) => pixel,
|
||||
};
|
||||
let pixel = pixel.transform_color_profile(&transformer);
|
||||
|
||||
out.put_pixel(x, y, pixel);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ pub enum CanvasError {
|
|||
#[error("Cannot decode image '{0}'")]
|
||||
InvalidImage(String),
|
||||
#[error(transparent)]
|
||||
Lcms(#[from] lcms2::Error),
|
||||
#[error(transparent)]
|
||||
/// This error will be mapped to TypeError.
|
||||
Image(#[from] image::ImageError),
|
||||
}
|
||||
|
|
|
@ -603,6 +603,7 @@ fn get_canvas_error(e: &CanvasError) -> &'static str {
|
|||
match e {
|
||||
CanvasError::UnsupportedColorType(_) => "TypeError",
|
||||
CanvasError::InvalidImage(_) => "DOMExceptionInvalidStateError",
|
||||
CanvasError::Lcms(_) => "TypeError",
|
||||
CanvasError::Image(_) => "TypeError",
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue