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
19 darktable is free software: you can redistribute it and/or modify
20 it under the terms of the GNU General Public License as published by
21 the Free Software Foundation, either version 3 of the License, or
22 (at your option) any later version.
23
24 darktable is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 GNU General Public License for more details.
28
29 You should have received a copy of the GNU General Public License
30 along with darktable. If not, see <http://www.gnu.org/licenses/>.
31*/
32
33#ifndef DT_IMAGEIO_IMAGEIO_CORE_H
34#define DT_IMAGEIO_IMAGEIO_CORE_H
35
36#include "system/atomic.h"
37#include "common/image.h"
39#include "caches/mipmap_cache.h"
40#include <glib.h>
41#include <stdio.h>
42#include <inttypes.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#define FILTERS_ARE_CYGM(filters) \
49 ((filters) == 0xb4b4b4b4 || (filters) == 0x4b4b4b4b || (filters) == 0x1e1e1e1e || (filters) == 0xe1e1e1e1)
50
51#define FILTERS_ARE_RGBE(filters) \
52 ((filters) == 0x63636363 || (filters) == 0x36363636 || (filters) == 0x9c9c9c9c || (filters) == 0xc9c9c9c9)
53
54// FIXME: kill this pls.
55#define FILTERS_ARE_4BAYER(filters) (FILTERS_ARE_CYGM(filters) || FILTERS_ARE_RGBE(filters))
56
57// for Adobe coefficients from LibRaw & RawSpeed
58#define ADOBE_COEFF_FACTOR 10000
59
74
75// Checks that the image is indeed an ldr image
76gboolean dt_imageio_is_ldr(const char *filename);
77// checks that the image has a monochrome preview attached
78gboolean dt_imageio_has_mono_preview(const char *filename);
79
80// opens the file using pfm, hdr, exr.
82// opens the file using jpeg, tiff, webp, png, j2k or pnm, in that order.
84// try all the options in sequence
86
107 dt_mipmap_buffer_t *buf);
108
114
117int dt_imageio_export(const int32_t imgid, const char *filename, struct dt_imageio_module_format_t *format,
118 struct dt_imageio_module_data_t *format_params, const gboolean high_quality,
119 const gboolean copy_metadata, const gboolean export_masks,
120 dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
122 dt_imageio_module_data_t *storage_params, int num, int total, dt_export_metadata_t *metadata);
123
124int dt_imageio_export_with_flags(const int32_t imgid, const char *filename,
125 struct dt_imageio_module_format_t *format,
126 struct dt_imageio_module_data_t *format_params, const gboolean ignore_exif,
127 const gboolean display_byteorder, const gboolean high_quality, gboolean is_scaling,
128 const gboolean thumbnail_export, const char *filter, const gboolean copy_metadata,
129 const gboolean export_masks, dt_colorspaces_color_profile_type_t icc_type,
130 const gchar *icc_filename, dt_iop_color_intent_t icc_intent,
132 int num, int total, dt_export_metadata_t *metadata,
133 dt_atomic_int *shutdown);
134
135// general, efficient buffer flipping function using memcopies
136void dt_imageio_flip_buffers(char *out, const char *in,
137 const size_t bpp, // bytes per pixel
138 const int wd, const int ht, const int fwd, const int fht, const int stride,
139 const dt_image_orientation_t orientation);
140
141void dt_imageio_flip_buffers_ui8_to_float(float *out, const uint8_t *in, const float black, const float white,
142 const int ch, const int wd, const int ht, const int fwd,
143 const int fht, const int stride,
144 const dt_image_orientation_t orientation);
145
159int dt_imageio_large_thumbnail(const char *filename, uint8_t **buffer, int32_t *th_width, int32_t *th_height,
161 const int height);
162
183gboolean dt_imageio_crop_thumbnail(const dt_boundingbox_t box, uint8_t *const buffer,
184 int32_t *width, int32_t *height);
185
186// lookup maker and model, dispatch lookup to rawspeed or libraw
187gboolean dt_imageio_lookup_makermodel(const char *maker, const char *model,
188 char *mk, int mk_len, char *md, int md_len,
189 char *al, int al_len);
190
191
192#ifdef __cplusplus
193}
194#endif
195
196#endif // DT_IMAGEIO_IMAGEIO_CORE_H
197
198// clang-format off
199// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
200// vim: shiftwidth=2 expandtab tabstop=2 cindent
201// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
202// clang-format on
atomic_int dt_atomic_int
Definition atomic.h:68
const dt_colormatrix_t dt_aligned_pixel_t out
float dt_boundingbox_t[4]
Definition image.h:83
dt_image_orientation_t
Definition image.h:216
dt_imageio_retval_t
Definition image.h:91
int bpp
gboolean dt_imageio_is_ldr(const char *filename)
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.
int 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, gboolean is_scaling, const gboolean thumbnail_export, 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)
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)
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 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)
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