• R/O
  • SSH
  • HTTPS

dataviewer: Commit


Commit MetaInfo

Révision21 (tree)
l'heure2013-10-06 20:18:15
Auteurberupon

Message de Log

changed call to WinAPI function, it seems like GetKeyState doesn't support Mouse. GetAsyncKeyState does though
changed the word "line offset" to "line stride"
added "pixel stride" to support various data formats
added minimum & maximum values for single component pixel formats to adjust image rendering
added signed integer single component types
applied VisualStyle

Change Summary

Modification

--- trunk/stdafx.h (revision 20)
+++ trunk/stdafx.h (revision 21)
@@ -48,3 +48,12 @@
4848 #include "fastdelegate.h"
4949 #include "PathUtility.h"
5050
51+#if defined _M_IX86
52+ #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
53+#elif defined _M_IA64
54+ #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
55+#elif defined _M_X64
56+ #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
57+#else
58+ #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
59+#endif
--- trunk/SettingDialog_2D.cpp (revision 20)
+++ trunk/SettingDialog_2D.cpp (revision 21)
@@ -13,20 +13,23 @@
1313
1414 #include "Setting.h"
1515
16-struct ColorFormatTypeMapper : public TwoWayMap<CString, DataSetting2D::ColorFormatType>
16+struct ColorFormatTypeMapper : public TwoWayMap<CString, ColorFormatType>
1717 {
1818 ColorFormatTypeMapper()
1919 {
20- map(CString("B5G6R5"), DataSetting2D::ColorFormatType_B5G6R5);
21- map(CString("B8G8R8"), DataSetting2D::ColorFormatType_B8G8R8);
22- map(CString("B8G8R8A8"), DataSetting2D::ColorFormatType_B8G8R8A8);
23-// map(CString("16F"), DataSetting2D::ColorFormatType_16F);
24- map(CString("32F"), DataSetting2D::ColorFormatType_32F);
25- map(CString("64F"), DataSetting2D::ColorFormatType_64F);
26- map(CString("1"), DataSetting2D::ColorFormatType_1);
27- map(CString("8"), DataSetting2D::ColorFormatType_8);
28- map(CString("16"), DataSetting2D::ColorFormatType_16);
29- map(CString("32"), DataSetting2D::ColorFormatType_32);
20+ map(CString("B5G6R5"), ColorFormatType_B5G6R5);
21+ map(CString("B8G8R8"), ColorFormatType_B8G8R8);
22+ map(CString("B8G8R8A8"), ColorFormatType_B8G8R8A8);
23+// map(CString("F16"), ColorFormatType_F16);
24+ map(CString("F32"), ColorFormatType_F32);
25+ map(CString("F64"), ColorFormatType_F64);
26+ map(CString("1"), ColorFormatType_1);
27+ map(CString("U8"), ColorFormatType_U8);
28+ map(CString("U16"), ColorFormatType_U16);
29+ map(CString("U32"), ColorFormatType_U32);
30+ map(CString("S8"), ColorFormatType_S8);
31+ map(CString("S16"), ColorFormatType_S16);
32+ map(CString("S32"), ColorFormatType_S32);
3033 }
3134 };
3235
@@ -49,12 +52,10 @@
4952 {
5053 DoDataExchange();
5154
52- for (int i=DataSetting2D::ColorFormatType_Begin; i<=DataSetting2D::ColorFormatType_End; ++i) {
53- m_wndCmbColorFormat.AddString(colorFormatTypeMapper[(DataSetting2D::ColorFormatType)i]);
55+ for (int i=ColorFormatType_Begin; i<=ColorFormatType_End; ++i) {
56+ m_wndCmbColorFormat.AddString(colorFormatTypeMapper[(ColorFormatType)i]);
5457 }
55-
5658 m_wndRadAddressedLineFirst.Click();
57-
5859 return 1; // Let the system set the focus
5960 }
6061
@@ -71,6 +72,13 @@
7172 return 0;
7273 }
7374
75+ColorFormatType CSettingDialog_2D::getColorFormat()
76+{
77+ CString str;
78+ m_wndCmbColorFormat.GetLBText(m_wndCmbColorFormat.GetCurSel(), str);
79+ return colorFormatTypeMapper[str];
80+}
81+
7482 void CSettingDialog_2D::RetrieveSetting(boost::shared_ptr<IDataSetting>& pSetting)
7583 {
7684 DataSetting2D* ps = new DataSetting2D;
@@ -84,9 +92,14 @@
8492 }else if (IsDlgButtonChecked(IDC_RAD_ADDRESSEDLINE_LAST) == BST_CHECKED) {
8593 ps->addressedLine = DataSetting2D::AddressedLine_Last;
8694 }
87- m_wndEdtLineOffset.GetWindowText(ps->lineOffsetFormula, Count(ps->lineOffsetFormula));
88- m_wndCmbColorFormat.GetLBText(m_wndCmbColorFormat.GetCurSel(), str);
89- ps->colorFormat = colorFormatTypeMapper[str];
95+ ps->colorFormat = getColorFormat();
96+
97+ ps->bUsePixelStride = (IsDlgButtonChecked(IDC_CHK_PIXEL_STRIDE) == BST_CHECKED);
98+ m_wndEdtPixelStride.GetWindowText(ps->pixelStrideFormula, Count(ps->pixelStrideFormula));
99+ ps->bUseLineStride = (IsDlgButtonChecked(IDC_CHK_LINE_STRIDE) == BST_CHECKED);
100+ m_wndEdtLineStride.GetWindowText(ps->lineStrideFormula, Count(ps->lineStrideFormula));
101+ m_wndEdtMinimum.GetWindowText(ps->minimumFormula, Count(ps->minimumFormula));
102+ m_wndEdtMaximum.GetWindowText(ps->maximumFormula, Count(ps->maximumFormula));
90103 }
91104
92105 void CSettingDialog_2D::SetSetting(const DataSetting2D& setting)
@@ -104,7 +117,55 @@
104117 CheckDlgButton(IDC_RAD_ADDRESSEDLINE_LAST, BST_CHECKED);
105118 break;
106119 }
107- m_wndEdtLineOffset.SetWindowTextW(setting.lineOffsetFormula);
108120 m_wndCmbColorFormat.SelectString(-1, colorFormatTypeMapper[setting.colorFormat]);
121+ CheckDlgButton(IDC_CHK_PIXEL_STRIDE, setting.bUsePixelStride);
122+ m_wndEdtPixelStride.EnableWindow(setting.bUsePixelStride);
123+ m_wndEdtPixelStride.SetWindowTextW(setting.pixelStrideFormula);
124+ CheckDlgButton(IDC_CHK_LINE_STRIDE, setting.bUseLineStride);
125+ m_wndEdtLineStride.EnableScrollBar(setting.bUseLineStride);
126+ m_wndEdtLineStride.SetWindowTextW(setting.lineStrideFormula);
127+ m_wndEdtMinimum.SetWindowTextW(setting.minimumFormula);
128+ m_wndEdtMaximum.SetWindowTextW(setting.maximumFormula);
129+ setMinMaxEditsEnability();
109130 }
110131
132+LRESULT CSettingDialog_2D::OnBnClickedChkPixelStride(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
133+{
134+ GetDlgItem(IDC_EDT_PIXEL_STRIDE).EnableWindow(IsDlgButtonChecked(IDC_CHK_PIXEL_STRIDE) == BST_CHECKED);
135+ return 0;
136+}
137+
138+LRESULT CSettingDialog_2D::OnBnClickedChkLineStride(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
139+{
140+ GetDlgItem(IDC_EDT_LINE_STRIDE).EnableWindow(IsDlgButtonChecked(IDC_CHK_LINE_STRIDE) == BST_CHECKED);
141+ return 0;
142+}
143+
144+LRESULT CSettingDialog_2D::OnBnClickedButton4(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
145+{
146+ return 0;
147+}
148+
149+LRESULT CSettingDialog_2D::OnBnClickedButton16(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
150+{
151+ return 0;
152+}
153+
154+LRESULT CSettingDialog_2D::OnBnClickedButton64(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
155+{
156+ return 0;
157+}
158+
159+void CSettingDialog_2D::setMinMaxEditsEnability()
160+{
161+ ColorFormatType fmt = getColorFormat();
162+ BOOL enable = (fmt == ColorFormatType_1) ? false : IsSingleComponent(fmt);
163+ m_wndEdtMinimum.EnableWindow(enable);
164+ m_wndEdtMaximum.EnableWindow(enable);
165+}
166+
167+LRESULT CSettingDialog_2D::OnCbnSelchangeCmbColorformat(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
168+{
169+ setMinMaxEditsEnability();
170+ return 0;
171+}
--- trunk/Setting.h (revision 20)
+++ trunk/Setting.h (revision 21)
@@ -70,6 +70,29 @@
7070 int GetAddressOffset() const { return 0; }
7171 };
7272
73+enum ColorFormatType
74+{
75+ ColorFormatType_B5G6R5,
76+ ColorFormatType_B8G8R8,
77+ ColorFormatType_B8G8R8A8,
78+// ColorFormatType_16F,
79+ ColorFormatType_F32,
80+ ColorFormatType_F64,
81+ ColorFormatType_1,
82+ ColorFormatType_U8,
83+ ColorFormatType_U16,
84+ ColorFormatType_U32,
85+ ColorFormatType_S8,
86+ ColorFormatType_S16,
87+ ColorFormatType_S32,
88+
89+ ColorFormatType_Begin = 0,
90+ ColorFormatType_End = ColorFormatType_S32,
91+};
92+
93+size_t GetByteSize(ColorFormatType t);
94+bool IsSingleComponent(ColorFormatType t);
95+
7396 struct DataSetting2D : public IDataSetting
7497 {
7598 enum AddressedLine
@@ -78,28 +101,16 @@
78101 AddressedLine_Last,
79102 };
80103
81- enum ColorFormatType
82- {
83- ColorFormatType_B5G6R5,
84- ColorFormatType_B8G8R8,
85- ColorFormatType_B8G8R8A8,
86-// ColorFormatType_16F,
87- ColorFormatType_32F,
88- ColorFormatType_64F,
89- ColorFormatType_1,
90- ColorFormatType_8,
91- ColorFormatType_16,
92- ColorFormatType_32,
93-
94- ColorFormatType_Begin = 0,
95- ColorFormatType_End = ColorFormatType_32,
96- };
97-
98104 TCHAR widthFormula[128];
99105 TCHAR heightFormula[128];
100- TCHAR lineOffsetFormula[128];
106+ bool bUsePixelStride;
107+ TCHAR pixelStrideFormula[128];
108+ bool bUseLineStride;
109+ TCHAR lineStrideFormula[128];
101110 AddressedLine addressedLine;
102111 ColorFormatType colorFormat;
112+ TCHAR minimumFormula[128];
113+ TCHAR maximumFormula[128];
103114
104115 size_t GetTotalBytes() const;
105116 int GetAddressOffset() const;
--- trunk/resource.h (revision 20)
+++ trunk/resource.h (revision 21)
@@ -10,7 +10,6 @@
1010 #define IDD_DLG_1D 202
1111 #define IDD_DLG_2D 203
1212 #define IDD_DLG_TEXT 204
13-#define IDD_DLG_MEMORY 207
1413 #define IDD_DLG_PROCESS 207
1514 #define IDD_DLG_FILE 208
1615 #define IDC_RAD_INT 1000
@@ -48,6 +47,7 @@
4847 #define IDC_TAB_SRC 1027
4948 #define IDC_EDIT1 1043
5049 #define IDC_EDT_WIDTH 1043
50+#define IDC_EDT_MINIMUM 1044
5151 #define IDC_COMBO1 1046
5252 #define IDC_CMB_TARGETTYPE 1046
5353 #define IDC_CMB_TYPE 1046
@@ -58,10 +58,13 @@
5858 #define IDC_EDT_HEIGHT 1048
5959 #define IDC_EDIT3 1049
6060 #define IDC_EDT_LINEOFFSET 1049
61+#define IDC_EDT_LINE_STRIDE 1049
6162 #define IDC_RADIO19 1050
6263 #define IDC_RAD_ADDRESSEDLINE_FIRST 1050
6364 #define IDC_EDT_TARGETADDRESS 1051
6465 #define IDC_EDT_TARGETSTRUCTUREADDRESS 1051
66+#define IDC_EDT_HEIGHT2 1051
67+#define IDC_EDT_MAXIMUM 1051
6568 #define IDC_BTN_READTARGET 1052
6669 #define IDC_BTN_READTARGETSTRUCTURE 1052
6770 #define IDC_COMBO3 1053
@@ -75,6 +78,12 @@
7578 #define IDC_BTN_PASTE 1057
7679 #define IDC_EDT_BYTES 1057
7780 #define IDC_EDT_FILEPATH 1058
81+#define IDC_EDT_PIXEL_STRIDE 1059
82+#define IDC_BUTTON_16 1061
83+#define IDC_BUTTON_4 1062
84+#define IDC_BUTTON_64 1063
85+#define IDC_CHK_LINE_STRIDE 1064
86+#define IDC_CHK_PIXEL_STRIDE 1065
7887 #define ID_UPDATE 32772
7988 #define ID_VIEW_ALWAYSONTOP 32776
8089 #define ID_ZOOM 32777
@@ -92,7 +101,7 @@
92101 #ifndef APSTUDIO_READONLY_SYMBOLS
93102 #define _APS_NEXT_RESOURCE_VALUE 207
94103 #define _APS_NEXT_COMMAND_VALUE 32789
95-#define _APS_NEXT_CONTROL_VALUE 1059
104+#define _APS_NEXT_CONTROL_VALUE 1065
96105 #define _APS_NEXT_SYMED_VALUE 101
97106 #endif
98107 #endif
--- trunk/DataViewerCommon.cpp (revision 20)
+++ trunk/DataViewerCommon.cpp (revision 21)
@@ -23,7 +23,11 @@
2323 std::string s = ConvertToMString(formula);
2424 parser.SetExpr(s.c_str());
2525 }
26- return parser.Eval();
26+ try {
27+ return parser.Eval();
28+ }catch (...) {
29+ return 0;
30+ }
2731 }
2832
2933 bool ReadProcessData(HANDLE hProcess, LPCVOID pTarget, void* buffer, size_t fetchSize)
--- trunk/DataView.cpp (revision 20)
+++ trunk/DataView.cpp (revision 21)
@@ -19,11 +19,6 @@
1919 typedef gl::fixed<32, unsigned int> Fixed32;
2020 typedef gl::Color4< gl::ColorBGRA<Fixed8> > ColorB8G8R8A8;
2121 typedef gl::Color3< gl::ColorBGR<Fixed8> > ColorB8G8R8;
22-typedef gl::Color1<float> Color32F;
23-typedef gl::Color1<double> Color64F;
24-typedef gl::Color1<Fixed8> ColorFixed8;
25-typedef gl::Color1<Fixed16> ColorFixed16;
26-typedef gl::Color1<Fixed32> ColorFixed32;
2722
2823 #define STATIC_ASSERT(expr) { char dummy[(expr) ? 1 : 0]; }
2924
@@ -45,6 +40,7 @@
4540 template <typename T>
4641 ColorB8G8R8A8 convert(ColorB5G6R5 from)
4742 {
43+ STATIC_ASSERT(sizeof(ColorB5G6R5) == 2);
4844 ColorB8G8R8A8 to;
4945 to.r.value = from.r << 3;
5046 to.g.value = from.g << 2;
@@ -52,7 +48,16 @@
5248 return to;
5349 }
5450
55-gl::ColorConverter<ColorB8G8R8A8> colorConverter;
51+template <typename T>
52+ColorB8G8R8A8 convert(double from)
53+{
54+ ColorB8G8R8A8 to;
55+ uint8_t v = (from * 255.0 + 0.5);
56+ to.r.value = v;
57+ to.g.value = v;
58+ to.b.value = v;
59+ return to;
60+}
5661
5762 #include "MathUtil.h"
5863
@@ -72,7 +77,14 @@
7277
7378 bool CDataView::isMouseClicked()
7479 {
75- return GetCapture() == m_hWnd && GetKeyState(GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON) < 0;
80+ HWND hWndCap = GetCapture();
81+ if (hWndCap == m_hWnd) {
82+ const int chkBtn = GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON;
83+ SHORT state = GetAsyncKeyState(chkBtn);
84+ bool bClicked = state < 0;
85+ return bClicked;
86+ }
87+ return false;
7688 }
7789
7890 CDataView::CDataView()
@@ -213,51 +225,40 @@
213225 int height = EvalFormula(setting.heightFormula);
214226 if (height <= 0)
215227 return;
216- int lineOffset = EvalFormula(setting.lineOffsetFormula);
217- if (lineOffset == 0)
218- return;
219-
228+
229+ int pixelStride;
230+ size_t colorFormatPixelSize = GetByteSize(setting.colorFormat);
231+ if (setting.bUsePixelStride) {
232+ pixelStride = EvalFormula(setting.pixelStrideFormula);
233+ if (pixelStride <= 0 || pixelStride < colorFormatPixelSize) {
234+ return;
235+ }
236+ }else {
237+ pixelStride = colorFormatPixelSize;
238+ }
239+
220240 size_t lineBytes = 0;
221- switch (setting.colorFormat) {
222- case DataSetting2D::ColorFormatType_B5G6R5:
223- lineBytes = width * 2;
224- break;
225- case DataSetting2D::ColorFormatType_B8G8R8:
226- lineBytes = width * 3;
227- break;
228- case DataSetting2D::ColorFormatType_B8G8R8A8:
229- case DataSetting2D::ColorFormatType_32F:
230- lineBytes = width * 4;
231- break;
232- case DataSetting2D::ColorFormatType_64F:
233- lineBytes = width * 8;
234- break;
235- case DataSetting2D::ColorFormatType_1:
241+ if (setting.colorFormat == ColorFormatType_1) {
236242 lineBytes = width / 8 + ((width % 8) ? 1 : 0);
237- break;
238- case DataSetting2D::ColorFormatType_8:
239- lineBytes = width;
240- break;
241- case DataSetting2D::ColorFormatType_16:
242- lineBytes = width * 2;
243- break;
244- case DataSetting2D::ColorFormatType_32:
245- lineBytes = width * 4;
246- break;
247- default:
248- return;
243+ }else {
244+ lineBytes = width * pixelStride;
249245 }
250- if (abs(lineOffset) < lineBytes)
246+
247+ int lineStride = setting.bUseLineStride ? EvalFormula(setting.lineStrideFormula) : lineBytes;
248+ if (lineStride == 0)
251249 return;
252- if (abs(lineOffset)*height != dataBytes)
250+
251+ if (abs(lineStride) < lineBytes)
253252 return;
253+ if (abs(lineStride)*height != dataBytes)
254+ return;
254255
255256 const char* pFirstLine = NULL;
256257 switch (setting.addressedLine) {
257258 case DataSetting2D::AddressedLine_Last:
258259 case DataSetting2D::AddressedLine_First:
259- if (lineOffset < 0) {
260- pFirstLine = pData + -lineOffset * (height - 1);
260+ if (lineStride < 0) {
261+ pFirstLine = pData + -lineStride * (int)(height - 1);
261262 }else {
262263 pFirstLine = pData;
263264 }
@@ -277,38 +278,52 @@
277278 }
278279 m_imgWidth = width;
279280 m_imgHeight = height;
281+ gl::Buffer2D<ColorB8G8R8A8>& img = *(gl::Buffer2D<ColorB8G8R8A8>*)m_pImage;
280282
281- STATIC_ASSERT(sizeof(ColorB5G6R5) == 2);
282-
283- gl::Buffer2D<ColorB8G8R8A8>& img = *(gl::Buffer2D<ColorB8G8R8A8>*)m_pImage;
284- switch (setting.colorFormat) {
285- case DataSetting2D::ColorFormatType_B5G6R5:
286- gl::BitBlockTransfer(gl::Buffer2D<ColorB5G6R5>(width, height, lineOffset, (void*)pFirstLine), img, 0,0,0,0,width,height, colorConverter);
287- break;
288- case DataSetting2D::ColorFormatType_B8G8R8:
289- gl::BitBlockTransfer(gl::Buffer2D<ColorB8G8R8>(width, height, lineOffset, (void*)pFirstLine), img, 0,0,0,0,width,height, colorConverter);
290- break;
291- case DataSetting2D::ColorFormatType_B8G8R8A8:
292- gl::BitBlockTransfer(gl::Buffer2D<ColorB8G8R8A8>(width, height, lineOffset, (void*)pFirstLine), img, 0,0,0,0,width,height, colorConverter);
293- break;
294- case DataSetting2D::ColorFormatType_32F:
295- gl::BitBlockTransfer(gl::Buffer2D<Color32F>(width, height, lineOffset, (void*)pFirstLine), img, 0,0,0,0,width,height, colorConverter);
296- break;
297- case DataSetting2D::ColorFormatType_64F:
298- gl::BitBlockTransfer(gl::Buffer2D<Color64F>(width, height, lineOffset, (void*)pFirstLine), img, 0,0,0,0,width,height, colorConverter);
299- break;
300- case DataSetting2D::ColorFormatType_1:
301- gl::BitBlockTransfer(gl::Buffer2D<bool>(width, height, lineOffset, (void*)pFirstLine), img, 0,0,0,0,width,height, colorConverter);
302- break;
303- case DataSetting2D::ColorFormatType_8:
304- gl::BitBlockTransfer(gl::Buffer2D<ColorFixed8>(width, height, lineOffset, (void*)pFirstLine), img, 0,0,0,0,width,height, colorConverter);
305- break;
306- case DataSetting2D::ColorFormatType_16:
307- gl::BitBlockTransfer(gl::Buffer2D<ColorFixed16>(width, height, lineOffset, (void*)pFirstLine), img, 0,0,0,0,width,height, colorConverter);
308- break;
309- case DataSetting2D::ColorFormatType_32:
310- gl::BitBlockTransfer(gl::Buffer2D<ColorFixed32>(width, height, lineOffset, (void*)pFirstLine), img, 0,0,0,0,width,height, colorConverter);
311- break;
283+ if (setting.colorFormat != ColorFormatType_1 && IsSingleComponent(setting.colorFormat)) {
284+ gl::ColorConverterMinMax<ColorB8G8R8A8> colorConverter(EvalFormula(setting.minimumFormula), EvalFormula(setting.maximumFormula));
285+ switch (setting.colorFormat) {
286+ case ColorFormatType_F32:
287+ gl::BitBlockTransfer(gl::Buffer2D<float>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
288+ break;
289+ case ColorFormatType_F64:
290+ gl::BitBlockTransfer(gl::Buffer2D<double>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
291+ break;
292+ case ColorFormatType_U8:
293+ gl::BitBlockTransfer(gl::Buffer2D<uint8_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
294+ break;
295+ case ColorFormatType_U16:
296+ gl::BitBlockTransfer(gl::Buffer2D<uint16_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
297+ break;
298+ case ColorFormatType_U32:
299+ gl::BitBlockTransfer(gl::Buffer2D<uint32_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
300+ break;
301+ case ColorFormatType_S8:
302+ gl::BitBlockTransfer(gl::Buffer2D<int8_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
303+ break;
304+ case ColorFormatType_S16:
305+ gl::BitBlockTransfer(gl::Buffer2D<int16_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
306+ break;
307+ case ColorFormatType_S32:
308+ gl::BitBlockTransfer(gl::Buffer2D<int32_t>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
309+ break;
310+ }
311+ }else {
312+ gl::ColorConverter<ColorB8G8R8A8> colorConverter;
313+ switch (setting.colorFormat) {
314+ case ColorFormatType_1:
315+ gl::BitBlockTransfer(gl::Buffer2D<bool>(width, height, lineStride, (void*)pFirstLine), img, 0,0,0,0,width,height, colorConverter);
316+ break;
317+ case ColorFormatType_B5G6R5:
318+ gl::BitBlockTransfer(gl::Buffer2D<ColorB5G6R5>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
319+ break;
320+ case ColorFormatType_B8G8R8:
321+ gl::BitBlockTransfer(gl::Buffer2D<ColorB8G8R8>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
322+ break;
323+ case ColorFormatType_B8G8R8A8:
324+ gl::BitBlockTransfer(gl::Buffer2D<ColorB8G8R8A8>(width, height, lineStride, (void*)pFirstLine), pixelStride, img, 0,0,0,0,width,height, colorConverter);
325+ break;
326+ }
312327 }
313328
314329 }
@@ -563,7 +578,7 @@
563578 static
564579 bool fetchData(
565580 const boost::shared_ptr<SourceSetting>& pSrcSetting,
566- size_t dataLength, int dataAddressOffset,
581+ size_t dataLength,
567582 std::vector<char>& data
568583 )
569584 {
@@ -574,7 +589,6 @@
574589
575590 ptrdiff_t addressBase = AddressHexStrToNum(pSrcSetting->addressBaseFormula);
576591 ptrdiff_t addressOffset = EvalFormula(pSrcSetting->addressOffsetFormula) * pSrcSetting->addressOffsetMultiplier;
577- addressOffset += dataAddressOffset;
578592 ptrdiff_t address = addressBase + addressOffset;
579593
580594 const type_info& ti = typeid(*pSrcSetting);
@@ -610,7 +624,6 @@
610624 fetchData(
611625 pSrcSetting,
612626 pDataSetting->GetTotalBytes(),
613- pDataSetting->GetAddressOffset(),
614627 m_data
615628 )
616629 ) {
--- trunk/common/gl/bitBlockTransfer.h (revision 20)
+++ trunk/common/gl/bitBlockTransfer.h (revision 21)
@@ -40,7 +40,8 @@
4040 // TODO: need to fix. runs too slow...
4141 template <typename ConverterT, typename SrcColorT, typename TargetColorT>
4242 void BitBlockTransfer(
43- const Buffer2D<SrcColorT>& src, Buffer2D<TargetColorT>& target,
43+ const Buffer2D<SrcColorT>& src, size_t pixelStride,
44+ Buffer2D<TargetColorT>& target,
4445 int srcX, int srcY, int targetX, int targetY,
4546 size_t width, size_t height,
4647 ConverterT& converter
@@ -104,7 +105,8 @@
104105 pTarget2 = pTarget;
105106 for (size_t x=0; x<width; ++x) {
106107 *pTarget2 = converter(*pSrc2);
107- ++pSrc2;
108+ pSrc2 = (const SrcColorT*) (((const char*)pSrc2)+pixelStride);
109+// ++pSrc2;
108110 ++pTarget2;
109111 }
110112 OffsetPtr(pSrc, srcLineOffset);
--- trunk/common/gl/colorConverter.h (revision 20)
+++ trunk/common/gl/colorConverter.h (revision 21)
@@ -47,6 +47,29 @@
4747
4848 };
4949
50+template <typename TargetColorT>
51+struct ColorConverterMinMax
52+{
53+ ColorConverterMinMax(double minimum, double maximum)
54+ :
55+ minimum(minimum),
56+ maximum(maximum),
57+ invRange(1.0 / (maximum - minimum))
58+ {
59+ }
60+ __forceinline TargetColorT operator () (double from)
61+ {
62+ double nv = (from - minimum) * invRange;
63+ nv = max(0.0, nv);
64+ nv = min(1.0, nv);
65+ return convert<TargetColorT>(nv);
66+ }
67+
68+ double minimum;
69+ double maximum;
70+ double invRange;
71+};
72+
5073 template <typename NumericT, typename ValueT, size_t tableSize>
5174 struct TableLookupHelper
5275 {
--- trunk/Setting.cpp (revision 20)
+++ trunk/Setting.cpp (revision 21)
@@ -66,23 +66,27 @@
6666
6767 size_t DataSetting2D::GetTotalBytes() const
6868 {
69+ int width = abs(EvalFormula(widthFormula));
6970 int height = abs(EvalFormula(heightFormula));
70- int lineOffset = EvalFormula(lineOffsetFormula);
71- return height * abs(lineOffset);
71+ int lineStride = bUseLineStride ? EvalFormula(lineStrideFormula) : (width * GetByteSize(colorFormat));
72+ return height * abs(lineStride);
7273 }
7374
7475 int DataSetting2D::GetAddressOffset() const
7576 {
76- int lineOffset = EvalFormula(lineOffsetFormula);
77+ if (!bUseLineStride) {
78+ return 0;
79+ }
80+ int lineStride = EvalFormula(lineStrideFormula);
7781 int height = EvalFormula(heightFormula);
7882 if (addressedLine == AddressedLine_First) {
79- if (lineOffset < 0) {
80- return lineOffset * (height - 1);
83+ if (lineStride < 0) {
84+ return lineStride * (height - 1);
8185 }else {
8286 return 0;
8387 }
8488 }else {
85- return -1 * lineOffset * (height - 1);
89+ return -1 * lineStride * (height - 1);
8690 }
8791 }
8892
@@ -107,3 +111,53 @@
107111 addressOffsetMultiplier = 1;
108112 }
109113
114+size_t GetByteSize(ColorFormatType t)
115+{
116+ switch (t) {
117+ case ColorFormatType_B5G6R5:
118+ return 2;
119+ case ColorFormatType_B8G8R8:
120+ return 3;
121+ case ColorFormatType_B8G8R8A8:
122+ case ColorFormatType_F32:
123+ return 4;
124+ case ColorFormatType_F64:
125+ return 8;
126+ case ColorFormatType_1:
127+ return 0;
128+ break;
129+ case ColorFormatType_U8:
130+ case ColorFormatType_S8:
131+ return 1;
132+ case ColorFormatType_U16:
133+ case ColorFormatType_S16:
134+ return 2;
135+ case ColorFormatType_U32:
136+ case ColorFormatType_S32:
137+ return 4;
138+ default:
139+ return 0;
140+ }
141+}
142+
143+bool IsSingleComponent(ColorFormatType t)
144+{
145+ switch (t) {
146+ case ColorFormatType_B5G6R5:
147+ case ColorFormatType_B8G8R8:
148+ case ColorFormatType_B8G8R8A8:
149+ return false;
150+ case ColorFormatType_F32:
151+ case ColorFormatType_F64:
152+ case ColorFormatType_1:
153+ case ColorFormatType_U8:
154+ case ColorFormatType_U16:
155+ case ColorFormatType_U32:
156+ case ColorFormatType_S8:
157+ case ColorFormatType_S16:
158+ case ColorFormatType_S32:
159+ return true;
160+ default:
161+ return false;
162+ }
163+}
\ No newline at end of file
--- trunk/SettingDialog_2D.h (revision 20)
+++ trunk/SettingDialog_2D.h (revision 21)
@@ -20,10 +20,20 @@
2020 void RetrieveSetting(boost::shared_ptr<IDataSetting>& pSetting);
2121 void SetSetting(const DataSetting2D& setting);
2222
23+private:
24+ enum ColorFormatType getColorFormat();
25+ void setMinMaxEditsEnability();
26+
2327 BEGIN_MSG_MAP(CSettingDialog_2D)
2428 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
2529 COMMAND_HANDLER(IDOK, BN_CLICKED, OnClickedOK)
2630 COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnClickedCancel)
31+ COMMAND_HANDLER(IDC_BUTTON_4, BN_CLICKED, OnBnClickedButton4)
32+ COMMAND_HANDLER(IDC_BUTTON_16, BN_CLICKED, OnBnClickedButton16)
33+ COMMAND_HANDLER(IDC_BUTTON_64, BN_CLICKED, OnBnClickedButton64)
34+ COMMAND_HANDLER(IDC_CHK_PIXEL_STRIDE, BN_CLICKED, OnBnClickedChkPixelStride)
35+ COMMAND_HANDLER(IDC_CHK_LINE_STRIDE, BN_CLICKED, OnBnClickedChkLineStride)
36+ COMMAND_HANDLER(IDC_CMB_COLORFORMAT, CBN_SELCHANGE, OnCbnSelchangeCmbColorformat)
2737 END_MSG_MAP()
2838
2939 BEGIN_DDX_MAP(CSettingDialog_2D)
@@ -31,17 +41,22 @@
3141 DDX_CONTROL_HANDLE(IDC_EDT_HEIGHT, m_wndEdtHeight)
3242 DDX_CONTROL_HANDLE(IDC_RAD_ADDRESSEDLINE_FIRST, m_wndRadAddressedLineFirst)
3343 DDX_CONTROL_HANDLE(IDC_RAD_ADDRESSEDLINE_LAST, m_wndRadAddressedLineLast)
34- DDX_CONTROL_HANDLE(IDC_EDT_LINEOFFSET, m_wndEdtLineOffset)
3544 DDX_CONTROL_HANDLE(IDC_CMB_COLORFORMAT, m_wndCmbColorFormat)
45+ DDX_CONTROL_HANDLE(IDC_EDT_PIXEL_STRIDE, m_wndEdtPixelStride)
46+ DDX_CONTROL_HANDLE(IDC_EDT_LINE_STRIDE, m_wndEdtLineStride)
47+ DDX_CONTROL_HANDLE(IDC_EDT_MINIMUM, m_wndEdtMinimum)
48+ DDX_CONTROL_HANDLE(IDC_EDT_MAXIMUM, m_wndEdtMaximum)
3649 END_DDX_MAP()
3750
38-private:
3951 CEdit m_wndEdtWidth;
4052 CEdit m_wndEdtHeight;
4153 CButton m_wndRadAddressedLineFirst;
4254 CButton m_wndRadAddressedLineLast;
43- CEdit m_wndEdtLineOffset;
4455 CComboBox m_wndCmbColorFormat;
56+ CEdit m_wndEdtPixelStride;
57+ CEdit m_wndEdtLineStride;
58+ CEdit m_wndEdtMinimum;
59+ CEdit m_wndEdtMaximum;
4560
4661 // Handler prototypes:
4762 // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
@@ -50,7 +65,12 @@
5065 LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
5166 LRESULT OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
5267 LRESULT OnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
53-
68+ LRESULT OnBnClickedChkPixelStride(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
69+ LRESULT OnBnClickedChkLineStride(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
70+ LRESULT OnBnClickedButton4(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
71+ LRESULT OnBnClickedButton16(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
72+ LRESULT OnBnClickedButton64(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
73+ LRESULT OnCbnSelchangeCmbColorformat(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
5474 };
5575
5676
Afficher sur ancien navigateur de dépôt.