src/trans: Use DQ() instead of explicit struct in variable creation.
[libale.git] / src / trans.c
blob6e9fda91e1cc11d4bcd4e20f57f0a3ef54dd3ae2
1 /*
2 * Copyright 2009 David Hilvert <dhilvert@gmail.com>
4 * This file is part of libale.
6 * libale is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU Affero General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
9 * any later version.
11 * libale is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
14 * more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with libale. If not, see <http://www.gnu.org/licenses/>.
20 #include "libale.h"
23 * API types.
26 TYPE(ale_trans, \
27 size_t height; \
28 size_t width; \
29 ale_context ac; \
30 double exposure; \
31 double black; \
32 double gamma; \
33 int bayer;, \
37 * API Implementation.
40 ale_trans ale_new_trans(ale_context ac, ale_image ai) {
41 #warning NULL image argument should produce the (Euclidean) identity (e.g., for a 2x2 image, as in legacy ALE).
42 if (!ale_context_valid(ac))
43 return N(ale_trans);
45 if (!ale_image_valid(ai))
46 return N(ale_trans);
48 ale_trans at = ale_trans_alloc(ac);
50 if (!ale_trans_valid(at))
51 return N(ale_trans);
53 DQ(ale_trans, at, atp)
55 atp->width = ale_image_get_width(ai);
56 atp->height = ale_image_get_height(ai);
57 atp->exposure = 1.0;
58 atp->gamma = 0.45;
59 atp->black = 0.0;
60 atp->ac = ac;
62 return at;
66 * Set original bounds for a Libale transformation.
69 int ale_trans_set_original_bounds(ale_trans at, ale_image ai) {
70 #warning raw imported code should be revised for Libale
71 #if 0
73 * Original ALE header copyright notice gives '2002, 2004, 2007 David Hilvert'
74 * for the following, but git-blame (correctly) gives 2008.
76 /*
77 * Set the bounds of the reference image after incorporation
78 * of the original frame.
79 */
80 void set_original_bounds(const image *i) {
81 assert (orig_ref_width == 0);
82 assert (orig_ref_height == 0);
84 orig_ref_height = i->height();
85 orig_ref_width = i->width();
86 orig_offset = i->offset();
88 assert (orig_ref_width != 0);
89 assert (orig_ref_height != 0);
92 #endif
94 return ALE_SUCCESS;
98 PARAMETER_RW(ale_trans, bayer, int)
99 PARAMETER_RW(ale_trans, exposure, double)
100 PARAMETER_RW(ale_trans, gamma, double)
101 PARAMETER_RW(ale_trans, black, double)