libopenraw
rawdata.cpp
1 /*
2  * libopenraw - rawdata.cpp
3  *
4  * Copyright (C) 2007 Hubert Figuiere
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3 of
9  * the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 /* @brief C api for rawdata
21  */
22 
23 
24 #include <libopenraw/libopenraw.h>
25 
26 #include <libopenraw++/rawdata.h>
27 
28 using OpenRaw::RawData;
29 
30 extern "C" {
31 
32  or_error or_get_extract_rawdata(const char* filename, uint32_t options,
33  ORRawDataRef *rawdata)
34  {
35  or_error ret = OR_ERROR_NONE;
36 
37  RawData ** pRawData = reinterpret_cast<RawData **>(rawdata);
38  *pRawData = RawData::getAndExtractRawData(filename,
39  options, ret);
40  return ret;
41  }
42 
43  ORRawDataRef
44  or_rawdata_new(void)
45  {
46  RawData * rawdata = new RawData();
47  return reinterpret_cast<ORRawDataRef>(rawdata);
48  }
49 
50  or_error
51  or_rawdata_release(ORRawDataRef rawdata)
52  {
53  if (rawdata == NULL) {
54  return OR_ERROR_NOTAREF;
55  }
56  delete reinterpret_cast<RawData *>(rawdata);
57  return OR_ERROR_NONE;
58  }
59 
60 
61  or_data_type
62  or_rawdata_format(ORRawDataRef rawdata)
63  {
64  return reinterpret_cast<RawData *>(rawdata)->dataType();
65  }
66 
67 
68  void *
69  or_rawdata_data(ORRawDataRef rawdata)
70  {
71  return reinterpret_cast<RawData *>(rawdata)->data();
72  }
73 
74 
75  size_t
76  or_rawdata_data_size(ORRawDataRef rawdata)
77  {
78  return reinterpret_cast<RawData *>(rawdata)->size();
79  }
80 
81 
82  void
83  or_rawdata_dimensions(ORRawDataRef rawdata,
84  uint32_t *x, uint32_t *y)
85  {
86  RawData* t = reinterpret_cast<RawData *>(rawdata);
87  if (x != NULL) {
88  *x = t->x();
89  }
90  if (y != NULL) {
91  *y = t->y();
92  }
93  }
94 
95  uint32_t
96  or_rawdata_bpc(ORRawDataRef rawdata)
97  {
98  return reinterpret_cast<RawData *>(rawdata)->bpc();
99  }
100 
101  or_cfa_pattern
102  or_rawdata_get_cfa_pattern(ORRawDataRef rawdata)
103  {
104  return reinterpret_cast<RawData *>(rawdata)->cfaPattern();
105  }
106 
107  or_error
108  or_rawdata_get_minmax(ORRawDataRef rawdata, uint16_t *min, uint16_t *max)
109  {
110  RawData* t = reinterpret_cast<RawData *>(rawdata);
111  if(min) {
112  *min = t->min();
113  }
114  if(max) {
115  *max = t->max();
116  }
117  return OR_ERROR_NONE;
118  }
119 
120 }