My Project
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
44class EXPORT_2D CRGB2DImage : public mia::CIOData
45{
46public:
48 typedef std::shared_ptr<CRGB2DImage> Pointer;
49
51 static const char *data_descr;
52
55
61
63 const mia::C2DBounds& get_size() const;
64
66 const unsigned char *pixel() const;
67
69 unsigned char *pixel();
70
71 /* provide a cloing mechanism for this image. This is only needed because
72 we use the plug-in handler infrastructure to provide the IO for this class
73 and the handler needs to be able to clone the data for internal storage.
74 */
76private:
77 mia::C2DBounds m_size;
78 std::vector<unsigned char> m_pixels;
79
80};
81
82
85
88
90extern template class EXPORT_2D TIOPlugin<CRGB2DImage>;
95typedef mia::THandlerSingleton< mia::TIOPluginHandler<C2DRGBImageIOPlugin>> C2DRGBImageIOPluginPluginHandler;
96
101typedef C2DRGBImageIOPluginPluginHandler::Instance::DataKey C2DRGBImageDataKey;
102
111bool EXPORT_2D save_image(const std::string& filename, const CRGB2DImage& image);
112
114
115#endif
T2DVector< unsigned int > C2DBounds
unsigned int valued 2D vector - used as 2D size parameter
Definition: 2d/vector.hh:540
std::shared_ptr< CRGB2DImage > Pointer
unifying pointer definition for this class.
Definition: rgbimageio.hh:48
const mia::C2DBounds & get_size() const
CRGB2DImage * clone() const
unsigned char * pixel()
const unsigned char * pixel() const
CRGB2DImage type
data type for the plug-in handler magic
Definition: rgbimageio.hh:54
static const char * data_descr
data type description used by the plug-in handler to locate the plug-ins
Definition: rgbimageio.hh:51
CRGB2DImage(const mia::C2DBounds &size)
The templatex basis class of all IO plug-ins.
Definition: ioplugin.hh:58
The generic base for all plug-ins.
Definition: plugin_base.hh:172
#define EXPORT_2D
Definition: defines2d.hh:37
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
mia::THandlerSingleton< mia::TIOPluginHandler< C2DRGBImageIOPlugin > > C2DRGBImageIOPluginPluginHandler
The 2D RGB image plugin handler.
Definition: rgbimageio.hh:95
C2DRGBImageIOPluginPluginHandler::Instance::DataKey C2DRGBImageDataKey
The data key type for the CDatapool storage.
Definition: rgbimageio.hh:101
bool EXPORT_2D save_image(const std::string &filename, const CRGB2DImage &image)
CRGB2DImage::Pointer PRGB2DImage
The shared pointer type of the image.
Definition: rgbimageio.hh:84
TIOPlugin< CRGB2DImage > C2DRGBImageIOPlugin
Base type for 2D RGB image IO plugins.
Definition: rgbimageio.hh:87