appkit  1.5.1
RoadNarrows Robotics Application Kit
WinGtkUtil.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: RoadNarrows Roboitics Windowing Package
4 //
5 // Library: librnrwin-gtk
6 //
7 // File: rnrGtkWinUtil.cxx
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2013-05-03 07:45:13 -0600 (Fri, 03 May 2013) $
12  * $Rev: 2904 $
13  *
14  * \brief Windowing utilities.
15  *
16  * \author Robin Knight (robin.knight@roadnarrows.com)
17  * \author Daniel Packard (daniel@roadnarrows.com)
18  *
19  * \par Copyright
20  * \h_copy 2011-2017. RoadNarrows LLC.\n
21  * http://www.roadnarrows.com\n
22  * All Rights Reserved
23  */
24 /*
25  * @EulaBegin@
26  *
27  * Permission is hereby granted, without written agreement and without
28  * license or royalty fees, to use, copy, modify, and distribute this
29  * software and its documentation for any purpose, provided that
30  * (1) The above copyright notice and the following two paragraphs
31  * appear in all copies of the source code and (2) redistributions
32  * including binaries reproduces these notices in the supporting
33  * documentation. Substantial modifications to this software may be
34  * copyrighted by their authors and need not follow the licensing terms
35  * described here, provided that the new terms are clearly indicated in
36  * all files where they apply.
37  *
38  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
39  * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
40  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
41  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
42  * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
43  * THE POSSIBILITY OF SUCH DAMAGE.
44  *
45  * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
46  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
47  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
48  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
49  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
50  *
51  * @EulaEnd@
52  */
53 ////////////////////////////////////////////////////////////////////////////////
54 
55 #include "rnr/rnrconfig.h"
56 #include "rnr/log.h"
57 
58 #include "opencv/cv.h"
59 #include "opencv/highgui.h"
60 
61 #include "rnr/rnrWin.h"
62 
63 using namespace std;
64 using namespace rnrWin;
65 
66 
67 /*!
68  * \brief Apply color gradient to image.
69  *
70  * The gradient ranges from black to the given color, given the intensity
71  * of each pixel in the unaltered image.
72  *
73  * \param [in,out] pImg Pointer to image to change.
74  * \param red 8-bit red component of RGB.
75  * \param green 8-bit green component of RGB.
76  * \param blue 8-bit blue component of RGB.
77  */
78 void ApplyColorGradient(IplImage *pImg, int red, int green, int blue)
79 {
80  CvScalar s;
81  CvScalar t;
82  double intensity;
83 
84  for(int i=0; i<pImg->width; ++i)
85  {
86  for(int j=0; j<pImg->height; ++j)
87  {
88  s =cvGet2D(pImg, i, j);
89  intensity = ((((byte_t)s.val[0]) & 0xff) << 16) |
90  ((((byte_t)s.val[1]) & 0xff) << 8) |
91  (((byte_t)s.val[2]) & 0xff);
92  intensity /= (double)(0x00ffffff);
93  t = cvScalar(blue*intensity, green*intensity, red*intensity);
94  cvSet2D(pImg, i, j, t);
95  }
96  }
97 }
void ApplyColorGradient(IplImage *pImg, int red, int green, int blue)
Apply color gradient to image.
Definition: WinGtkUtil.cxx:78