/* Copyright 2020, Dirk Krause. All rights reserved. SPDX-License-Identifier: BSD-3-Clause */ /** @file dk4bifty.h Type definitions for bitmap image files. */ #ifndef DK4BIFTY_H_INCLUDED /** Protection against multiple inclusions. */ #define DK4BIFTY_H_INCLUDED 1 #ifndef DK4CONF_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4conf.h" #else #include #endif #endif #ifndef DK4TYPES_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4types.h" #else #include #endif #endif #ifndef DK4ERROR_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4error.h" #else #include #endif #endif #ifndef DK4STO_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4sto.h" #else #include #endif #endif #ifndef DK4PX_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4px.h" #else #include #endif #endif #ifndef DK4PXRES_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4pxres.h" #else #include #endif #endif #ifndef DK4CS_H_INCLUDED #if DK4_BUILDING_DKTOOLS4 #include "dk4cs.h" #else #include #endif #endif /** Image dimension and coordinate specifcation. */ typedef long dk4_bif_dim_t; /** Image file type. */ enum { DK4_BIF_TYPE_PNG = 0, /**< PNG image. */ DK4_BIF_TYPE_JPEG , /**< JPEG image. */ DK4_BIF_TYPE_TIFF , /**< TIFF image. */ DK4_BIF_TYPE_NETPBM , /**< NetPBM image. */ DK4_BIF_TYPE_MIN = DK4_BIF_TYPE_PNG , /**< Minimum value. */ DK4_BIF_TYPE_MAX = DK4_BIF_TYPE_NETPBM /**< Maximum value. */ }; /** One frame from image. The l_cs component is the color space the image reading library returned, possibly after applying transformations to the image data. The f_cs component is the original color space used in the image file. The bg array contains a background color suggested in the image file if there is partial transparency. If l_cs is DK4_CS_GRAY_ALPHA there is only one gray component in the array. If l_cs is DK4_CS_RGB_ALPHA there are red, green and blue components. */ typedef struct { dk4_px_t bg[4]; /**< Background data, output bit depth. */ dk4_px_t bglbd[4]; /**< Background data, original bit depth. */ dk4_px_resample_t resampler; /**< Bit depth resampler. */ void *tsdata; /**< Type-specific data per frame. */ double res_x; /**< X resolution in dpi (dots per inch). */ double res_y; /**< Y resolution in dpi (dots per inch). */ size_t fno; /**< Frame number. */ size_t n_comp; /**< Number of color components. */ dk4_bif_dim_t dim_x; /**< Image width (number of pixels). */ dk4_bif_dim_t dim_y; /**< Image height (number of pixels). */ int l_cs; /**< Color space returned by library. */ int f_cs; /**< Color space in file. */ int hbg; /**< Flag: Background chunk in file. */ int fmres; /**< Flag: Must resample, unusual maxval. */ dk4_px_t fmrmv; /**< Unusual maxval value of frame. */ dk4_px_bit_depth_t l_bdepth; /**< Original bit depth from image file. */ dk4_px_bit_depth_t r_bdepth; /**< Required output bit depth. */ } dk4_bif_frame_t; /** Bitmap image file. */ typedef struct { dk4_cs_conv_ctx_t cs_ctx; /**< Color space conversion context. */ void *tsdata; /**< Type-specific data per file. */ dk4_sto_t *s_frames; /**< Container to store frames. */ dk4_sto_it_t *i_frames; /**< Iterator for frames container. */ dkChar *filename; /**< Name of image file. */ dk4_bif_frame_t *cf; /**< Current frame to process. */ size_t n_frames; /**< Number of frames in image. */ int imgtype; /**< Image type. */ int hdronly; /**< Flag: Read header information only. */ } dk4_bif_t; /** Allowed difference in aspect ratio when setting custom resolution. */ #define DK4_BIF_EPSILON_ASPECT (1.0e-5) #endif /* ifndef DK4BIFTY_H_INCLUDED */ /* vim: set ai sw=4 ts=4 : */