libopenraw
bitmapdata.cpp
1 /*
2  * libopenraw - bitmapdata.cpp
3  *
4  * Copyright (C) 2007-2008 Hubert Figuiere
5  * Copyright (C) 2008 Novell Inc.
6  *
7  * This library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 /* @brief C api for bitmapdata
22  */
23 
24 
25 #include <libopenraw/libopenraw.h>
26 
27 #include <libopenraw++/bitmapdata.h>
28 
30 
31 extern "C" {
32 
33 ORBitmapDataRef
34 or_bitmapdata_new(void)
35 {
36  BitmapData * bitmapdata = new BitmapData();
37  return reinterpret_cast<ORBitmapDataRef>(bitmapdata);
38 }
39 
40 or_error
41 or_bitmapdata_release(ORBitmapDataRef bitmapdata)
42 {
43  if (bitmapdata == NULL) {
44  return OR_ERROR_NOTAREF;
45  }
46  delete reinterpret_cast<BitmapData *>(bitmapdata);
47  return OR_ERROR_NONE;
48 }
49 
50 
51 or_data_type
52 or_bitmapdata_format(ORBitmapDataRef bitmapdata)
53 {
54  return reinterpret_cast<BitmapData *>(bitmapdata)->dataType();
55 }
56 
57 
58 void *
59 or_bitmapdata_data(ORBitmapDataRef bitmapdata)
60 {
61  return reinterpret_cast<BitmapData *>(bitmapdata)->data();
62 }
63 
64 
65 size_t
66 or_bitmapdata_data_size(ORBitmapDataRef bitmapdata)
67 {
68  return reinterpret_cast<BitmapData *>(bitmapdata)->size();
69 }
70 
71 
72 void
73 or_bitmapdata_dimensions(ORBitmapDataRef bitmapdata,
74  uint32_t *x, uint32_t *y)
75 {
76  BitmapData* t = reinterpret_cast<BitmapData *>(bitmapdata);
77  if (x != NULL) {
78  *x = t->x();
79  }
80  if (y != NULL) {
81  *y = t->y();
82  }
83 }
84 
85 uint32_t
86 or_bitmapdata_bpc(ORBitmapDataRef bitmapdata)
87 {
88  return reinterpret_cast<BitmapData *>(bitmapdata)->bpc();
89 }
90 
91 
92 }