1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
use super::*; pub trait FloatOrU16: Sized + Copy { unsafe fn eval_tone_curve(self, handle: *const ffi::ToneCurve) -> Self; unsafe fn eval_pipeline(handle: *const ffi::Pipeline, input: &[Self], out: &mut [Self]); unsafe fn stage_alloc_clut(contextid: ffi::Context, ngridpoints: u32, inputchan: u32, outputchan: u32, table: *const Self) -> *mut ffi::Stage; } impl FloatOrU16 for f32 { #[inline] unsafe fn eval_tone_curve(self, handle: *const ffi::ToneCurve) -> Self { ffi::cmsEvalToneCurveFloat(handle, self) } #[inline] unsafe fn eval_pipeline(handle: *const ffi::Pipeline, input: &[Self], out: &mut [Self]) { ffi::cmsPipelineEvalFloat(input.as_ptr(), out.as_mut_ptr(), handle) } #[inline] unsafe fn stage_alloc_clut(contextid: ffi::Context, ngridpoints: u32, inputchan: u32, outputchan: u32, table: *const Self) -> *mut ffi::Stage { ffi::cmsStageAllocCLutFloat(contextid, ngridpoints, inputchan, outputchan, table) } } impl FloatOrU16 for u16 { #[inline] unsafe fn eval_tone_curve(self, handle: *const ffi::ToneCurve) -> Self { ffi::cmsEvalToneCurve16(handle, self) } #[inline] unsafe fn eval_pipeline(handle: *const ffi::Pipeline, input: &[Self], out: &mut [Self]) { ffi::cmsPipelineEval16(input.as_ptr(), out.as_mut_ptr(), handle) } #[inline] unsafe fn stage_alloc_clut(contextid: ffi::Context, ngridpoints: u32, inputchan: u32, outputchan: u32, table: *const Self) -> *mut ffi::Stage { ffi::cmsStageAllocCLut16bit(contextid, ngridpoints, inputchan, outputchan, table) } }