libopenraw
bitmapdata.cpp
1/*
2 * libopenraw - bitmapdata.cpp
3 *
4 * Copyright (C) 2007-2015 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#include <stddef.h>
25#include <stdint.h>
26
27#include <libopenraw/types.h>
28#include <libopenraw/consts.h>
29
30#include "bitmapdata.hpp"
31
33
34extern "C" {
35
36ORBitmapDataRef or_bitmapdata_new(void)
37{
38 BitmapData *bitmapdata = new BitmapData();
39 return reinterpret_cast<ORBitmapDataRef>(bitmapdata);
40}
41
42or_error or_bitmapdata_release(ORBitmapDataRef bitmapdata)
43{
44 if (bitmapdata == NULL) {
45 return OR_ERROR_NOTAREF;
46 }
47 delete reinterpret_cast<BitmapData *>(bitmapdata);
48 return OR_ERROR_NONE;
49}
50
51or_data_type or_bitmapdata_format(ORBitmapDataRef bitmapdata)
52{
53 return reinterpret_cast<BitmapData *>(bitmapdata)->dataType();
54}
55
56void *or_bitmapdata_data(ORBitmapDataRef bitmapdata)
57{
58 return reinterpret_cast<BitmapData *>(bitmapdata)->data();
59}
60
61size_t or_bitmapdata_data_size(ORBitmapDataRef bitmapdata)
62{
63 return reinterpret_cast<BitmapData *>(bitmapdata)->size();
64}
65
66void or_bitmapdata_dimensions(ORBitmapDataRef bitmapdata, uint32_t *x,
67 uint32_t *y)
68{
69 BitmapData *t = reinterpret_cast<BitmapData *>(bitmapdata);
70 if (x != NULL) {
71 *x = t->width();
72 }
73 if (y != NULL) {
74 *y = t->height();
75 }
76}
77
78uint32_t or_bitmapdata_bpc(ORBitmapDataRef bitmapdata)
79{
80 return reinterpret_cast<BitmapData *>(bitmapdata)->bpc();
81}
82}