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