SMIL  0.9.1
DRGB.h
1 /*
2  * Copyright (c) 2011-2016, Matthieu FAESSEL and ARMINES
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Matthieu FAESSEL, or ARMINES nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 
30 #ifndef _DRGB_H
31 #define _DRGB_H
32 
33 #include "Core/include/DColor.h"
34 #include "DImage_RGB.h"
35 #include "DLineArith_RGB.h"
36 
37 #ifdef USE_QT
38 
39 #include "Gui/Qt/DQtImageViewer.hpp"
40 #include "Gui/Qt/DQtImageViewer.hxx"
41 
42 namespace smil
43 {
44  template <>
45  inline void QtImageViewer<RGB>::setImage(Image<RGB> &im)
46  {
47  BASE_QT_VIEWER::imageFormat = QImage::Format_ARGB32_Premultiplied;
48  ImageViewer<RGB>::setImage(im);
49  BASE_QT_VIEWER::setImageSize(im.getWidth(), im.getHeight(), im.getDepth());
50  if (im.getName()!=string(""))
51  setName(this->image->getName());
52  }
53 
54  template <>
55  inline void QtImageViewer<RGB>::drawImage()
56  {
57  Image<RGB>::sliceType lines = this->image->getSlices()[slider->value()];
58  Image<RGB>::lineType pixels;
59  typedef Image<UINT8>::lineType arrayType;
60 
61  size_t w = this->image->getWidth();
62  size_t h = this->image->getHeight();
63 
64  QRgb *destLine;
65  arrayType rArray, gArray, bArray;
66 
67  for (size_t j=0;j<h;j++)
68  {
69  destLine = (QRgb*)(this->qImage->scanLine(j));
70  pixels = *lines++;
71  rArray = pixels.arrays[0];
72  gArray = pixels.arrays[1];
73  bArray = pixels.arrays[2];
74  for (size_t i=0;i<w;i++)
75  {
76  destLine[i] = qRgb(rArray[i], gArray[i], bArray[i]);
77  }
78  }
79  }
80 
81  template <>
82  inline void QtImageViewer<RGB>::displayPixelValue(size_t x, size_t y, size_t z)
83  {
84  RGB pixVal;
85 
86  pixVal = this->image->getPixel(x, y, z);
87  QString txt = "(" + QString::number(x) + ", " + QString::number(y);
88  if (this->image->getDepth()>1)
89  txt = txt + ", " + QString::number(z);
90  txt = txt + ") " + QString::number(pixVal[0]) + "," + QString::number(pixVal[1]) + "," + QString::number(pixVal[2]);
91  valueLabel->setText(txt);
92  valueLabel->adjustSize();
93  }
94 
95  template <>
96  inline void QtImageViewer<RGB>::drawOverlay(const Image<RGB> &/*im*/)
97  {
98  }
99 
100 #ifdef USE_QWT
101  template <>
102  inline void QtImageViewer<RGB>::displayHistogram(bool /*update*/)
103  {
104  }
105  template <>
106  inline void QtImageViewer<RGB>::displayProfile(bool /*update*/)
107  {
108  }
109 #endif // USE_QWT
110 }
111 
112 #endif // USE_QT
113 
114 
115 namespace smil
116 {
117 
118 
119 
120 
121 #if defined SWIGPYTHON && defined USE_NUMPY
122  template <>
123  PyObject * Image<RGB>::getNumArray(bool /*c_contigous*/)
124  {
125  return NULL;
126  }
127 #endif // defined SWIGPYTHON and defined USE_NUMPY
128 
129 } // namespace smil
130 
131 #endif // _DRGB_H
132 
Definition: DColorConvert.h:38