Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
imageio.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#pragma once
34
35#include "common/image.h"
37#include "common/mipmap_cache.h"
38#include "common/tags.h"
39#include <glib.h>
40#include <stdio.h>
41#include <inttypes.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47#define FILTERS_ARE_CYGM(filters) \
48 ((filters) == 0xb4b4b4b4 || (filters) == 0x4b4b4b4b || (filters) == 0x1e1e1e1e || (filters) == 0xe1e1e1e1)
49
50#define FILTERS_ARE_RGBE(filters) \
51 ((filters) == 0x63636363 || (filters) == 0x36363636 || (filters) == 0x9c9c9c9c || (filters) == 0xc9c9c9c9)
52
53// FIXME: kill this pls.
54#define FILTERS_ARE_4BAYER(filters) (FILTERS_ARE_CYGM(filters) || FILTERS_ARE_RGBE(filters))
55
56// for Adobe coefficients from LibRaw & RawSpeed
57#define ADOBE_COEFF_FACTOR 10000
58
73
74// Checks that the image is indeed an ldr image
75gboolean dt_imageio_is_ldr(const char *filename);
76// checks that the image has a monochrome preview attached
77gboolean dt_imageio_has_mono_preview(const char *filename);
78// Set the ansel/mode/hdr tag
80// Update the tag for b&w workflow
81void dt_imageio_update_monochrome_workflow_tag(int32_t id, int mask);
82// opens the file using pfm, hdr, exr.
84// opens file using imagemagick
86// try all the options in sequence
88// tries to open the files not opened by the other routines using GraphicsMagick (if supported)
91
94int dt_imageio_export(const int32_t imgid, const char *filename, struct dt_imageio_module_format_t *format,
95 struct dt_imageio_module_data_t *format_params, const gboolean high_quality,
96 const gboolean copy_metadata, const gboolean export_masks,
97 dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
99 dt_imageio_module_data_t *storage_params, int num, int total, dt_export_metadata_t *metadata);
100
101int dt_imageio_export_with_flags(const int32_t imgid, const char *filename,
102 struct dt_imageio_module_format_t *format,
103 struct dt_imageio_module_data_t *format_params, const gboolean ignore_exif,
104 const gboolean display_byteorder, const gboolean high_quality, gboolean is_scaling,
105 const gboolean thumbnail_export, const char *filter, const gboolean copy_metadata,
106 const gboolean export_masks, dt_colorspaces_color_profile_type_t icc_type,
107 const gchar *icc_filename, dt_iop_color_intent_t icc_intent,
109 int num, int total, dt_export_metadata_t *metadata);
110
111// general, efficient buffer flipping function using memcopies
112void dt_imageio_flip_buffers(char *out, const char *in,
113 const size_t bpp, // bytes per pixel
114 const int wd, const int ht, const int fwd, const int fht, const int stride,
115 const dt_image_orientation_t orientation);
116
117void dt_imageio_flip_buffers_ui8_to_float(float *out, const uint8_t *in, const float black, const float white,
118 const int ch, const int wd, const int ht, const int fwd,
119 const int fht, const int stride,
120 const dt_image_orientation_t orientation);
121
135int dt_imageio_large_thumbnail(const char *filename, uint8_t **buffer, int32_t *th_width, int32_t *th_height,
137 const int height);
138
139// lookup maker and model, dispatch lookup to rawspeed or libraw
140gboolean dt_imageio_lookup_makermodel(const char *maker, const char *model,
141 char *mk, int mk_len, char *md, int md_len,
142 char *al, int al_len);
143
144// get the type of image from its extension
146
147#ifdef __cplusplus
148}
149#endif
150
151// clang-format off
152// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
153// vim: shiftwidth=2 expandtab tabstop=2 cindent
154// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
155// clang-format on
const char * extension(dt_imageio_module_data_t *data)
Definition avif.c:704
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
dt_iop_color_intent_t
Definition colorspaces.h:63
dt_colorspaces_color_profile_type_t
Definition colorspaces.h:81
static const dt_colormatrix_t dt_aligned_pixel_t out
Definition colorspaces_inline_conversions.h:184
dt_image_orientation_t
Definition common/image.h:169
dt_imageio_retval_t
Definition common/image.h:78
dt_image_flags_t
Definition common/image.h:91
int bpp
Definition imageio/format/pdf.c:88
void dt_imageio_set_hdr_tag(dt_image_t *img)
Definition imageio.c:1267
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)
Definition imageio.c:400
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)
Definition imageio.c:964
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)
Definition imageio.c:1363
dt_imageio_retval_t dt_imageio_open(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
Definition imageio.c:1282
void dt_imageio_update_monochrome_workflow_tag(int32_t id, int mask)
Definition imageio.c:1251
dt_imageio_retval_t dt_imageio_open_raster(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
Definition imageio.c:627
gboolean dt_imageio_has_mono_preview(const char *filename)
Definition imageio.c:316
dt_imageio_levels_t
Definition imageio.h:60
@ IMAGEIO_INT32
Definition imageio.h:64
@ IMAGEIO_INT16
Definition imageio.h:63
@ IMAGEIO_PREC_MASK
Definition imageio.h:67
@ IMAGEIO_RGB
Definition imageio.h:69
@ IMAGEIO_INT12
Definition imageio.h:62
@ IMAGEIO_INT8
Definition imageio.h:61
@ IMAGEIO_CHANNEL_MASK
Definition imageio.h:71
@ IMAGEIO_GRAY
Definition imageio.h:70
@ IMAGEIO_FLOAT
Definition imageio.h:65
@ IMAGEIO_BW
Definition imageio.h:66
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)
Definition imageio.c:349
dt_imageio_retval_t dt_imageio_open_hdr(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
Definition imageio.c:456
dt_imageio_retval_t dt_imageio_open_exotic(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *buf)
Definition imageio.c:1231
dt_image_flags_t dt_imageio_get_type_from_extension(const char *extension)
Definition imageio.c:135
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)
Definition imageio.c:728
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,...
Definition imageio.c:163
const char * maker
Definition iop/tonecurve.c:450
const char * model
Definition iop/tonecurve.c:451
dt_colorspaces_color_profile_type_t color_space
Definition mipmap_cache.c:5
Definition metadata_export.h:42
Definition common/image.h:247
Definition imageio_module.h:81
Definition imageio_module.h:91
Definition imageio_module.h:113
Definition mipmap_cache.h:68