EBST_CAM
Toggle main menu visibility
Loading...
Searching...
No Matches
ESLSCDLL
Direct2dViewer.h
Go to the documentation of this file.
1
/*****************************************************************/
9
10
#pragma once
11
12
#ifndef MINIMAL_BUILD
13
14
// Modify the following defines if you have to target a platform prior to the ones specified below.
15
// Refer to MSDN for the latest info on corresponding values for different platforms.
16
#ifndef WINVER
// Allow use of features specific to Windows 7 or later.
17
#define WINVER 0x0700
// Change this to the appropriate value to target other versions of Windows.
18
#endif
19
20
#ifndef _WIN32_WINNT
// Allow use of features specific to Windows 7 or later.
21
#define _WIN32_WINNT 0x0A00
// Change this to the appropriate value to target other versions of Windows.
22
#endif
23
24
#ifndef UNICODE
25
#define UNICODE
26
#endif
27
28
#define WIN32_LEAN_AND_MEAN
// Exclude rarely-used stuff from Windows headers
29
// Windows Header Files:
30
#include <Windows.h>
31
#include <Windowsx.h>
32
// C RunTime Header Files
33
#include <stdlib.h>
34
35
#include <malloc.h>
36
#include <memory.h>
37
#include <wchar.h>
38
#include <math.h>
39
#include <string>
40
41
#include <d2d1.h>
42
#include <d2d1helper.h>
43
#include <dwrite.h>
44
#include <wincodec.h>
45
#include <d2d1_1.h>
46
/******************************************************************
47
* *
48
* Macros *
49
* *
50
******************************************************************/
51
52
template
<
class
Interface>
53
inline
void
54
SafeRelease
(
55
Interface **ppInterfaceToRelease
56
)
57
{
58
if
(*ppInterfaceToRelease != NULL)
59
{
60
(*ppInterfaceToRelease)->Release();
61
62
(*ppInterfaceToRelease) = NULL;
63
}
64
}
65
66
#ifndef Assert
67
#if defined( DEBUG ) || defined( _DEBUG )
68
#define Assert(b) do {if (!(b)) {OutputDebugStringA("Assert: " #b "\n");}} while(0)
69
#else
70
#define Assert(b)
71
#endif
//DEBUG || _DEBUG
72
#endif
73
74
75
#ifndef HINST_THISCOMPONENT
76
EXTERN_C IMAGE_DOS_HEADER
__ImageBase
;
77
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
78
#endif
79
80
#define WM_2DVIEWER_CLOSED (WM_USER + 0x0001)
81
/******************************************************************
82
* *
83
* Direct2dViewer *
84
* *
85
******************************************************************/
86
87
class
Direct2dViewer
88
{
89
public
:
90
Direct2dViewer
();
91
~Direct2dViewer
();
92
93
HRESULT
start2dViewer
94
(
95
HWND hWndParent,
96
void
*bitmapAddr,
97
UINT width,
98
UINT height
99
);
100
void
showNewBitmap
101
(
102
void
*addr,
103
UINT width,
104
UINT height
105
);
106
void
repaintWindow
();
107
HWND
getWindowHandler
();
108
void
SetGammaValue
109
(
110
UINT16 white,
111
UINT16 black
112
);
113
UINT16
GetGammaWhite
();
114
UINT16
GetGammaBlack
();
115
116
private
:
117
HRESULT Initialize( HWND hWndParent );
118
void
setBitmapSource
119
(
120
void
*addr,
121
UINT width,
122
UINT height
123
);
124
HRESULT loadBitmap();
125
HRESULT CreateDeviceIndependentResources();
126
HRESULT CreateDeviceResources();
127
void
DiscardDeviceResources();
128
HRESULT OnRender();
129
void
OnResize(
130
UINT width,
131
UINT height
132
);
133
static
LRESULT CALLBACK WndProc(
134
HWND hWnd,
135
UINT message,
136
WPARAM wParam,
137
LPARAM lParam
138
);
139
void
CalcCursorPos();
140
void
DrawScale();
141
void
DrawVerticalLine(
142
D2D1_POINT_2F startPoint,
143
FLOAT length,
144
FLOAT strokeWidth
145
);
146
void
DrawHorizontalLine(
147
D2D1_POINT_2F startPoint,
148
FLOAT length,
149
FLOAT strokeWidth
150
);
151
void
DrawNumber(
152
D2D1_POINT_2F location,
153
int
number
154
);
155
void
Scale_setSkipLines(
156
int
x,
157
int
y
158
);
159
HWND m_hwnd;
160
ID2D1Factory *m_pD2DFactory;
161
IWICImagingFactory *m_pWICFactory;
162
IDWriteFactory *m_pDWriteFactory;
163
ID2D1HwndRenderTarget *m_pRenderTarget;
164
IDWriteTextFormat *m_pTextFormat;
165
IDWriteTextFormat *m_pTextFormat_scale;
166
ID2D1SolidColorBrush *m_pBlackBrush;
167
ID2D1Bitmap *m_pBitmap;
168
struct
_Scale
169
{
170
FLOAT length = 12;
171
FLOAT width = 1;
172
FLOAT distance_x = 10;
173
FLOAT distance_y = 10;
174
int
skip_x = 25;
175
int
skip_y = 5;
176
} _scale;
177
struct
_Gamma
178
{
179
FLOAT amplitude = 1;
180
INT32 offset = 0;
181
UINT16 white = 0xFFFF;
182
UINT16 black = 0;
183
} _gamma;
184
const
struct
_Margin
185
{
186
FLOAT top = 0;
187
FLOAT left = 35;
188
FLOAT bottom = 50;
189
FLOAT right = 0;
190
} _margin;
191
struct
_CursorPos
192
{
193
// relative position to upper left corner of direct2d window
194
int
x = 0;
195
int
y = 0;
196
// position in camera data
197
int
pixel = 0;
198
int
line = 0;
199
} _cursorPos;
200
struct
_BitmapSource
201
{
202
void
*addr;
203
UINT width;
204
UINT height;
205
} _bitmapSource;
206
};
207
208
#endif
SafeRelease
void SafeRelease(Interface **ppInterfaceToRelease)
Definition
Direct2dViewer.h:54
__ImageBase
EXTERN_C IMAGE_DOS_HEADER __ImageBase
Definition
Direct2dViewer.h:76
Direct2dViewer::showNewBitmap
void showNewBitmap(void *addr, UINT width, UINT height)
Show a new bitmap in 2d viewer.
Definition
Direct2dViewer.cpp:563
Direct2dViewer::~Direct2dViewer
~Direct2dViewer()
Release resources.
Definition
Direct2dViewer.cpp:29
Direct2dViewer::Direct2dViewer
Direct2dViewer()
Initialize members.
Definition
Direct2dViewer.cpp:13
Direct2dViewer::getWindowHandler
HWND getWindowHandler()
Returns the window handler of 2d viewer.
Definition
Direct2dViewer.cpp:504
Direct2dViewer::GetGammaBlack
UINT16 GetGammaBlack()
return gamma value black
Definition
Direct2dViewer.cpp:535
Direct2dViewer::start2dViewer
HRESULT start2dViewer(HWND hWndParent, void *bitmapAddr, UINT width, UINT height)
Starts 2d viewer with a initial bitmap. Use this to start 2d viewer. Call constructor before.
Definition
Direct2dViewer.cpp:548
Direct2dViewer::GetGammaWhite
UINT16 GetGammaWhite()
return gamma value white
Definition
Direct2dViewer.cpp:527
Direct2dViewer::repaintWindow
void repaintWindow()
Reload the displayed bitmap in 2d viewer.
Definition
Direct2dViewer.cpp:575
Direct2dViewer::SetGammaValue
void SetGammaValue(UINT16 white, UINT16 black)
Set gamma value.
Definition
Direct2dViewer.cpp:514
Generated by
1.17.0