libopenraw
capi.cpp
1 /*
2  * libopenraw - capi.cpp
3  *
4  * Copyright (C) 2005-2015 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  */
25 #include <stddef.h>
26 #include <stdint.h>
27 
28 #include <libopenraw/consts.h>
29 #include <libopenraw/thumbnails.h>
30 
31 #include "thumbnail.hpp"
32 
33 using OpenRaw::Thumbnail;
34 
35 extern "C" {
36 
37 // typedef struct Thumbnail _Thumbnail;
38 
39  or_error or_get_extract_thumbnail(const char* _filename,
40  uint32_t _preferred_size,
41  ORThumbnailRef *_thumb)
42  {
43  or_error ret = OR_ERROR_NONE;
44 
45  Thumbnail ** pThumbnail = reinterpret_cast<Thumbnail **>(_thumb);
46  *pThumbnail = Thumbnail::getAndExtractThumbnail(_filename,
47  _preferred_size, ret);
48  return ret;
49  }
50 
51 
52  ORThumbnailRef or_thumbnail_new(void)
53  {
54  Thumbnail *thumb = new Thumbnail();
55  return reinterpret_cast<ORThumbnailRef>(thumb);
56  }
57 
58 
59  or_error
60  or_thumbnail_release(ORThumbnailRef thumb)
61  {
62  if (thumb == NULL) {
63  return OR_ERROR_NOTAREF;
64  }
65  delete reinterpret_cast<Thumbnail *>(thumb);
66  return OR_ERROR_NONE;
67  }
68 
69 
70  or_data_type
71  or_thumbnail_format(ORThumbnailRef thumb)
72  {
73  return reinterpret_cast<Thumbnail *>(thumb)->dataType();
74  }
75 
76 
77  void *
78  or_thumbnail_data(ORThumbnailRef thumb)
79  {
80  return reinterpret_cast<Thumbnail *>(thumb)->data();
81  }
82 
83  size_t
84  or_thumbnail_data_size(ORThumbnailRef thumb)
85  {
86  return reinterpret_cast<Thumbnail *>(thumb)->size();
87  }
88 
89  void
90  or_thumbnail_dimensions(ORThumbnailRef thumb, uint32_t *width, uint32_t *height)
91  {
92  Thumbnail* t = reinterpret_cast<Thumbnail *>(thumb);
93  if (width != NULL) {
94  *width = t->width();
95  }
96  if (height != NULL) {
97  *height = t->height();
98  }
99  }
100 
101 
102 }
103