/* Copyright (C) 2017-2020, Dirk Krause SPDX-License-Identifier: BSD-3-Clause */ /* WARNING: This file was generated by the dkct program (see http://dktools.sourceforge.net/ for details). Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: dk4pxres.ctr */ #ifndef DK4PXRES_H_INCLUDED /** Avoid multiple inclusions. */ #define DK4PXRES_H_INCLUDED 1 #line 9 "dk4pxres.ctr" /** @file dk4pxres.h Pixel resampling. */ #ifndef DK4CONF_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4conf.h" #else #include #endif #endif #ifndef DK4PXBIT_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4pxbit.h" #else #include #endif #endif /** Structure to resample pixels. */ typedef struct { unsigned long nom; /**< Nominator in scale factor. */ unsigned long denom; /**< Denominator in scale factor. */ unsigned long denom2; /**< Half of the denominator. */ } dk4_px_resample_t; #ifdef __cplusplus extern "C" { #endif /** Initialize resampler structure. @param pxrptr Resampler structure to initialize. */ void dk4pxres_init(dk4_px_resample_t *pxrptr); /** Set up resample structure for conversions. @param pxrptr Resample structure to set up. @param ibits Number of input bits. @param obits Number of output (result) bits. @return 1 on success, 0 on error. */ int dk4pxres_setup( dk4_px_resample_t *pxrptr, size_t ibits, size_t obits ); /** Set up resample structure for conversions for unusual maxval values. Input is from a range with unusual maxval, output is prepared for a given bit depth. @param pxrptr Resample structure to set up. @param imaxval Maximum value for input pixel data. @param obits Number of output (result) bits. @return 1 on success, 0 on error. */ int dk4pxres_setup_from_maxval( dk4_px_resample_t *pxrptr, dk4_px_t imaxval, size_t obits ); /** Set up resample structure for conversions for unusual maxval values. Input has a given bit depth, output must be in the range up to s specified maxval. @param pxrptr Resample structure to set up. @param ibits Input bit depth. @param omaxval Maximum value for output pixel data. @return 1 on success, 0 on error. */ int dk4pxres_setup_to_maxval( dk4_px_resample_t *pxrptr, size_t ibits, dk4_px_t omaxval ); /** Resample pixel component from old bit width to new bit width. @param pxrptr Resample structure to use. @param in Component value in old bit depth. @return Resampling result (component value in new bit depth). */ dk4_px_t dk4pxres_get( dk4_px_resample_t const *pxrptr, dk4_px_t in ); /** Check whether a component value can be resampled without quality loss. @param pxrptr Resample structure to use. @param in Component value in old bit depth. @return 1 on success (no division remainder), 0 on error (skipped division remainder results in quality loss). */ int dk4pxres_check( dk4_px_resample_t const *pxrptr, dk4_px_t in ); /** Resample multiple values to new bit depth. @param dptr Array containing values to resample, results on output. @param dsz Number of elements in array. @param pxrptr Resample structure to use. @return 1 on success, 0 on error. */ int dk4pxres_multiple( dk4_px_t *dptr, size_t dsz, dk4_px_resample_t const *pxrptr ); #ifdef __cplusplus } #endif /* vim: set ai sw=4 ts=4 : */ #endif