Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
imageio_core.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2009-2014 johannes hanika.
4 Copyright (C) 2011-2012, 2014-2017, 2019-2020 Tobias Ellinghaus.
5 Copyright (C) 2012 Richard Wonka.
6 Copyright (C) 2012-2014 Ulrich Pegelow.
7 Copyright (C) 2014 Jérémy Rosen.
8 Copyright (C) 2014-2016 Pedro Côrte-Real.
9 Copyright (C) 2014, 2016 Roman Lebedev.
10 Copyright (C) 2019 Philippe Weyland.
11 Copyright (C) 2020 Hanno Schwalm.
12 Copyright (C) 2020-2022 Pascal Obry.
13 Copyright (C) 2021 Daniel Vogelbacher.
14 Copyright (C) 2022 Aldric Renaudin.
15 Copyright (C) 2022, 2025 Aurélien PIERRE.
16 Copyright (C) 2022 Martin Bařinka.
17 Copyright (C) 2025 Alynx Zhou.
18 Copyright (C) 2026 Guillaume Stutin.
19
20 darktable is free software: you can redistribute it and/or modify
21 it under the terms of the GNU General Public License as published by
22 the Free Software Foundation, either version 3 of the License, or
23 (at your option) any later version.
24
25 darktable is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 GNU General Public License for more details.
29
30 You should have received a copy of the GNU General Public License
31 along with darktable. If not, see <http://www.gnu.org/licenses/>.
32*/
33
34#ifndef DT_IMAGEIO_IMAGEIO_CORE_H
35#define DT_IMAGEIO_IMAGEIO_CORE_H
36
37#include "system/atomic.h"
38#include "common/image.h"
40#include "caches/mipmap_cache.h"
41#include <glib.h>
42#include <stdio.h>
43#include <inttypes.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#define FILTERS_ARE_CYGM(filters) \
50 ((filters) == 0xb4b4b4b4 || (filters) == 0x4b4b4b4b || (filters) == 0x1e1e1e1e || (filters) == 0xe1e1e1e1)
51
52#define FILTERS_ARE_RGBE(filters) \
53 ((filters) == 0x63636363 || (filters) == 0x36363636 || (filters) == 0x9c9c9c9c || (filters) == 0xc9c9c9c9)
54
55// FIXME: kill this pls.
56#define FILTERS_ARE_4BAYER(filters) (FILTERS_ARE_CYGM(filters) || FILTERS_ARE_RGBE(filters))
57
58// for Adobe coefficients from LibRaw & RawSpeed
59#define ADOBE_COEFF_FACTOR 10000
60
75
76// Checks that the image is indeed an ldr image
77gboolean dt_imageio_is_ldr(const char *filename);
78// checks that the image has a monochrome preview attached
79gboolean dt_imageio_has_mono_preview(const char *filename);
80
81// opens the file using pfm, hdr, exr.
83// opens the file using jpeg, tiff, webp, png, j2k or pnm, in that order.
85// try all the options in sequence
87
108 dt_mipmap_buffer_t *buf);
109
115
124int dt_imageio_export(const int32_t imgid, const char *filename, struct dt_imageio_module_format_t *format,
125 struct dt_imageio_module_data_t *format_params, const double scale_factor,
126 const gboolean high_quality,
127 const gboolean copy_metadata, const gboolean export_masks,
128 dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
130 dt_imageio_module_data_t *storage_params, int num, int total, dt_export_metadata_t *metadata);
131
142dt_imageio_retval_t dt_imageio_export_with_flags(const int32_t imgid, const char *filename,
143 struct dt_imageio_module_format_t *format,
144 struct dt_imageio_module_data_t *format_params, const gboolean ignore_exif,
145 const gboolean display_byteorder, const gboolean high_quality, const double scale_factor,
146 const gboolean thumbnail_export, const gboolean ignore_history, const char *filter, const gboolean copy_metadata,
147 const gboolean export_masks, dt_colorspaces_color_profile_type_t icc_type,
148 const gchar *icc_filename, dt_iop_color_intent_t icc_intent,
150 int num, int total, dt_export_metadata_t *metadata,
151 dt_atomic_int *shutdown);
152
153// general, efficient buffer flipping function using memcopies
154void dt_imageio_flip_buffers(char *out, const char *in,
155 const size_t bpp, // bytes per pixel
156 const int wd, const int ht, const int fwd, const int fht, const int stride,
157 const dt_image_orientation_t orientation);
158
159void dt_imageio_flip_buffers_ui8_to_float(float *out, const uint8_t *in, const float black, const float white,
160 const int ch, const int wd, const int ht, const int fwd,
161 const int fht, const int stride,
162 const dt_image_orientation_t orientation);
163
177int dt_imageio_large_thumbnail(const char *filename, uint8_t **buffer, int32_t *th_width, int32_t *th_height,
179 const int height);
180
201gboolean dt_imageio_crop_thumbnail(const dt_boundingbox_t box, uint8_t *const buffer,
202 int32_t *width, int32_t *height);
203
204// lookup maker and model, dispatch lookup to rawspeed or libraw
205gboolean dt_imageio_lookup_makermodel(const char *maker, const char *model,
206 char *mk, int mk_len, char *md, int md_len,
207 char *al, int al_len);
208
209
210#ifdef __cplusplus
211}
212#endif
213
214#endif // DT_IMAGEIO_IMAGEIO_CORE_H
215
216// clang-format off
217// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
218// vim: shiftwidth=2 expandtab tabstop=2 cindent
219// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
220// clang-format on
atomic_int dt_atomic_int
Definition atomic.h:68
const dt_colormatrix_t dt_aligned_pixel_t out
dt_iop_roi_t in
Definition geometry.h:117
float dt_boundingbox_t[4]
Definition image.h:83
dt_image_orientation_t
Definition image.h:225
dt_imageio_retval_t
Return value of image io functions: loading, exporting, and making a thumbnail.
Definition image.h:97
int bpp
gboolean dt_imageio_is_ldr(const char *filename)
int dt_imageio_export(const int32_t imgid, const char *filename, struct dt_imageio_module_format_t *format, struct dt_imageio_module_data_t *format_params, const double scale_factor, const gboolean high_quality, const gboolean copy_metadata, const gboolean export_masks, dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename, dt_iop_color_intent_t icc_intent, dt_imageio_module_storage_t *storage, dt_imageio_module_data_t *storage_params, int num, int total, dt_export_metadata_t *metadata)
void dt_imageio_flip_buffers_ui8_to_float(float *out, const uint8_t *in, const float black, const float white, const int ch, const int wd, const int ht, const int fwd, const int fht, const int stride, const dt_image_orientation_t orientation)
gboolean dt_imageio_lookup_makermodel(const char *maker, const char *model, char *mk, int mk_len, char *md, int md_len, char *al, int al_len)
dt_imageio_retval_t dt_imageio_open(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
void dt_imageio_close_standalone(dt_mipmap_buffer_t *buf)
Release a buffer from dt_imageio_open_standalone(). NULL-safe, and safe to call on a buffer whose ope...
dt_imageio_retval_t dt_imageio_open_raster(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
dt_imageio_retval_t dt_imageio_open_standalone(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
Decode a file into a buffer the CALLER owns, with no cache involvement.
gboolean dt_imageio_has_mono_preview(const char *filename)
dt_imageio_levels_t
@ IMAGEIO_INT32
@ IMAGEIO_INT16
@ IMAGEIO_PREC_MASK
@ IMAGEIO_RGB
@ IMAGEIO_INT12
@ IMAGEIO_INT8
@ IMAGEIO_CHANNEL_MASK
@ IMAGEIO_GRAY
@ IMAGEIO_FLOAT
@ IMAGEIO_BW
gboolean dt_imageio_crop_thumbnail(const dt_boundingbox_t box, uint8_t *const buffer, int32_t *width, int32_t *height)
Crop an 8-bit RGBA preview buffer in place to a normalized bounding box.
void dt_imageio_flip_buffers(char *out, const char *in, const size_t bpp, const int wd, const int ht, const int fwd, const int fht, const int stride, const dt_image_orientation_t orientation)
dt_imageio_retval_t dt_imageio_open_hdr(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
dt_imageio_retval_t dt_imageio_export_with_flags(const int32_t imgid, const char *filename, struct dt_imageio_module_format_t *format, struct dt_imageio_module_data_t *format_params, const gboolean ignore_exif, const gboolean display_byteorder, const gboolean high_quality, const double scale_factor, const gboolean thumbnail_export, const gboolean ignore_history, const char *filter, const gboolean copy_metadata, const gboolean export_masks, dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename, dt_iop_color_intent_t icc_intent, dt_imageio_module_storage_t *storage, dt_imageio_module_data_t *storage_params, int num, int total, dt_export_metadata_t *metadata, dt_atomic_int *shutdown)
int dt_imageio_large_thumbnail(const char *filename, uint8_t **buffer, int32_t *th_width, int32_t *th_height, dt_colorspaces_color_profile_type_t *color_space, const int width, const int height)
Load the thumbnail embedded into a RAW file having at least the size MAX(width, height) x MAX(width,...
const char * maker
const char * model
float *const restrict const size_t const size_t ch
uint32_t width
Definition mipmap_cache.c:0
uint32_t height
Definition mipmap_cache.c:1
dt_colorspaces_color_profile_type_t color_space
Definition mipmap_cache.c:5
dt_iop_color_intent_t
ICC rendering intent, as stored in iop params and in conf.
dt_colorspaces_color_profile_type_t