Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
printing.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2010-2011 Henrik Andersson.
4 Copyright (C) 2010 johannes hanika.
5 Copyright (C) 2010 Pascal de Bruijn.
6 Copyright (C) 2012 Richard Wonka.
7 Copyright (C) 2013-2014 Jérémy Rosen.
8 Copyright (C) 2014-2015, 2020-2021 Pascal Obry.
9 Copyright (C) 2015-2017 Tobias Ellinghaus.
10 Copyright (C) 2016 Roman Lebedev.
11 Copyright (C) 2022 Martin Bařinka.
12
13 darktable is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 darktable is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with darktable. If not, see <http://www.gnu.org/licenses/>.
25*/
26
27#ifndef DT_COMMON_PRINTING_H
28#define DT_COMMON_PRINTING_H
29
30#include <glib.h>
31#include <inttypes.h>
32#include "common/cups_print.h"
33
34
35#define MAX_IMAGE_PER_PAGE 20
36
37typedef struct _imgage_pos
38{
39 float x, y, width, height;
41
42typedef struct _image_box
43{
44 int32_t imgid;
45 int32_t max_width, max_height; // max size for the export (in pixels)
46 int32_t exp_width, exp_height; // final exported size (in pixels)
47 int32_t dis_width, dis_height; // image size on screen (in pixels)
48 int32_t img_width, img_height; // the final image size as it will be exported
50 dt_image_pos pos; // relative pos from screen.page
51 dt_image_pos screen; // current screen pos (in pixels)
52 dt_image_pos print; // current print pos (in pixels) depending on paper size + DPI
53 uint16_t *buf;
55
56typedef struct dt_screen_pos
57{
58 dt_image_pos page; // this is for reference and is the box of the
59 // white page (in pixels) in print module.
60 // it is the full page.
61
62 dt_image_pos print_area; // this is for reference and is the box of the
63 // grey area in the white page (in pixels) in print
64 // module. it is the print area (without margins).
65 gboolean borderless; // whether the print is borderless (user's margins below
66 // hardware margins.
68
69typedef struct dt_images_box
70{
72 int32_t motion_over;
73 int count;
75 float page_width, page_height; // full print page in pixels
76 float page_width_mm, page_height_mm; // full print page in mm
79
80// return the box index or -1 if (x, y) coordinate is not over an image
81int32_t dt_printing_get_image_box(const dt_images_box *imgs, const int x, const int y);
82
85
86/* (x, y) -> (width, height) are in pixels (on screen position) */
88 const float px, const float py, const float pwidth, const float pheight,
89 const float ax, const float ay, const float awidth, const float aheight, gboolean borderless);
90
91void dt_printing_setup_box(dt_images_box *imgs, const int idx,
92 const float x, const float y,
93 const float width, const float height);
94
95/* page_width page_height in mm, compute the max_width and max_height in
96 pixels for the image */
98 const float page_width, const float page_height,
99 const int resolution);
100
101/* setup the image id and exported width x height */
102void dt_printing_setup_image(dt_images_box *imgs, const int idx,
103 const int32_t imgid, const int32_t width, const int32_t height,
104 const dt_alignment_t alignment);
105
106/* return the on screen pos with alignement */
107void dt_printing_get_screen_pos(const dt_images_box *imgs, const dt_image_box *img, dt_image_pos *pos);
109void dt_printing_get_image_pos_mm(const dt_images_box *imgs, const dt_image_box *img, dt_image_pos *pos);
110void dt_printing_get_image_pos(const dt_images_box *imgs, const dt_image_box *img, dt_image_pos *pos);
111
112#endif // DT_COMMON_PRINTING_H
113
114// clang-format off
115// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
116// vim: shiftwidth=2 expandtab tabstop=2 cindent
117// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
118// clang-format on
119
static const float x
dt_alignment_t
Definition cups_print.h:31
uint32_t width
Definition mipmap_cache.c:0
uint32_t height
Definition mipmap_cache.c:1
void dt_printing_get_screen_pos(const dt_images_box *imgs, const dt_image_box *img, dt_image_pos *pos)
Definition printing.c:267
#define MAX_IMAGE_PER_PAGE
Definition printing.h:35
void dt_printing_setup_display(dt_images_box *imgs, const float px, const float py, const float pwidth, const float pheight, const float ax, const float ay, const float awidth, const float aheight, gboolean borderless)
Definition printing.c:117
void dt_printing_get_image_pos(const dt_images_box *imgs, const dt_image_box *img, dt_image_pos *pos)
Definition printing.c:295
int32_t dt_printing_get_image_box(const dt_images_box *imgs, const int x, const int y)
Definition printing.c:68
void dt_printing_clear_box(dt_image_box *img)
Definition printing.c:38
struct _imgage_pos dt_image_pos
void dt_printing_setup_box(dt_images_box *imgs, const int idx, const float x, const float y, const float width, const float height)
Definition printing.c:157
void dt_printing_setup_image(dt_images_box *imgs, const int idx, const int32_t imgid, const int32_t width, const int32_t height, const dt_alignment_t alignment)
Definition printing.c:307
void dt_printing_get_screen_rel_pos(const dt_images_box *imgs, const dt_image_box *img, dt_image_pos *pos)
Definition printing.c:274
void dt_printing_setup_page(dt_images_box *imgs, const float page_width, const float page_height, const int resolution)
Definition printing.c:202
void dt_printing_clear_boxes(dt_images_box *imgs)
Definition printing.c:53
void dt_printing_get_image_pos_mm(const dt_images_box *imgs, const dt_image_box *img, dt_image_pos *pos)
Definition printing.c:283
struct _image_box dt_image_box
dt_image_pos screen
Definition printing.h:51
int32_t dis_width
Definition printing.h:47
int32_t exp_height
Definition printing.h:46
int32_t exp_width
Definition printing.h:46
int32_t dis_height
Definition printing.h:47
dt_alignment_t alignment
Definition printing.h:49
int32_t max_width
Definition printing.h:45
int32_t img_height
Definition printing.h:48
int32_t imgid
Definition printing.h:44
dt_image_pos pos
Definition printing.h:50
int32_t max_height
Definition printing.h:45
uint16_t * buf
Definition printing.h:53
int32_t img_width
Definition printing.h:48
dt_image_pos print
Definition printing.h:52
float width
Definition printing.h:39
float x
Definition printing.h:39
float height
Definition printing.h:39
float y
Definition printing.h:39
float page_height
Definition printing.h:75
int32_t imgid_to_load
Definition printing.h:71
float page_width
Definition printing.h:75
dt_image_box box[20]
Definition printing.h:74
int32_t motion_over
Definition printing.h:72
dt_screen_pos screen
Definition printing.h:77
float page_width_mm
Definition printing.h:76
float page_height_mm
Definition printing.h:76
gboolean borderless
Definition printing.h:65
dt_image_pos print_area
Definition printing.h:62
dt_image_pos page
Definition printing.h:58