rgbimageio.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef mia_2d_rgbimageio_hh
22 #define mia_2d_rgbimageio_hh
23 
24 #include <vector>
25 #include <mia/2d/defines2d.hh>
26 #include <mia/2d/vector.hh>
27 #include <mia/core/iodata.hh>
28 #include <mia/core/ioplugin.hh>
29 #include <mia/core/iohandler.hh>
30 
32 
33 /*
34  \brief Quick and dirty class to store RGB unsigned char images
35 
36  This class is a very shallow inmplementation of a 2D RGB image that may
37  only be used to hold tha data and save it. Main purpoise is its use to create
38  some nice and colorfull output.
39  This implementation has nothing to do with T2DImage.
40 
41 */
42 
43 
44 class EXPORT_2D CRGB2DImage : public mia::CIOData{
45 public:
47  typedef std::shared_ptr<CRGB2DImage> Pointer;
48 
50  static const char *data_descr;
51 
53  typedef CRGB2DImage type;
54 
59  CRGB2DImage(const mia::C2DBounds& size);
60 
62  const mia::C2DBounds& get_size() const;
63 
65  const unsigned char *pixel() const;
66 
68  unsigned char *pixel();
69 
70  /* provide a cloing mechanism for this image. This is only needed because
71  we use the plug-in handler infrastructure to provide the IO for this class
72  and the handler needs to be able to clone the data for internal storage.
73  */
74  CRGB2DImage *clone() const;
75 private:
76  mia::C2DBounds m_size;
77  std::vector<unsigned char> m_pixels;
78 
79 };
80 
81 
84 
87 
88 extern template class EXPORT_2D TPlugin<CRGB2DImage, io_plugin_type>;
89 extern template class EXPORT_2D TIOPlugin<CRGB2DImage>;
94 typedef mia::THandlerSingleton< mia::TIOPluginHandler<C2DRGBImageIOPlugin> > C2DRGBImageIOPluginPluginHandler;
95 
100 typedef C2DRGBImageIOPluginPluginHandler::Instance::DataKey C2DRGBImageDataKey;
101 
110 bool EXPORT_2D save_image(const std::string& filename, const CRGB2DImage& image);
111 
113 
114 #endif
static const char * data_descr
data type description used by the plug-in handler to locate the plug-ins
Definition: rgbimageio.hh:50
The templatex basis class of all IO plug-ins.
Definition: ioplugin.hh:57
std::shared_ptr< CRGB2DImage > Pointer
unifying pointer definition for this class.
Definition: rgbimageio.hh:47
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
CRGB2DImage::Pointer PRGB2DImage
The shared pointer type of the image.
Definition: rgbimageio.hh:83
#define EXPORT_2D
Definition: defines2d.hh:37
T2DVector< unsigned int > C2DBounds
unsigned int valued 2D vector - used as 2D size parameter
Definition: 2d/vector.hh:496
bool EXPORT_2D save_image(const std::string &filename, const CRGB2DImage &image)
C2DRGBImageIOPluginPluginHandler::Instance::DataKey C2DRGBImageDataKey
The data key type for the CDatapool storage.
Definition: rgbimageio.hh:100
CRGB2DImage type
data type for the plug-in handler magic
Definition: rgbimageio.hh:53
mia::THandlerSingleton< mia::TIOPluginHandler< C2DRGBImageIOPlugin > > C2DRGBImageIOPluginPluginHandler
The 2D RGB image plugin handler.
Definition: rgbimageio.hh:94
TIOPlugin< CRGB2DImage > C2DRGBImageIOPlugin
Base type for 2D RGB image IO plugins.
Definition: rgbimageio.hh:86
The generic base for all plug-ins.
Definition: plugin_base.hh:170
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36