OpenCMISS-Zinc C++ API Documentation
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Pages
streamimage.hpp
Go to the documentation of this file.
1 
4 /* OpenCMISS-Zinc Library
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #ifndef CMZN_STREAMIMAGE_HPP__
10 #define CMZN_STREAMIMAGE_HPP__
11 
12 #include "zinc/streamimage.h"
13 #include "zinc/fieldimage.hpp"
14 #include "zinc/stream.hpp"
15 
16 namespace OpenCMISS
17 {
18 namespace Zinc
19 {
20 
31 {
32 public:
34  { }
35 
36  // takes ownership of C handle, responsibility for destroying it
37  explicit StreaminformationImage(cmzn_streaminformation_image_id streaminformation_image_id) :
38  Streaminformation(reinterpret_cast<cmzn_streaminformation_id>(streaminformation_image_id))
39  { }
40 
46  bool isValid() const
47  {
48  return (0 != id);
49  }
50 
56  cmzn_streaminformation_image_id getId() const
57  {
58  return reinterpret_cast<cmzn_streaminformation_image_id>(id);
59  }
60 
65  enum Attribute
66  {
67  ATTRIBUTE_RAW_WIDTH_PIXELS = CMZN_STREAMINFORMATION_IMAGE_ATTRIBUTE_RAW_WIDTH_PIXELS,
71  ATTRIBUTE_RAW_HEIGHT_PIXELS = CMZN_STREAMINFORMATION_IMAGE_ATTRIBUTE_RAW_HEIGHT_PIXELS,
75  ATTRIBUTE_BITS_PER_COMPONENT = CMZN_STREAMINFORMATION_IMAGE_ATTRIBUTE_BITS_PER_COMPONENT,
79  ATTRIBUTE_COMPRESSION_QUALITY = CMZN_STREAMINFORMATION_IMAGE_ATTRIBUTE_COMPRESSION_QUALITY
85  };
86 
92  {
93  FILE_FORMAT_INVALID = CMZN_STREAMINFORMATION_IMAGE_FILE_FORMAT_INVALID,
95  FILE_FORMAT_BMP = CMZN_STREAMINFORMATION_IMAGE_FILE_FORMAT_BMP,
98  FILE_FORMAT_DICOM = CMZN_STREAMINFORMATION_IMAGE_FILE_FORMAT_DICOM,
101  FILE_FORMAT_JPG = CMZN_STREAMINFORMATION_IMAGE_FILE_FORMAT_JPG,
104  FILE_FORMAT_GIF = CMZN_STREAMINFORMATION_IMAGE_FILE_FORMAT_GIF,
107  FILE_FORMAT_PNG = CMZN_STREAMINFORMATION_IMAGE_FILE_FORMAT_PNG,
110  FILE_FORMAT_SGI = CMZN_STREAMINFORMATION_IMAGE_FILE_FORMAT_SGI,
113  FILE_FORMAT_TIFF = CMZN_STREAMINFORMATION_IMAGE_FILE_FORMAT_TIFF,
116  FILE_FORMAT_ANALYZE = CMZN_STREAMINFORMATION_IMAGE_FILE_FORMAT_ANALYZE
119  };
120 
125  {
126  PIXEL_FORMAT_INVALID = CMZN_STREAMINFORMATION_IMAGE_PIXEL_FORMAT_INVALID,
128  PIXEL_FORMAT_LUMINANCE = CMZN_STREAMINFORMATION_IMAGE_PIXEL_FORMAT_LUMINANCE,
131  PIXEL_FORMAT_LUMINANCE_ALPHA = CMZN_STREAMINFORMATION_IMAGE_PIXEL_FORMAT_LUMINANCE_ALPHA,
134  PIXEL_FORMAT_RGB = CMZN_STREAMINFORMATION_IMAGE_PIXEL_FORMAT_RGB,
137  PIXEL_FORMAT_RGBA = CMZN_STREAMINFORMATION_IMAGE_PIXEL_FORMAT_RGBA,
140  PIXEL_FORMAT_ABGR = CMZN_STREAMINFORMATION_IMAGE_PIXEL_FORMAT_ABGR,
143  PIXEL_FORMAT_BGR = CMZN_STREAMINFORMATION_IMAGE_PIXEL_FORMAT_BGR
146  };
147 
159  int setAttributeInteger(Attribute attribute, int value)
160  {
161  return cmzn_streaminformation_image_set_attribute_integer(
162  reinterpret_cast<cmzn_streaminformation_image_id>(id),
163  static_cast<cmzn_streaminformation_image_attribute>(attribute), value);
164  }
165 
175  int setAttributeReal(Attribute attribute, double value)
176  {
177  return cmzn_streaminformation_image_set_attribute_real(
178  reinterpret_cast<cmzn_streaminformation_image_id>(id),
179  static_cast<cmzn_streaminformation_image_attribute>(attribute), value);
180  }
181 
189  int setFileFormat(FileFormat imageFileFormat)
190  {
191  return cmzn_streaminformation_image_set_file_format(
192  reinterpret_cast<cmzn_streaminformation_image_id>(id),
193  static_cast<cmzn_streaminformation_image_file_format>(imageFileFormat));
194  }
195 
203  int setPixelFormat(PixelFormat imagePixelFormat)
204  {
205  return cmzn_streaminformation_image_set_pixel_format(
206  reinterpret_cast<cmzn_streaminformation_image_id>(id),
207  static_cast<cmzn_streaminformation_image_pixel_format>(imagePixelFormat));
208  }
209 
210 };
211 
213 {
214  return StreaminformationImage(cmzn_streaminformation_cast_image(id));
215 }
216 
218 {
219  return StreaminformationImage(
220  reinterpret_cast<cmzn_streaminformation_image_id>(
221  cmzn_field_image_create_streaminformation_image(getDerivedId())));
222 }
223 
224 inline int FieldImage::read(const StreaminformationImage& streaminformationImage)
225 {
226  return cmzn_field_image_read(getDerivedId(), streaminformationImage.getId());
227 }
228 
229 inline int FieldImage::write(const StreaminformationImage& streaminformationImage)
230 {
231  return cmzn_field_image_write(getDerivedId(), streaminformationImage.getId());
232 }
233 
234 } // namespace Zinc
235 }
236 #endif
int write(const StreaminformationImage &streaminformationImage)
Definition: streamimage.hpp:229
int read(const StreaminformationImage &streaminformationImage)
Definition: streamimage.hpp:224
PixelFormat
Definition: streamimage.hpp:124
int setAttributeReal(Attribute attribute, double value)
Definition: streamimage.hpp:175
FileFormat
Definition: streamimage.hpp:91
int setPixelFormat(PixelFormat imagePixelFormat)
Definition: streamimage.hpp:203
StreaminformationImage castImage()
Definition: streamimage.hpp:212
Attribute
Definition: streamimage.hpp:65
Base type listing resources and options for stream I/O.
Definition: stream.hpp:193
int setFileFormat(FileFormat imageFileFormat)
Definition: streamimage.hpp:189
bool isValid() const
Definition: streamimage.hpp:46
int setAttributeInteger(Attribute attribute, int value)
Definition: streamimage.hpp:159
An image-specific stream information object.
Definition: streamimage.hpp:30
cmzn_streaminformation_image_id getId() const
Definition: streamimage.hpp:56
StreaminformationImage createStreaminformationImage()
Definition: streamimage.hpp:217