Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpGDIRenderer.h
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5 *
6 * This software 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 2 of the License, or
9 * (at your option) any later version.
10 * See the file LICENSE.txt at the root directory of this source
11 * distribution for additional information about the GNU GPL.
12 *
13 * For using ViSP with software that can not be combined with the GNU
14 * GPL, please contact Inria about acquiring a ViSP Professional
15 * Edition License.
16 *
17 * See https://visp.inria.fr for more information.
18 *
19 * This software was developed at:
20 * Inria Rennes - Bretagne Atlantique
21 * Campus Universitaire de Beaulieu
22 * 35042 Rennes Cedex
23 * France
24 *
25 * If you have questions regarding the use of this file, please contact
26 * Inria at visp@inria.fr
27 *
28 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30 *
31 * Description:
32 * GDI renderer for windows 32 display
33 *
34 * Authors:
35 * Bruno Renier
36 *
37*****************************************************************************/
38
39#include <visp3/core/vpConfig.h>
40
41#if (defined(VISP_HAVE_GDI))
42#ifndef vpGDIRenderer_HH
43#define vpGDIRenderer_HH
44
45#ifndef DOXYGEN_SHOULD_SKIP_THIS
46
47// Include WinSock2.h before windows.h to ensure that winsock.h is not
48// included by windows.h since winsock.h and winsock2.h are incompatible
49#include <WinSock2.h>
50#include <windows.h>
51
52#include <visp3/core/vpDisplayException.h>
53#include <visp3/core/vpImage.h>
54#include <visp3/core/vpRGBa.h>
55#include <visp3/gui/vpWin32Renderer.h>
56
57#include <visp3/core/vpMath.h>
58
59class VISP_EXPORT vpGDIRenderer : public vpWin32Renderer
60{
61 // the handle of the associated window
62 HWND m_hWnd;
63
64 // the bitmap object to display
65 HBITMAP m_bmp;
66
67 // colors for overlay
68 COLORREF m_colors[vpColor::id_unknown];
69
70 // font used to draw text
71 HFONT m_hFont;
72
73 // used to ensure that only one thread at a time is accessing bmp
74 CRITICAL_SECTION m_criticalSection;
75
76 unsigned int m_bmp_width;
77 unsigned int m_bmp_height;
78
79public:
80 double timelost;
81 vpGDIRenderer();
82 virtual ~vpGDIRenderer();
83
84 bool init(HWND hWnd, unsigned int width, unsigned int height);
85
86 bool render();
87
88 void setImg(const vpImage<vpRGBa> &I);
89 void setImg(const vpImage<unsigned char> &I);
90 void setImgROI(const vpImage<vpRGBa> &I, const vpImagePoint &iP, unsigned int width, unsigned int height);
91 void setImgROI(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int width, unsigned int height);
92
93 void setPixel(const vpImagePoint &iP, const vpColor &color);
94
95 void drawLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness,
96 int style = PS_SOLID);
97
98 void drawRect(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color,
99 bool fill = false, unsigned int thickness = 1);
100
101 void clear(const vpColor &color);
102
103 void drawCircle(const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill = false,
104 unsigned int thickness = 1);
105
106 void drawText(const vpImagePoint &ip, const char *text, const vpColor &color);
107
108 void drawCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness = 1);
109
110 void drawArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int w, unsigned int h,
111 unsigned int thickness = 1);
112
113 void getImage(vpImage<vpRGBa> &I);
114
115private:
116 // updates the renderer hbitmaps.
117 bool updateBitmap(HBITMAP &hBmp, unsigned char *imBuffer, unsigned int w, unsigned int h);
118 // updates the renderer hbitmaps.
119 bool updateBitmapROI(unsigned char *imBuffer, int i_min, int j_min, int w, int h);
120
121 // converts a vpImage<vpRGBa> into a HBITMAP .
122 void convert(const vpImage<vpRGBa> &I, HBITMAP &hBmp);
123
124 // converst a vpImage<unsigned char> into a HBITMAP .
125 void convert(const vpImage<unsigned char> &I, HBITMAP &hBmp);
126
127 // converts a vpImage<vpRGBa> into a HBITMAP .
128 void convertROI(const vpImage<vpRGBa> &I, const vpImagePoint &iP, unsigned int width, unsigned int height);
129
130 // converst a vpImage<unsigned char> into a HBITMAP .
131 void convertROI(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int width, unsigned int height);
132};
133#endif
134#endif
135#endif
Class to define RGB colors available for display functionalities.
Definition vpColor.h:152
@ id_unknown
Definition vpColor.h:193
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
Definition vpImage.h:135