From 151e519df10e6d9317b5931aa5a403f968ef4941 Mon Sep 17 00:00:00 2001 From: Simon Smith Date: Mon, 6 Mar 2023 09:00:47 +0000 Subject: [PATCH] Refactor Of Header Files Split up headers, predefine where we can, and use precompiled headers to speed up compile times. Includes some CString/QString changes to aid in the above where only a simple change was needed. --- ChartCtrl/ChartAxis.cpp | 3 +- ChartCtrl/ChartAxis.h | 13 - ChartCtrl/ChartAxisLabel.h | 10 - ChartCtrl/ChartCtrl.cpp | 3 + ChartCtrl/ChartCtrl.h | 27 +- ChartCtrl/ChartObject.h | 11 - ChartCtrl/ChartSerie.cpp | 2 - ChartCtrl/ChartSerie.h | 16 +- ChartCtrl/ChartSurfaceSerie.cpp | 3 +- ChartCtrl/ChartSurfaceSerie.h | 7 - DeepSkyStacker.VS2019.sln | 18 +- DeepSkyStacker/AHDDemosaicing.cpp | 12 +- DeepSkyStacker/AHDDemosaicing.h | 3 + DeepSkyStacker/About.cpp | 35 +- DeepSkyStacker/AlignmentParameters.cpp | 7 +- DeepSkyStacker/AlignmentParameters.h | 7 +- DeepSkyStacker/AskRegistering.h | 1 + DeepSkyStacker/BackgroundCalibration.cpp | 2 + DeepSkyStacker/BackgroundCalibration.h | 6 + DeepSkyStacker/BatchStacking.cpp | 16 +- DeepSkyStacker/Bayer.cpp | 172 ++ DeepSkyStacker/Bayer.h | 23 + DeepSkyStacker/BezierAdjust.h | 3 +- DeepSkyStacker/BilinearParameters.cpp | 266 ++ DeepSkyStacker/BilinearParameters.h | 49 + DeepSkyStacker/BitMapFiller.cpp | 6 +- DeepSkyStacker/BitMapFiller.h | 13 +- DeepSkyStacker/BitmapBase.cpp | 98 +- DeepSkyStacker/BitmapBase.h | 2496 +---------------- DeepSkyStacker/BitmapCharacteristics.h | 41 + DeepSkyStacker/BitmapConstants.h | 1 + DeepSkyStacker/BitmapExt.cpp | 862 +++--- DeepSkyStacker/BitmapExt.h | 801 +----- DeepSkyStacker/BitmapExtraInfo.h | 56 + DeepSkyStacker/BitmapInfo.cpp | 211 ++ DeepSkyStacker/BitmapInfo.h | 59 + DeepSkyStacker/BitmapIterator.h | 4 +- DeepSkyStacker/BitmapPartFile.h | 46 + DeepSkyStacker/CFABitmapInfo.h | 117 + DeepSkyStacker/ChannelAlign.cpp | 2 + DeepSkyStacker/ChannelAlign.h | 5 +- DeepSkyStacker/CheckAbove.cpp | 1 - DeepSkyStacker/CheckAbove.h | 3 - DeepSkyStacker/ColorBitmap.cpp | 294 ++ DeepSkyStacker/ColorBitmap.h | 145 + DeepSkyStacker/ColorHelpers.cpp | 254 ++ DeepSkyStacker/ColorHelpers.h | 12 + DeepSkyStacker/ColorMultiBitmap.cpp | 220 ++ DeepSkyStacker/ColorMultiBitmap.h | 30 + DeepSkyStacker/ColorRef.h | 48 + DeepSkyStacker/CometStacking.cpp | 11 +- DeepSkyStacker/CometStacking.h | 6 +- DeepSkyStacker/CosmeticEngine.cpp | 16 +- DeepSkyStacker/CosmeticEngine.h | 7 +- DeepSkyStacker/DSS-versionhelpers.h | 1 + DeepSkyStacker/DSSCommon.h | 11 +- DeepSkyStacker/DSSProgress.cpp | 1 - DeepSkyStacker/DSSProgress.h | 10 +- DeepSkyStacker/DSSTools.cpp | 2 + DeepSkyStacker/DSSTools.h | 650 +---- DeepSkyStacker/DarkFrame.cpp | 32 +- DeepSkyStacker/DarkFrame.h | 41 +- DeepSkyStacker/DeBloom.cpp | 10 +- DeepSkyStacker/DeBloom.h | 19 +- DeepSkyStacker/DeepSkyStacker.cpp | 146 +- DeepSkyStacker/DeepSkyStacker.h | 166 +- DeepSkyStacker/DeepSkyStacker.rc | 44 +- DeepSkyStacker/DeepSkyStacker.vcxproj | 118 +- DeepSkyStacker/DeepSkyStacker.vcxproj.filters | 130 +- DeepSkyStacker/DeepStack.cpp | 13 +- DeepSkyStacker/DeepStack.h | 32 +- DeepSkyStacker/Delaunay.cpp | 2 +- DeepSkyStacker/DropFilesDlg.cpp | 10 +- DeepSkyStacker/DropFilesDlg.h | 3 - DeepSkyStacker/DynamicStats.h | 78 + DeepSkyStacker/EntropyInfo.cpp | 80 +- DeepSkyStacker/EntropyInfo.h | 83 +- DeepSkyStacker/ExceptionHandling.cpp | 4 +- DeepSkyStacker/ExplorerBar.cpp | 38 +- DeepSkyStacker/ExplorerBar.h | 3 - DeepSkyStacker/ExtraInfo.h | 55 + DeepSkyStacker/FITSUtil.cpp | 59 +- DeepSkyStacker/FITSUtil.h | 16 +- DeepSkyStacker/File.cpp | 20 + DeepSkyStacker/File.h | 3 + DeepSkyStacker/FileProperty.h | 3 +- DeepSkyStacker/Filters.cpp | 18 +- DeepSkyStacker/Filters.h | 24 +- DeepSkyStacker/FlatFrame.cpp | 30 +- DeepSkyStacker/FlatFrame.h | 32 +- DeepSkyStacker/FlatPart.h | 52 + DeepSkyStacker/FrameInfo.cpp | 142 +- DeepSkyStacker/FrameInfo.h | 138 +- DeepSkyStacker/FrameInfoSupport.h | 2 +- DeepSkyStacker/FrameList.cpp | 1363 ++++----- DeepSkyStacker/FrameList.h | 83 +- DeepSkyStacker/GrayBitmap.cpp | 573 ++++ DeepSkyStacker/GrayBitmap.h | 199 ++ DeepSkyStacker/GreyMultiBitmap.cpp | 158 ++ DeepSkyStacker/GreyMultiBitmap.h | 30 + DeepSkyStacker/Histogram.h | 7 +- DeepSkyStacker/ImageListModel.cpp | 17 - DeepSkyStacker/ImageListModel.h | 11 - DeepSkyStacker/ImageSinks.cpp | 10 +- DeepSkyStacker/ImageSinks.h | 19 +- DeepSkyStacker/IntermediateFiles.cpp | 15 +- DeepSkyStacker/IntermediateFiles.h | 7 +- DeepSkyStacker/LinearInterpolationh.h | 53 + DeepSkyStacker/LuminanceTab.cpp | 2 - DeepSkyStacker/LuminanceTab.h | 21 +- DeepSkyStacker/MasterFrames.cpp | 11 + DeepSkyStacker/MasterFrames.h | 41 +- DeepSkyStacker/MatchingStars.cpp | 7 +- DeepSkyStacker/MatchingStars.h | 11 +- DeepSkyStacker/MedianFilterEngine.cpp | 6 + DeepSkyStacker/MedianFilterEngine.h | 101 +- DeepSkyStacker/MemoryBitmap.cpp | 46 + DeepSkyStacker/MemoryBitmap.h | 213 ++ DeepSkyStacker/MultiBitmap.h | 118 + DeepSkyStacker/MultiBitmapProcess.cpp | 27 +- DeepSkyStacker/MultiBitmapProcess.h | 7 +- DeepSkyStacker/OutputTab.cpp | 15 - DeepSkyStacker/OutputTab.h | 11 +- DeepSkyStacker/PCLTools.cpp | 296 -- DeepSkyStacker/PCLTools.h | 12 - DeepSkyStacker/PixelTransform.h | 1 + DeepSkyStacker/PostCalibration.cpp | 42 +- DeepSkyStacker/PostCalibration.h | 11 +- DeepSkyStacker/ProcessSettingsSheet.cpp | 1 - DeepSkyStacker/ProcessSettingsSheet.h | 17 - DeepSkyStacker/ProcessingDlg.cpp | 17 +- DeepSkyStacker/ProcessingDlg.h | 35 +- DeepSkyStacker/QtProgressDlg.cpp | 4 +- DeepSkyStacker/QtProgressDlg.h | 2 +- DeepSkyStacker/RAWUtils.cpp | 67 +- DeepSkyStacker/RAWUtils.h | 27 +- DeepSkyStacker/RGBTab.cpp | 3 - DeepSkyStacker/RGBTab.h | 20 +- DeepSkyStacker/RationalInterpolation.h | 57 + DeepSkyStacker/RawDDPSettings.cpp | 80 +- DeepSkyStacker/RawDDPSettings.h | 19 +- DeepSkyStacker/RecommendedSettings.cpp | 96 +- DeepSkyStacker/RecommendedSettings.h | 77 +- DeepSkyStacker/RegisterEngine.cpp | 88 +- DeepSkyStacker/RegisterEngine.h | 86 +- DeepSkyStacker/RegisterSettings.cpp | 40 +- DeepSkyStacker/RegisterSettings.h | 5 - DeepSkyStacker/ResultParameters.cpp | 17 +- DeepSkyStacker/ResultParameters.h | 9 +- DeepSkyStacker/RunningStackingEngine.cpp | 24 +- DeepSkyStacker/RunningStackingEngine.h | 6 +- DeepSkyStacker/SaturationTab.cpp | 2 - DeepSkyStacker/SaturationTab.h | 21 +- DeepSkyStacker/SaveEditChanges.cpp | 1 - DeepSkyStacker/SaveEditChanges.h | 2 - DeepSkyStacker/SavePicture.cpp | 2 +- DeepSkyStacker/SavePicture.h | 4 +- DeepSkyStacker/SetUILanguage.cpp | 4 - DeepSkyStacker/Settings.h | 5 +- DeepSkyStacker/SettingsDlg.h | 13 +- DeepSkyStacker/StackRecap.cpp | 51 +- DeepSkyStacker/StackRecap.h | 6 +- DeepSkyStacker/StackSettings.cpp | 36 +- DeepSkyStacker/StackSettings.h | 19 +- DeepSkyStacker/StackedBitmap.cpp | 34 +- DeepSkyStacker/StackedBitmap.h | 35 +- DeepSkyStacker/StackingDlg.cpp | 76 +- DeepSkyStacker/StackingDlg.h | 23 +- DeepSkyStacker/StackingEngine.cpp | 32 +- DeepSkyStacker/StackingEngine.h | 3 +- DeepSkyStacker/StackingParameters.cpp | 25 +- DeepSkyStacker/StackingParameters.h | 7 +- DeepSkyStacker/StackingTasks.cpp | 74 +- DeepSkyStacker/StackingTasks.h | 68 +- DeepSkyStacker/StarMask.cpp | 12 +- DeepSkyStacker/StarMask.h | 6 +- DeepSkyStacker/StarMaskDlg.cpp | 6 +- DeepSkyStacker/StarMaskDlg.h | 1 + DeepSkyStacker/Stars.h | 11 +- DeepSkyStacker/StdAfx.h | 111 +- DeepSkyStacker/TIFFUtil.cpp | 75 +- DeepSkyStacker/TIFFUtil.h | 73 +- DeepSkyStacker/TaskInfo.cpp | 65 + DeepSkyStacker/TaskInfo.h | 71 +- DeepSkyStacker/Workspace.cpp | 16 +- DeepSkyStacker/Workspace.h | 4 +- DeepSkyStacker/avx.cpp | 11 +- DeepSkyStacker/avx.h | 14 +- DeepSkyStacker/avx_avg.cpp | 9 +- DeepSkyStacker/avx_avg.h | 4 +- DeepSkyStacker/avx_bitmap_filler.cpp | 6 +- DeepSkyStacker/avx_bitmap_filler.h | 7 +- DeepSkyStacker/avx_cfa.cpp | 3 +- DeepSkyStacker/avx_cfa.h | 1 - DeepSkyStacker/avx_entropy.cpp | 11 +- DeepSkyStacker/avx_entropy.h | 7 +- DeepSkyStacker/avx_filter.cpp | 8 +- DeepSkyStacker/avx_histogram.cpp | 3 +- DeepSkyStacker/avx_histogram.h | 4 +- DeepSkyStacker/avx_luminance.cpp | 2 +- DeepSkyStacker/avx_output.cpp | 7 +- DeepSkyStacker/avx_output.h | 2 +- DeepSkyStacker/avx_support.cpp | 6 +- DeepSkyStacker/avx_support.h | 5 +- DeepSkyStacker/cfa.h | 71 + DeepSkyStacker/commonresource.h | 8 +- DeepSkyStacker/dslr.h | 38 + DeepSkyStacker/dss_settings.cpp | 3 - DeepSkyStacker/dss_settings.h | 2 + DeepSkyStacker/editstars.cpp | 58 +- DeepSkyStacker/editstars.h | 49 +- DeepSkyStacker/group.cpp | 191 +- DeepSkyStacker/group.h | 38 +- DeepSkyStacker/imageloader.cpp | 34 +- DeepSkyStacker/imageloader.h | 5 - DeepSkyStacker/matrix.h | 1 + DeepSkyStacker/mrulist.cpp | 2 +- DeepSkyStacker/mrupath.h | 6 - DeepSkyStacker/picturelist.h | 1 - DeepSkyStacker/resource.h | 2 +- DeepSkyStacker/resourceCZ.h | 2 +- DeepSkyStacker/resourceES.h | 2 +- DeepSkyStacker/resourceIT.h | 2 +- DeepSkyStacker/selectrect.cpp | 26 +- DeepSkyStacker/selectrect.h | 5 - DeepSkyStacker/toolbar.cpp | 12 +- DeepSkyStacker/toolbar.h | 4 - DeepSkyStackerCL/DeepSkyStackerCL.cpp | 5 + DeepSkyStackerCL/DeepSkyStackerCL.h | 2 + DeepSkyStackerCL/DeepSkyStackerCL.vcxproj | 34 +- .../DeepSkyStackerCL.vcxproj.filters | 66 + DeepSkyStackerCL/ProgressConsole.h | 192 -- DeepSkyStackerCL/stdafx.h | 49 +- DeepSkyStackerLive/DeepSkyStackerLive.cpp | 24 +- DeepSkyStackerLive/DeepSkyStackerLive.rc | 12 +- DeepSkyStackerLive/DeepSkyStackerLive.vcxproj | 32 +- .../DeepSkyStackerLive.vcxproj.filters | 186 +- DeepSkyStackerLive/DeepSkyStackerLiveCAT.rc | 10 +- DeepSkyStackerLive/DeepSkyStackerLiveCN.rc | Bin 46812 -> 46876 bytes DeepSkyStackerLive/DeepSkyStackerLiveCZ.rc | Bin 57630 -> 57694 bytes DeepSkyStackerLive/DeepSkyStackerLiveDE.rc | 10 +- DeepSkyStackerLive/DeepSkyStackerLiveDlg.cpp | 242 +- DeepSkyStackerLive/DeepSkyStackerLiveDlg.h | 256 +- DeepSkyStackerLive/DeepSkyStackerLiveES.rc | 8 +- DeepSkyStackerLive/DeepSkyStackerLiveFR.rc | 10 +- DeepSkyStackerLive/DeepSkyStackerLiveIT.rc | 10 +- DeepSkyStackerLive/DeepSkyStackerLiveNL.rc | 10 +- DeepSkyStackerLive/DeepSkyStackerLivePTB.rc | 10 +- DeepSkyStackerLive/DeepSkyStackerLiveRO.rc | 8 +- DeepSkyStackerLive/DeepSkyStackerLiveRU.rc | Bin 59764 -> 59838 bytes DeepSkyStackerLive/DeepSkyStackerLiveTR.rc | Bin 59092 -> 59166 bytes DeepSkyStackerLive/GraphView.cpp | 119 +- DeepSkyStackerLive/GraphView.h | 133 +- DeepSkyStackerLive/ImageList.cpp | 8 +- DeepSkyStackerLive/ImageView.cpp | 10 +- DeepSkyStackerLive/ImageView.h | 27 +- DeepSkyStackerLive/LiveEngine.cpp | 41 +- DeepSkyStackerLive/LiveEngine.h | 15 +- DeepSkyStackerLive/LogTab.cpp | 4 - DeepSkyStackerLive/LogTab.h | 12 +- DeepSkyStackerLive/MainBoard.cpp | 24 +- DeepSkyStackerLive/MainBoard.h | 16 +- DeepSkyStackerLive/Settings.cpp | 7 +- DeepSkyStackerLive/Settings.h | 21 +- DeepSkyStackerLive/StackedSink.cpp | 8 +- DeepSkyStackerLive/StackedSink.h | 3 +- DeepSkyStackerLive/resource.h | 8 +- DeepSkyStackerLive/stdafx.h | 113 +- DeepSkyStackerTest/AvxAccumulateTest.cpp | 6 +- DeepSkyStackerTest/AvxCfaTest.cpp | 16 +- DeepSkyStackerTest/AvxEntropyTest.cpp | 49 +- DeepSkyStackerTest/AvxHistogramTest.cpp | 28 +- DeepSkyStackerTest/AvxStackingTest.cpp | 7 +- DeepSkyStackerTest/BitMapFillerTest.cpp | 4 +- DeepSkyStackerTest/DeepSkyStackerTest.vcxproj | 24 + .../DeepSkyStackerTest.vcxproj.filters | 72 + DeepSkyStackerTest/OpenMpTest.cpp | 4 +- DeepSkyStackerTest/PixelIteratorTest.cpp | 2 +- DeepSkyStackerTest/stdafx.h | 30 +- SMTP/resource.h | 2 +- Tools/ButtonToolbar.cpp | 4 +- Tools/ButtonToolbar.h | 3 - Tools/ControlPos.cpp | 2 +- Tools/CtrlCache.h | 2 +- Tools/Gradient.h | 10 - Tools/GradientCtrl.cpp | 1 - Tools/Label.h | 14 - Tools/WndImage.cpp | 3 - Tools/WndImage.h | 1 + Tools/cdxCRot90DC.cpp | 1 + Tools/cdxCRotBevelLine.cpp | 2 +- Tools/childprop.cpp | 1 - Tools/childprop.h | 14 - Tools/gradientctrl.h | 15 - 294 files changed, 8098 insertions(+), 8872 deletions(-) create mode 100644 DeepSkyStacker/Bayer.cpp create mode 100644 DeepSkyStacker/Bayer.h create mode 100644 DeepSkyStacker/BilinearParameters.cpp create mode 100644 DeepSkyStacker/BilinearParameters.h create mode 100644 DeepSkyStacker/BitmapCharacteristics.h create mode 100644 DeepSkyStacker/BitmapConstants.h create mode 100644 DeepSkyStacker/BitmapExtraInfo.h create mode 100644 DeepSkyStacker/BitmapInfo.cpp create mode 100644 DeepSkyStacker/BitmapInfo.h create mode 100644 DeepSkyStacker/BitmapPartFile.h create mode 100644 DeepSkyStacker/CFABitmapInfo.h create mode 100644 DeepSkyStacker/ColorBitmap.cpp create mode 100644 DeepSkyStacker/ColorBitmap.h create mode 100644 DeepSkyStacker/ColorHelpers.cpp create mode 100644 DeepSkyStacker/ColorHelpers.h create mode 100644 DeepSkyStacker/ColorMultiBitmap.cpp create mode 100644 DeepSkyStacker/ColorMultiBitmap.h create mode 100644 DeepSkyStacker/ColorRef.h create mode 100644 DeepSkyStacker/DSSTools.cpp create mode 100644 DeepSkyStacker/DynamicStats.h create mode 100644 DeepSkyStacker/ExtraInfo.h create mode 100644 DeepSkyStacker/File.cpp create mode 100644 DeepSkyStacker/File.h create mode 100644 DeepSkyStacker/FlatPart.h create mode 100644 DeepSkyStacker/GrayBitmap.cpp create mode 100644 DeepSkyStacker/GrayBitmap.h create mode 100644 DeepSkyStacker/GreyMultiBitmap.cpp create mode 100644 DeepSkyStacker/GreyMultiBitmap.h create mode 100644 DeepSkyStacker/LinearInterpolationh.h create mode 100644 DeepSkyStacker/MemoryBitmap.cpp create mode 100644 DeepSkyStacker/MemoryBitmap.h create mode 100644 DeepSkyStacker/MultiBitmap.h delete mode 100644 DeepSkyStacker/PCLTools.cpp delete mode 100644 DeepSkyStacker/PCLTools.h create mode 100644 DeepSkyStacker/RationalInterpolation.h create mode 100644 DeepSkyStacker/TaskInfo.cpp create mode 100644 DeepSkyStacker/cfa.h create mode 100644 DeepSkyStacker/dslr.h delete mode 100644 DeepSkyStackerCL/ProgressConsole.h diff --git a/ChartCtrl/ChartAxis.cpp b/ChartCtrl/ChartAxis.cpp index 8e61b313b..c959d1aa7 100644 --- a/ChartCtrl/ChartAxis.cpp +++ b/ChartCtrl/ChartAxis.cpp @@ -30,8 +30,7 @@ #include "ChartAxisLabel.h" #include "ChartGrid.h" #include "ChartCtrl.h" - -#include "Math.h" +#include "ChartSerie.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction diff --git a/ChartCtrl/ChartAxis.h b/ChartCtrl/ChartAxis.h index 4f0eea2f6..93b33a42e 100644 --- a/ChartCtrl/ChartAxis.h +++ b/ChartCtrl/ChartAxis.h @@ -18,19 +18,8 @@ * * */ - -#if !defined(AFX_CHARTAXIS_H__063D695C_43CF_4A46_8AA0_C7E00268E0D3__INCLUDED_) -#define AFX_CHARTAXIS_H__063D695C_43CF_4A46_8AA0_C7E00268E0D3__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 - #include "ChartObject.h" -#include - -#include -#include class CChartGrid; class CChartSerie; @@ -168,5 +157,3 @@ class CChartAxis : public CChartObject COLORREF m_TextColor; }; - -#endif // !defined(AFX_CHARTAXIS_H__063D695C_43CF_4A46_8AA0_C7E00268E0D3__INCLUDED_) diff --git a/ChartCtrl/ChartAxisLabel.h b/ChartCtrl/ChartAxisLabel.h index 2de5d414a..105287940 100644 --- a/ChartCtrl/ChartAxisLabel.h +++ b/ChartCtrl/ChartAxisLabel.h @@ -18,17 +18,9 @@ * * */ - -#if !defined(AFX_CHARTAXISLABEL_H__0E5519C8_A2F4_4CED_9681_32A56B25D0C5__INCLUDED_) -#define AFX_CHARTAXISLABEL_H__0E5519C8_A2F4_4CED_9681_32A56B25D0C5__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #include "ChartObject.h" -#include - class CChartAxis; @@ -59,5 +51,3 @@ class CChartAxisLabel : public CChartObject std::string m_strFontName; std::string m_strLabelText; }; - -#endif // !defined(AFX_CHARTAXISLABEL_H__0E5519C8_A2F4_4CED_9681_32A56B25D0C5__INCLUDED_) diff --git a/ChartCtrl/ChartCtrl.cpp b/ChartCtrl/ChartCtrl.cpp index 263398daf..6aecbb869 100644 --- a/ChartCtrl/ChartCtrl.cpp +++ b/ChartCtrl/ChartCtrl.cpp @@ -40,6 +40,9 @@ #include "ChartLineSerie.h" #include "ChartPointsSerie.h" #include "ChartSurfaceSerie.h" +#include "ChartLegend.h" +#include "ChartTitle.h" +#include "ChartAxis.h" #define CHARTCTRL_CLASSNAME "ChartCtrl" // Window class name diff --git a/ChartCtrl/ChartCtrl.h b/ChartCtrl/ChartCtrl.h index f687b9c58..9bc192ae2 100644 --- a/ChartCtrl/ChartCtrl.h +++ b/ChartCtrl/ChartCtrl.h @@ -18,28 +18,15 @@ * * */ - - -#if !defined(AFX_CHARTCTRL_H__5DDBAE42_77C3_4344_A207_3F39B623343B__INCLUDED_) -#define AFX_CHARTCTRL_H__5DDBAE42_77C3_4344_A207_3F39B623343B__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 - -#include "ChartSerie.h" -#include "ChartAxis.h" -#include "ChartGrid.h" -#include "ChartLegend.h" -#include "ChartTitle.h" - -#include - ///////////////////////////////////////////////////////////////////////////// // CChartCtrl window - +class CChartLegend; +class CChartTitle; +class CChartAxis; +class CChartSerie; class CChartCtrl : public CWnd { @@ -125,9 +112,3 @@ class CChartCtrl : public CWnd CRect m_rectZoomArea; }; -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CHARTCTRL_H__5DDBAE42_77C3_4344_A207_3F39B623343B__INCLUDED_) diff --git a/ChartCtrl/ChartObject.h b/ChartCtrl/ChartObject.h index 4b0142c1f..5e12c6ff2 100644 --- a/ChartCtrl/ChartObject.h +++ b/ChartCtrl/ChartObject.h @@ -18,16 +18,7 @@ * * */ - -#if !defined(AFX_CHARTOBJECT_H__6ED024F2_00D9_45D5_AB83_258EF0075288__INCLUDED_) -#define AFX_CHARTOBJECT_H__6ED024F2_00D9_45D5_AB83_258EF0075288__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 - -#include -#include class CChartCtrl; @@ -97,5 +88,3 @@ class CChartObject virtual void Draw(CDC* pDC) = 0; }; - -#endif // !defined(AFX_CHARTOBJECT_H__6ED024F2_00D9_45D5_AB83_258EF0075288__INCLUDED_) diff --git a/ChartCtrl/ChartSerie.cpp b/ChartCtrl/ChartSerie.cpp index 58745fa9b..1fa3d2355 100644 --- a/ChartCtrl/ChartSerie.cpp +++ b/ChartCtrl/ChartSerie.cpp @@ -27,8 +27,6 @@ #include "ChartAxis.h" #include "ChartCtrl.h" -#include "Math.h" - ////////////////////////////////////////////////////////////////////// // Construction/Destruction diff --git a/ChartCtrl/ChartSerie.h b/ChartCtrl/ChartSerie.h index 33c0305f5..234b04ef7 100644 --- a/ChartCtrl/ChartSerie.h +++ b/ChartCtrl/ChartSerie.h @@ -18,26 +18,14 @@ * * */ - -#if !defined(AFX_CHARTSERIE_H__FFCF0E32_10E7_4A4D_9FF3_3C6177EDE4B1__INCLUDED_) -#define AFX_CHARTSERIE_H__FFCF0E32_10E7_4A4D_9FF3_3C6177EDE4B1__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #include "ChartObject.h" -#include "ChartAxis.h" - -#include -#include class CChartLineSerie; class CChartPointsSerie; class CChartLegend; - - - +class CChartAxis; class CChartSerie : public CChartObject { friend CChartCtrl; @@ -106,5 +94,3 @@ class CChartSerie : public CChartObject virtual void Draw(CDC* pDC) =0; virtual void DrawAll(CDC *pDC) =0; }; - -#endif // !defined(AFX_CHARTSERIE_H__FFCF0E32_10E7_4A4D_9FF3_3C6177EDE4B1__INCLUDED_) diff --git a/ChartCtrl/ChartSurfaceSerie.cpp b/ChartCtrl/ChartSurfaceSerie.cpp index ab4c2651a..2382e29f3 100644 --- a/ChartCtrl/ChartSurfaceSerie.cpp +++ b/ChartCtrl/ChartSurfaceSerie.cpp @@ -5,8 +5,7 @@ #include "stdafx.h" #include "ChartSurfaceSerie.h" #include "ChartCtrl.h" - -#include +#include "ChartAxis.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction diff --git a/ChartCtrl/ChartSurfaceSerie.h b/ChartCtrl/ChartSurfaceSerie.h index 9783b5276..d2599aa4c 100644 --- a/ChartCtrl/ChartSurfaceSerie.h +++ b/ChartCtrl/ChartSurfaceSerie.h @@ -2,12 +2,7 @@ // ////////////////////////////////////////////////////////////////////// -#if !defined(AFX_CHARTSURFACESERIE_H__28A77823_43BD_4502_9AA7_A2B227454035__INCLUDED_) -#define AFX_CHARTSURFACESERIE_H__28A77823_43BD_4502_9AA7_A2B227454035__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #include "ChartSerie.h" @@ -69,5 +64,3 @@ class CChartSurfaceSerie : public CChartSerie // the curve and the corresponding vertical axis) bool m_bHorizontal; }; - -#endif // !defined(AFX_CHARTSURFACESERIE_H__28A77823_43BD_4502_9AA7_A2B227454035__INCLUDED_) diff --git a/DeepSkyStacker.VS2019.sln b/DeepSkyStacker.VS2019.sln index 2085d07c1..985c22c67 100644 --- a/DeepSkyStacker.VS2019.sln +++ b/DeepSkyStacker.VS2019.sln @@ -9,19 +9,19 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeepSkyStackerCL", "DeepSky ProjectSection(ProjectDependencies) = postProject {1747F255-9CB9-472B-8FEE-9E0BBFBAD49D} = {1747F255-9CB9-472B-8FEE-9E0BBFBAD49D} {A2F500C6-6903-4C2D-906D-CE86B99BA50D} = {A2F500C6-6903-4C2D-906D-CE86B99BA50D} - {767E57ED-6D37-32A1-B51E-C39E7C1CD02A} = {767E57ED-6D37-32A1-B51E-C39E7C1CD02A} + {A71D2131-F425-381F-8A9A-29D60132A046} = {A71D2131-F425-381F-8A9A-29D60132A046} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeepSkyStackerLive", "DeepSkyStackerLive\DeepSkyStackerLive.vcxproj", "{6290D6C2-900F-496C-A522-D5C8BF807066}" ProjectSection(ProjectDependencies) = postProject {D5FB2402-A821-4474-91E7-07F0DD5866F0} = {D5FB2402-A821-4474-91E7-07F0DD5866F0} {A2F500C6-6903-4C2D-906D-CE86B99BA50D} = {A2F500C6-6903-4C2D-906D-CE86B99BA50D} - {767E57ED-6D37-32A1-B51E-C39E7C1CD02A} = {767E57ED-6D37-32A1-B51E-C39E7C1CD02A} + {A71D2131-F425-381F-8A9A-29D60132A046} = {A71D2131-F425-381F-8A9A-29D60132A046} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeepSkyStacker", "DeepSkyStacker\DeepSkyStacker.vcxproj", "{90721C24-BC43-450A-ADED-3417280D075B}" ProjectSection(ProjectDependencies) = postProject - {767E57ED-6D37-32A1-B51E-C39E7C1CD02A} = {767E57ED-6D37-32A1-B51E-C39E7C1CD02A} + {A71D2131-F425-381F-8A9A-29D60132A046} = {A71D2131-F425-381F-8A9A-29D60132A046} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjpg", "libjpg\libjpg.vcxproj", "{A2F500C6-6903-4C2D-906D-CE86B99BA50D}" @@ -30,7 +30,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtiff", "LibTiff\libtiff. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZCLass", "ZCLass\ZCLass.vcxproj", "{1747F255-9CB9-472B-8FEE-9E0BBFBAD49D}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libraw", "LibRaw\buildfiles\libraw.vcxproj", "{767E57ED-6D37-32A1-B51E-C39E7C1CD02A}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libraw", "LibRaw\buildfiles\libraw.vcxproj", "{A71D2131-F425-381F-8A9A-29D60132A046}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6E9EC8B1-5EAC-4F7F-8989-EFED16DA4B7A}" EndProject @@ -69,10 +69,10 @@ Global {1747F255-9CB9-472B-8FEE-9E0BBFBAD49D}.Debug|x64.Build.0 = Debug|x64 {1747F255-9CB9-472B-8FEE-9E0BBFBAD49D}.Release|x64.ActiveCfg = Release|x64 {1747F255-9CB9-472B-8FEE-9E0BBFBAD49D}.Release|x64.Build.0 = Release|x64 - {767E57ED-6D37-32A1-B51E-C39E7C1CD02A}.Debug|x64.ActiveCfg = Debug|x64 - {767E57ED-6D37-32A1-B51E-C39E7C1CD02A}.Debug|x64.Build.0 = Debug|x64 - {767E57ED-6D37-32A1-B51E-C39E7C1CD02A}.Release|x64.ActiveCfg = Release|x64 - {767E57ED-6D37-32A1-B51E-C39E7C1CD02A}.Release|x64.Build.0 = Release|x64 + {A71D2131-F425-381F-8A9A-29D60132A046}.Debug|x64.ActiveCfg = Debug|x64 + {A71D2131-F425-381F-8A9A-29D60132A046}.Debug|x64.Build.0 = Debug|x64 + {A71D2131-F425-381F-8A9A-29D60132A046}.Release|x64.ActiveCfg = Release|x64 + {A71D2131-F425-381F-8A9A-29D60132A046}.Release|x64.Build.0 = Release|x64 {487E5070-BF81-4DEF-BE9F-510EEACE627B}.Debug|x64.ActiveCfg = Debug|x64 {487E5070-BF81-4DEF-BE9F-510EEACE627B}.Debug|x64.Build.0 = Debug|x64 {487E5070-BF81-4DEF-BE9F-510EEACE627B}.Release|x64.ActiveCfg = Release|x64 @@ -85,7 +85,7 @@ Global {A2F500C6-6903-4C2D-906D-CE86B99BA50D} = {A8F4069D-F6D1-4A9A-A4E5-9A22B411D691} {D5FB2402-A821-4474-91E7-07F0DD5866F0} = {A8F4069D-F6D1-4A9A-A4E5-9A22B411D691} {1747F255-9CB9-472B-8FEE-9E0BBFBAD49D} = {A8F4069D-F6D1-4A9A-A4E5-9A22B411D691} - {767E57ED-6D37-32A1-B51E-C39E7C1CD02A} = {A8F4069D-F6D1-4A9A-A4E5-9A22B411D691} + {A71D2131-F425-381F-8A9A-29D60132A046} = {A8F4069D-F6D1-4A9A-A4E5-9A22B411D691} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {64F56483-090C-45A4-9437-FC1753EF3BA5} diff --git a/DeepSkyStacker/AHDDemosaicing.cpp b/DeepSkyStacker/AHDDemosaicing.cpp index 630e7673d..7c78f970a 100644 --- a/DeepSkyStacker/AHDDemosaicing.cpp +++ b/DeepSkyStacker/AHDDemosaicing.cpp @@ -1,11 +1,15 @@ #include -#include "resource.h" -#include "BitmapExt.h" -#include "AHDDemosaicing.h" #include -#include "DSSProgress.h" #include +#include "AHDDemosaicing.h" +#include "ColorBitmap.h" +#include "Ztrace.h" +#include "DSSProgress.h" +#include "Multitask.h" +#include "ColorHelpers.h" +#include "DSSTools.h" +using namespace DSS; static std::vector g_vLUT; diff --git a/DeepSkyStacker/AHDDemosaicing.h b/DeepSkyStacker/AHDDemosaicing.h index cfcd59ad3..6b2bb1e50 100644 --- a/DeepSkyStacker/AHDDemosaicing.h +++ b/DeepSkyStacker/AHDDemosaicing.h @@ -1,6 +1,9 @@ #ifndef __AHDDEMOSAICING_H__ #define __AHDDEMOSAICING_H__ +#include "GrayBitmap.h" +namespace DSS { class ProgressBase; } +using namespace DSS; template bool AHDDemosaicing(CGrayBitmapT * pGrayInputBitmap, std::shared_ptr& rpColorBitmap, ProgressBase* pProgress); diff --git a/DeepSkyStacker/About.cpp b/DeepSkyStacker/About.cpp index f4cbc88c8..c8be85254 100644 --- a/DeepSkyStacker/About.cpp +++ b/DeepSkyStacker/About.cpp @@ -1,39 +1,16 @@ -#include -using std::min; -using std::max; - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "commonresource.h" +#include "stdafx.h" #include "About.h" #include "ui/ui_About.h" +#include "DSSVersion.h" +#include "libraw/libraw_version.h" +#include "fitsio.h" +#include "tiffio.h" +#include "DeepSkyStacker.h" extern bool g_bShowRefStars; extern QTranslator theAppTranslator; extern QTranslator theQtTranslator; -#include "DeepSkyStacker.h" -#include "DSSCommon.h" -#include "commonresource.h" -#include "DSSVersion.h" -#include -#include -#include - #define xstr(s) str(s) #define str(s) #s diff --git a/DeepSkyStacker/AlignmentParameters.cpp b/DeepSkyStacker/AlignmentParameters.cpp index 01858c18b..3d64fbabb 100644 --- a/DeepSkyStacker/AlignmentParameters.cpp +++ b/DeepSkyStacker/AlignmentParameters.cpp @@ -1,11 +1,8 @@ +#include "stdafx.h" #include "AlignmentParameters.h" #include "ui/ui_AlignmentParameters.h" - -#include -#include - -#include "DSSCommon.h" #include "Workspace.h" +#include "DSSCommon.h" AlignmentParameters::AlignmentParameters(QWidget *parent) : QWidget(parent), diff --git a/DeepSkyStacker/AlignmentParameters.h b/DeepSkyStacker/AlignmentParameters.h index 8a312e843..254a972a3 100644 --- a/DeepSkyStacker/AlignmentParameters.h +++ b/DeepSkyStacker/AlignmentParameters.h @@ -1,7 +1,4 @@ -#ifndef ALIGNMENTPARAMETERS_H -#define ALIGNMENTPARAMETERS_H - -#include +#pragma once class Workspace; @@ -42,5 +39,3 @@ private slots: private: }; - -#endif // ALIGNMENTPARAMETERS_H diff --git a/DeepSkyStacker/AskRegistering.h b/DeepSkyStacker/AskRegistering.h index 4ec1740b7..72c9c05d7 100644 --- a/DeepSkyStacker/AskRegistering.h +++ b/DeepSkyStacker/AskRegistering.h @@ -1,5 +1,6 @@ #ifndef __ASKREGISTERING_H__ #define __ASKREGISTERING_H__ +#include "commonresource.h" typedef enum tagASKREGISTERINGANSWER { diff --git a/DeepSkyStacker/BackgroundCalibration.cpp b/DeepSkyStacker/BackgroundCalibration.cpp index 4b1c617ee..7f8046e42 100644 --- a/DeepSkyStacker/BackgroundCalibration.cpp +++ b/DeepSkyStacker/BackgroundCalibration.cpp @@ -6,6 +6,8 @@ #include "DSSProgress.h" #include "StackingTasks.h" #include "avx_histogram.h" +#include "Multitask.h" +#include "Ztrace.h" CBackgroundCalibration::CBackgroundCalibration() : m_bInitOk{ false }, diff --git a/DeepSkyStacker/BackgroundCalibration.h b/DeepSkyStacker/BackgroundCalibration.h index 3b68517f9..3464d9f53 100644 --- a/DeepSkyStacker/BackgroundCalibration.h +++ b/DeepSkyStacker/BackgroundCalibration.h @@ -1,6 +1,12 @@ #ifndef __BACKGROUNDCALIBRATION_H__ #define __BACKGROUNDCALIBRATION_H__ +#include "DSSCommon.h" +#include "RationalInterpolation.h" +#include "LinearInterpolationh.h" +class CMemoryBitmap; +namespace DSS { class ProgressBase; } +using namespace DSS; class CBackgroundCalibration { diff --git a/DeepSkyStacker/BatchStacking.cpp b/DeepSkyStacker/BatchStacking.cpp index 9b2a81ae2..277b174ff 100644 --- a/DeepSkyStacker/BatchStacking.cpp +++ b/DeepSkyStacker/BatchStacking.cpp @@ -1,24 +1,16 @@ // BatchStacking.cpp : implementation file // - #include "stdafx.h" #include "BatchStacking.h" - - #include "ui/ui_BatchStacking.h" - -#include "StackingTasks.h" +#include "Ztrace.h" #include "Workspace.h" +#include "StackingTasks.h" #include "FrameList.h" #include "QtProgressDlg.h" #include "StackingEngine.h" -#include "DeepSkyStacker.h" - -#include -#include -#include -#include -#include +#include "TIFFUtil.h" +#include "FITSUtil.h" namespace { diff --git a/DeepSkyStacker/Bayer.cpp b/DeepSkyStacker/Bayer.cpp new file mode 100644 index 000000000..03a7c8746 --- /dev/null +++ b/DeepSkyStacker/Bayer.cpp @@ -0,0 +1,172 @@ +#include "stdafx.h" +#include "Bayer.h" + +BAYERCOLOR GetBayerColor(size_t baseX, size_t baseY, CFATYPE CFAType, int xOffset/*=0*/, int yOffset/*=0*/) +{ + const size_t x = baseX + xOffset; // Apply the X Bayer offset if supplied + const size_t y = baseY + yOffset; // Apply the Y Bayer offset if supplied + + switch (CFAType) + { + case CFATYPE_NONE: + return BAYER_UNKNOWN; + break; + case CFATYPE_BGGR: + if (x & 1) + { + if (y & 1) + return BAYER_RED; + else + return BAYER_GREEN; + } + else + { + if (y & 1) + return BAYER_GREEN; + else + return BAYER_BLUE; + }; + break; + case CFATYPE_GRBG: + if (x & 1) + { + if (y & 1) + return BAYER_GREEN; + else + return BAYER_RED; + } + else + { + if (y & 1) + return BAYER_BLUE; + else + return BAYER_GREEN; + }; + break; + case CFATYPE_GBRG: + if (x & 1) + { + if (y & 1) + return BAYER_GREEN; + else + return BAYER_BLUE; + } + else + { + if (y & 1) + return BAYER_RED; + else + return BAYER_GREEN; + }; + break; + case CFATYPE_RGGB: + if (x & 1) + { + if (y & 1) + return BAYER_BLUE; + else + return BAYER_GREEN; + } + else + { + if (y & 1) + return BAYER_GREEN; + else + return BAYER_RED; + }; + break; + default: + { // CYMG Type + if (IsSimpleCYMG(CFAType)) + { + // 2 lines and 2 columns repeated pattern + if (y & 1) + { + if (x & 1) + return (BAYERCOLOR)(CFAType & 0xF); + else + return (BAYERCOLOR)((CFAType >> 4) & 0xF); + } + else + { + if (x & 1) + return (BAYERCOLOR)((CFAType >> 8) & 0xF); + else + return (BAYERCOLOR)((CFAType >> 12) & 0xF); + }; + } + else + { + // 4 lines and 2 columns repeated pattern + if (y % 4 == 0) + { + if (x & 1) + return (BAYERCOLOR)((CFAType >> 24) & 0xF); + else + return (BAYERCOLOR)((CFAType >> 28) & 0xF); + } + else if (y % 4 == 1) + { + if (x & 1) + return (BAYERCOLOR)((CFAType >> 16) & 0xF); + else + return (BAYERCOLOR)((CFAType >> 20) & 0xF); + } + else if (y % 4 == 2) + { + if (x & 1) + return (BAYERCOLOR)((CFAType >> 8) & 0xF); + else + return (BAYERCOLOR)((CFAType >> 12) & 0xF); + } + else + { + if (x & 1) + return (BAYERCOLOR)((CFAType >> 0) & 0xF); + else + return (BAYERCOLOR)((CFAType >> 4) & 0xF); + }; + }; + }; + }; + return BAYER_UNKNOWN; +} + +// +// Add parameter yOffset to specify CFA Matrix offset to be applied (for FITS files) +// +bool IsBayerBlueLine(size_t baseY, CFATYPE CFAType, int yOffset /* = 0 */) +{ + size_t y = baseY + yOffset; + + if ((CFAType == CFATYPE_GRBG) || (CFAType == CFATYPE_RGGB)) + return (y & 1) ? true : false; + else + return (y & 1) ? false : true; +} + +// +// Add parameter xOffset to specify CFA Matrix offset to be applied (for FITS files) +// +bool IsBayerBlueColumn(size_t baseX, CFATYPE CFAType, int xOffset /* = 0 */) +{ + size_t x = baseX + xOffset; + + if ((CFAType == CFATYPE_GBRG) || (CFAType == CFATYPE_RGGB)) + return (x & 1) ? true : false; + else + return (x & 1) ? false : true; +} + +bool IsBayerRedLine(size_t baseY, CFATYPE CFAType, int yOffset /* = 0 */) +{ + return !IsBayerBlueLine(baseY, CFAType, yOffset); +} + +// +// Add parameter xOffset to specify CFA Matrix offset to be applied (for FITS files) +// +bool IsBayerRedColumn(size_t baseX, CFATYPE CFAType, int xOffset /* = 0 */) +{ + return !IsBayerBlueColumn(baseX, CFAType, xOffset); +} diff --git a/DeepSkyStacker/Bayer.h b/DeepSkyStacker/Bayer.h new file mode 100644 index 000000000..209471a92 --- /dev/null +++ b/DeepSkyStacker/Bayer.h @@ -0,0 +1,23 @@ +#pragma once +#include "cfa.h" + +typedef enum +{ + BAYER_UNKNOWN = 0, + BAYER_RED = 1, + BAYER_GREEN = 2, + BAYER_BLUE = 3, + BAYER_CYAN = 0xA, + BAYER_GREEN2 = 0xB, + BAYER_MAGENTA = 0xC, + BAYER_YELLOW = 0xD, + BAYER_NRCOLORS = 0xD + 1 +} BAYERCOLOR; + +inline int CMYGZeroIndex(BAYERCOLOR Color) { return Color - BAYER_CYAN; } + +BAYERCOLOR GetBayerColor(size_t baseX, size_t baseY, CFATYPE CFAType, int xOffset = 0, int yOffset = 0); +bool IsBayerBlueLine(size_t baseY, CFATYPE CFAType, int yOffset = 0); +bool IsBayerBlueColumn(size_t baseX, CFATYPE CFAType, int xOffset = 0); +bool IsBayerRedLine(size_t baseY, CFATYPE CFAType, int yOffset = 0); +bool IsBayerRedColumn(size_t baseX, CFATYPE CFAType, int xOffset = 0); diff --git a/DeepSkyStacker/BezierAdjust.h b/DeepSkyStacker/BezierAdjust.h index 1fd2ea484..a0ffd49fc 100644 --- a/DeepSkyStacker/BezierAdjust.h +++ b/DeepSkyStacker/BezierAdjust.h @@ -1,7 +1,8 @@ #ifndef _BEZIERADJUST_H__ #define _BEZIERADJUST_H__ /* ------------------------------------------------------------------- */ -#undef PI +//#undef PI +#include "DSSCommon.h" class CBezierCurvePoint { diff --git a/DeepSkyStacker/BilinearParameters.cpp b/DeepSkyStacker/BilinearParameters.cpp new file mode 100644 index 000000000..4a959662e --- /dev/null +++ b/DeepSkyStacker/BilinearParameters.cpp @@ -0,0 +1,266 @@ +#include "stdafx.h" +#include "BilinearParameters.h" + +void CBilinearParameters::Clear() noexcept +{ + Type = TT_BILINEAR; + a0 = a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0.0; + a9 = a10 = a11 = a12 = a13 = a14 = a15 = 0.0; + b0 = b1 = b2 = b3 = b4 = b5 = b6 = b7 = b8 = 0.0; + b9 = b10 = b11 = b12 = b13 = b14 = b15 = 0.0; + a1 = 1.0; // to have x' = x + b2 = 1.0; // to have y' = y + + fXWidth = fYWidth = 1.0; +} + +bool CBilinearParameters::GetNextParameter(CString& strParameters, double& fValue) const +{ + bool bResult = false; + int nPos; + CString strValue; + + if (strParameters.GetLength()) + { + nPos = strParameters.Find(_T(",")); + if (nPos >= 0) + strValue = strParameters.Left(nPos); + else + strValue = strParameters; + + fValue = _ttof((LPCTSTR)strValue); // Change _ttof to _ttof for Unicode + strParameters = strParameters.Right(std::max(0, strParameters.GetLength() - strValue.GetLength() - 1)); + bResult = true; + }; + + return bResult; +} + +void CBilinearParameters::ToText(CString& strText) const +{ + if (Type == TT_NONE) + { + strText.Format(_T("None(%.20g,%.20g)"), fXWidth, fYWidth); + } + else if (Type == TT_BICUBIC) + { + CString strText1; + + strText1.Format(_T("Bicubic(%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,"), + a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); + strText = strText1; + + strText1.Format(_T("%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,"), + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15); + strText += strText1; + strText1.Format(_T("%.20g,%.20g)"), + fXWidth, fYWidth); + strText += strText1; + } + else if (Type == TT_BISQUARED) + { + CString strText1; + + strText1.Format(_T("Bisquared(%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,"), + a0, a1, a2, a3, a4, a5, a6, a7, a8); + strText = strText1; + + strText1.Format(_T("%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g)"), + b0, b1, b2, b3, b4, b5, b6, b7, b8, + fXWidth, fYWidth); + strText += strText1; + } + else + { + strText.Format(_T("Bilinear(%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g)"), + a0, a1, a2, a3, + b0, b1, b2, b3, + fXWidth, fYWidth); + }; +} + +bool CBilinearParameters::FromText(LPCTSTR szText) +{ + bool bResult = false; + CString strText = szText; + int nPos1, + nPos2; + + nPos1 = strText.Find(_T("(")); + nPos2 = strText.Find(_T(")")); + if (nPos1 >= 0 && nPos2 > nPos1) + { + CString strType; + CString strParameters; + + strType = strText.Left(nPos1); + strParameters = strText.Mid(nPos1 + 1, nPos2 - nPos1 - 1); + if (!strType.CompareNoCase(_T("None"))) + { + Clear(); + Type = TT_NONE; + bResult = GetNextParameter(strParameters, fXWidth) && + GetNextParameter(strParameters, fYWidth); + } + else if (!strType.CompareNoCase(_T("Bilinear"))) + { + Type = TT_BILINEAR; + bResult = GetNextParameter(strParameters, a0) && + GetNextParameter(strParameters, a1) && + GetNextParameter(strParameters, a2) && + GetNextParameter(strParameters, a3) && + GetNextParameter(strParameters, b0) && + GetNextParameter(strParameters, b1) && + GetNextParameter(strParameters, b2) && + GetNextParameter(strParameters, b3) && + GetNextParameter(strParameters, fXWidth) && + GetNextParameter(strParameters, fYWidth); + } + else if (!strType.CompareNoCase(_T("Bisquared"))) + { + Type = TT_BISQUARED; + bResult = GetNextParameter(strParameters, a0) && + GetNextParameter(strParameters, a1) && + GetNextParameter(strParameters, a2) && + GetNextParameter(strParameters, a3) && + GetNextParameter(strParameters, a4) && + GetNextParameter(strParameters, a5) && + GetNextParameter(strParameters, a6) && + GetNextParameter(strParameters, a7) && + GetNextParameter(strParameters, a8) && + GetNextParameter(strParameters, b0) && + GetNextParameter(strParameters, b1) && + GetNextParameter(strParameters, b2) && + GetNextParameter(strParameters, b3) && + GetNextParameter(strParameters, b4) && + GetNextParameter(strParameters, b5) && + GetNextParameter(strParameters, b6) && + GetNextParameter(strParameters, b7) && + GetNextParameter(strParameters, b8) && + GetNextParameter(strParameters, fXWidth) && + GetNextParameter(strParameters, fYWidth); + } + else if (!strType.CompareNoCase(_T("Bicubic"))) + { + Type = TT_BICUBIC; + bResult = GetNextParameter(strParameters, a0) && + GetNextParameter(strParameters, a1) && + GetNextParameter(strParameters, a2) && + GetNextParameter(strParameters, a3) && + GetNextParameter(strParameters, a4) && + GetNextParameter(strParameters, a5) && + GetNextParameter(strParameters, a6) && + GetNextParameter(strParameters, a7) && + GetNextParameter(strParameters, a8) && + GetNextParameter(strParameters, a9) && + GetNextParameter(strParameters, a10) && + GetNextParameter(strParameters, a11) && + GetNextParameter(strParameters, a12) && + GetNextParameter(strParameters, a13) && + GetNextParameter(strParameters, a14) && + GetNextParameter(strParameters, a15) && + GetNextParameter(strParameters, b0) && + GetNextParameter(strParameters, b1) && + GetNextParameter(strParameters, b2) && + GetNextParameter(strParameters, b3) && + GetNextParameter(strParameters, b4) && + GetNextParameter(strParameters, b5) && + GetNextParameter(strParameters, b6) && + GetNextParameter(strParameters, b7) && + GetNextParameter(strParameters, b8) && + GetNextParameter(strParameters, b9) && + GetNextParameter(strParameters, b10) && + GetNextParameter(strParameters, b11) && + GetNextParameter(strParameters, b12) && + GetNextParameter(strParameters, b13) && + GetNextParameter(strParameters, b14) && + GetNextParameter(strParameters, b15) && + GetNextParameter(strParameters, fXWidth) && + GetNextParameter(strParameters, fYWidth); + }; + }; + + return bResult; +} +QPointF CBilinearParameters::transform(const QPointF& pt) const noexcept +{ + QPointF ptResult; + qreal& x = ptResult.rx(); + qreal& y = ptResult.ry(); + + + if (Type == TT_BICUBIC) + { + qreal X = pt.x() / fXWidth; + qreal X2 = X * X; + qreal X3 = X * X * X; + qreal Y = pt.y() / fYWidth; + qreal Y2 = Y * Y; + qreal Y3 = Y * Y * Y; + + x = a0 + a1 * X + a2 * Y + a3 * X * Y + + a4 * X2 + a5 * Y2 + a6 * X2 * Y + a7 * X * Y2 + a8 * X2 * Y2 + + a9 * X3 + a10 * Y3 + a11 * X3 * Y + a12 * X * Y3 + a13 * X3 * Y2 + a14 * X2 * Y3 + a15 * X3 * Y3; + y = b0 + b1 * X + b2 * Y + b3 * X * Y + + b4 * X2 + b5 * Y2 + b6 * X2 * Y + b7 * X * Y2 + b8 * X2 * Y2 + + b9 * X3 + b10 * Y3 + b11 * X3 * Y + b12 * X * Y3 + b13 * X3 * Y2 + b14 * X2 * Y3 + b15 * X3 * Y3; + } + else if (Type == TT_BISQUARED) + { + qreal X = pt.x() / fXWidth; + qreal X2 = X * X; + qreal Y = pt.y() / fYWidth; + qreal Y2 = Y * Y; + + x = a0 + a1 * X + a2 * Y + a3 * X * Y + + a4 * X2 + a5 * Y2 + a6 * X2 * Y + a7 * X * Y2 + a8 * X2 * Y2; + y = b0 + b1 * X + b2 * Y + b3 * X * Y + + b4 * X2 + b5 * Y2 + b6 * X2 * Y + b7 * X * Y2 + b8 * X2 * Y2; + } + else + { + qreal X = pt.x() / fXWidth; + qreal Y = pt.y() / fYWidth; + + x = a0 + a1 * X + a2 * Y + a3 * X * Y; + y = b0 + b1 * X + b2 * Y + b3 * X * Y; + }; + + x *= fXWidth; + y *= fYWidth; + + return ptResult; +} + +double CBilinearParameters::Angle(int lWidth) const noexcept +{ + double fAngle; + QPointF pt1(0, 0), + pt2(lWidth, 0); + + pt1 = transform(pt1); + pt2 = transform(pt2); + + fAngle = atan2(pt2.y() - pt1.y(), pt2.x() - pt1.x()); + + return fAngle; +} + +void CBilinearParameters::Offsets(double& dX, double& dY) const noexcept +{ + dX = a0 * fXWidth; + dY = b0 * fYWidth; +} + +void CBilinearParameters::Footprint(QPointF& pt1, QPointF& pt2, QPointF& pt3, QPointF& pt4) const noexcept +{ + pt1.rx() = pt1.ry() = 0; + pt2.rx() = fXWidth; pt2.ry() = 0; + pt3.rx() = fXWidth; pt3.ry() = fYWidth; + pt4.rx() = 0; pt4.ry() = fYWidth; + + pt1 = transform(pt1); + pt2 = transform(pt2); + pt3 = transform(pt3); + pt4 = transform(pt4); +} \ No newline at end of file diff --git a/DeepSkyStacker/BilinearParameters.h b/DeepSkyStacker/BilinearParameters.h new file mode 100644 index 000000000..29aff6c20 --- /dev/null +++ b/DeepSkyStacker/BilinearParameters.h @@ -0,0 +1,49 @@ +#pragma once + +#include + +typedef enum TRANSFORMATIONTYPE +{ + TT_LINEAR = 0, + TT_BILINEAR = 1, + TT_BISQUARED = 2, + TT_BICUBIC = 3, + TT_NONE = 4, + TT_LAST = 5 +} TRANSFORMATIONTYPE; + +class QPointF; +class CBilinearParameters +{ +public: + TRANSFORMATIONTYPE Type; + double a0, a1, a2, a3; + double a4, a5, a6, a7, a8; + double a9, a10, a11, a12, a13, a14, a15; + double b0, b1, b2, b3; + double b4, b5, b6, b7, b8; + double b9, b10, b11, b12, b13, b14, b15; + + double fXWidth, fYWidth; + +private: + bool GetNextParameter(CString& strParameters, double& fValue) const; + +public: + CBilinearParameters() + { + Clear(); + } + + CBilinearParameters(const CBilinearParameters& bp) = default; + + CBilinearParameters& operator=(const CBilinearParameters& bp) = default; + + void Clear() noexcept; + void ToText(CString& strText) const; + bool FromText(LPCTSTR szText); + QPointF transform(const QPointF& pt) const noexcept; + double Angle(int lWidth) const noexcept; + void Offsets(double& dX, double& dY) const noexcept; + void Footprint(QPointF& pt1, QPointF& pt2, QPointF& pt3, QPointF& pt4) const noexcept; +}; diff --git a/DeepSkyStacker/BitMapFiller.cpp b/DeepSkyStacker/BitMapFiller.cpp index 40b65f298..64f545c61 100644 --- a/DeepSkyStacker/BitMapFiller.cpp +++ b/DeepSkyStacker/BitMapFiller.cpp @@ -1,7 +1,11 @@ -#include "StdAfx.h" +#include "stdafx.h" #include "BitMapFiller.h" #include "avx_bitmap_filler.h" #include "avx_support.h" +#include "DSSProgress.h" +#include "ZExcept.h" + +using namespace DSS; // ---------------------------------- // BitmapFillerInterface diff --git a/DeepSkyStacker/BitMapFiller.h b/DeepSkyStacker/BitMapFiller.h index 1684b15a6..07961bb7c 100644 --- a/DeepSkyStacker/BitMapFiller.h +++ b/DeepSkyStacker/BitMapFiller.h @@ -1,14 +1,13 @@ #pragma once +#include "cfa.h" -#include "BitmapBase.h" -#include "DSSProgress.h" -#include - +namespace DSS { class ProgressBase; } +class CMemoryBitmap; class BitmapFillerInterface { public: - static std::unique_ptr makeBitmapFiller(CMemoryBitmap* pBitmap, ProgressBase* pProgress, const double redWb, const double greenWb, const double blueWb); + static std::unique_ptr makeBitmapFiller(CMemoryBitmap* pBitmap, DSS::ProgressBase* pProgress, const double redWb, const double greenWb, const double blueWb); virtual ~BitmapFillerInterface() {} virtual bool isThreadSafe() const; @@ -25,7 +24,7 @@ class BitmapFillerInterface class BitmapFillerBase : public BitmapFillerInterface { protected: - ProgressBase* pProgress; + DSS::ProgressBase* pProgress; CMemoryBitmap* pBitmap; const float redScale; const float greenScale; @@ -40,7 +39,7 @@ class BitmapFillerBase : public BitmapFillerInterface std::vector blueBuffer; std::vector cfaFactors; public: - BitmapFillerBase(CMemoryBitmap* pB, ProgressBase* pP, const double redWb, const double greenWb, const double blueWb); + BitmapFillerBase(CMemoryBitmap* pB, DSS::ProgressBase* pP, const double redWb, const double greenWb, const double blueWb); virtual ~BitmapFillerBase() {} virtual void SetCFAType(CFATYPE cfaType) override; diff --git a/DeepSkyStacker/BitmapBase.cpp b/DeepSkyStacker/BitmapBase.cpp index f10ef40e1..f025d6253 100644 --- a/DeepSkyStacker/BitmapBase.cpp +++ b/DeepSkyStacker/BitmapBase.cpp @@ -1,60 +1,66 @@ -#include -#include +#include "stdafx.h" +#include "Ztrace.h" #include "BitmapBase.h" +#include "BitmapCharacteristics.h" +#include "GrayBitmap.h" +#include "ColorBitmap.h" - -template -void CGrayBitmapT::RemoveHotPixels(ProgressBase* pProgress) +std::shared_ptr CreateBitmap(const CBitmapCharacteristics& bc) { - const int nrProcessors = CMultitask::GetNrProcessors(); - - if (pProgress != nullptr) - { - const QString strText(QCoreApplication::translate("BitmapBase", "Detecting hot pixels", "IDS_REMOVINGHOTPIXELS")); - pProgress->Start2(strText, m_lHeight); - }; + ZFUNCTRACE_RUNTIME(); - const int height = this->Height(); - const int width = this->Width(); - std::vector hotOffsets; - std::vector localHotOffsets; - -#pragma omp parallel default(none) shared(hotOffsets) firstprivate(localHotOffsets) if(nrProcessors > 1) + if (bc.m_lNrChannels == 1) { -#pragma omp for schedule(dynamic, 50) nowait - for (int row = 2; row < height - 2; ++row) + if (bc.m_lBitsPerPixel == 8) + { + ZTRACE_RUNTIME("Creating 8 Gray bit memory bitmap"); + return std::make_shared(); + } + else if (bc.m_lBitsPerPixel == 16) { - for (int column = 2; column < width - 2; ++column) + ZTRACE_RUNTIME("Creating 16 Gray bit memory bitmap"); + return std::make_shared(); + } + else if (bc.m_lBitsPerPixel == 32) + { + if (bc.m_bFloat) { - const size_t testOffset = this->GetOffset(column, row); - const T testValue = this->m_vPixels[testOffset]; - constexpr double hotFactor = 4; - - if (testValue > hotFactor * m_vPixels[GetOffset(column - 1, row)] - && testValue > hotFactor * m_vPixels[GetOffset(column + 1, row)] - && testValue > hotFactor * m_vPixels[GetOffset(column, row + 1)] - && testValue > hotFactor * m_vPixels[GetOffset(column, row - 1)]) - { - localHotOffsets.push_back(testOffset); - ++column; - } + ZTRACE_RUNTIME("Creating 32 float Gray bit memory bitmap"); + return std::make_shared(); + } + else + { + ZTRACE_RUNTIME("Creating 32 Gray bit memory bitmap"); + return std::make_shared(); } } -#pragma omp critical(OmpLockHotpixelRemove) + } + else if (bc.m_lNrChannels == 3) + { + if (bc.m_lBitsPerPixel == 8) + { + ZTRACE_RUNTIME("Creating 8 RGB bit memory bitmap"); + return std::make_shared(); + } + else if (bc.m_lBitsPerPixel == 16) { - hotOffsets.insert(hotOffsets.end(), localHotOffsets.cbegin(), localHotOffsets.cend()); + ZTRACE_RUNTIME("Creating 16 RGB bit memory bitmap"); + return std::make_shared(); + } + else if (bc.m_lBitsPerPixel == 32) + { + if (bc.m_bFloat) + { + ZTRACE_RUNTIME("Creating 32 float RGB bit memory bitmap"); + return std::make_shared(); + } + else + { + ZTRACE_RUNTIME("Creating 32 RGB bit memory bitmap"); + return std::make_shared(); + } } } - for (const auto hotOffset : hotOffsets) - this->m_vPixels[hotOffset] = 0; - - if (pProgress != nullptr) - pProgress->End2(); + return std::shared_ptr{}; } - -template void CGrayBitmapT::RemoveHotPixels(ProgressBase*); -template void CGrayBitmapT::RemoveHotPixels(ProgressBase*); -template void CGrayBitmapT::RemoveHotPixels(ProgressBase*); -template void CGrayBitmapT::RemoveHotPixels(ProgressBase*); -template void CGrayBitmapT::RemoveHotPixels(ProgressBase*); diff --git a/DeepSkyStacker/BitmapBase.h b/DeepSkyStacker/BitmapBase.h index bcc6c4f2f..86ffd5aab 100644 --- a/DeepSkyStacker/BitmapBase.h +++ b/DeepSkyStacker/BitmapBase.h @@ -1,2500 +1,6 @@ #pragma once -#undef max -#undef min - -#include -#include -#include -#include "Multitask.h" -#include "DSSCommon.h" -#include "DSSProgress.h" -#include "DSSTools.h" - - -class CMultiBitmap; -class CMedianFilterEngine; +class CMemoryBitmap; class CBitmapCharacteristics; -template class CGrayMedianFilterEngineT; -template class CGrayBitmapT; -template class CColorBitmapT; - -using namespace DSS; - -#pragma pack(push, HDCOLORREFT, 1) - -template -class COLORREFT -{ -public: - TType red; - TType green; - TType blue; - -private: - void CopyFrom(const COLORREFT& cr) - { - red = cr.red; - green = cr.green; - blue = cr.blue; - }; - -public: - COLORREFT(TType r = 0, TType g = 0, TType b = 0) - { - red = r; - green = g; - blue = b; - }; - - COLORREFT(const COLORREFT& cr) - { - CopyFrom(cr); - }; - - COLORREFT& operator = (const COLORREFT& cr) - { - CopyFrom(cr); - return *this; - }; - -}; - -typedef COLORREFT COLORREF8; -typedef COLORREFT COLORREF16; -typedef COLORREFT COLORREF32; -typedef COLORREFT COLORREF32F; - -#pragma pack(pop, HDCOLORREFT) - - -typedef enum -{ - BAYER_UNKNOWN = 0, - BAYER_RED = 1, - BAYER_GREEN = 2, - BAYER_BLUE = 3, - BAYER_CYAN = 0xA, - BAYER_GREEN2 = 0xB, - BAYER_MAGENTA = 0xC, - BAYER_YELLOW = 0xD, - BAYER_NRCOLORS = 0xD + 1 -} BAYERCOLOR; - - -typedef enum tagEXTRAINFOTYPE -{ - EIT_UNKNOWN = 0, - EIT_STRING = 1, - EIT_LONG = 2, - EIT_DOUBLE = 3 -} EXTRAINFOTYPE; - -class CExtraInfo -{ -public: - EXTRAINFOTYPE m_Type; - CString m_strName; - CString m_strValue; - CString m_strComment; - int m_lValue; - double m_fValue; - bool m_bPropagate; - -private: - void CopyFrom(const CExtraInfo& ei) - { - m_Type = ei.m_Type; - m_strName = ei.m_strName; - m_strValue = ei.m_strValue; - m_lValue = ei.m_lValue; - m_fValue = ei.m_fValue; - m_strComment = ei.m_strComment; - m_bPropagate = ei.m_bPropagate; - }; - -public: - CExtraInfo() - { - m_bPropagate = false; - m_Type = EIT_UNKNOWN; - m_lValue = 0; - m_fValue = 0; - }; - CExtraInfo(const CExtraInfo& ei) - { - CopyFrom(ei); - }; - ~CExtraInfo() {}; - - CExtraInfo& operator = (const CExtraInfo& ei) - { - CopyFrom(ei); - return (*this); - }; -}; - -typedef std::vector EXTRAINFOVECTOR; - - -class CBitmapExtraInfo -{ -public: - EXTRAINFOVECTOR m_vExtras; - -public: - CBitmapExtraInfo() {}; - ~CBitmapExtraInfo() {}; - - void AddInfo(const CExtraInfo& ei) - { - m_vExtras.push_back(ei); - }; - - void AddInfo(LPCTSTR szName, LPCTSTR szValue, LPCTSTR szComment = nullptr, bool bPropagate = false) - { - CExtraInfo ei; - - ei.m_Type = EIT_STRING; - ei.m_strName = szName; - ei.m_strComment = szComment; - ei.m_strValue = szValue; - ei.m_bPropagate = bPropagate; - m_vExtras.push_back(ei); - }; - void AddInfo(LPCTSTR szName, int lValue, LPCTSTR szComment = nullptr, bool bPropagate = false) - { - CExtraInfo ei; - - ei.m_Type = EIT_LONG; - ei.m_strName = szName; - ei.m_lValue = lValue; - ei.m_strComment = szComment; - ei.m_bPropagate = bPropagate; - m_vExtras.push_back(ei); - }; - void AddInfo(LPCTSTR szName, double fValue, LPCTSTR szComment = nullptr, bool bPropagate = false) - { - CExtraInfo ei; - - ei.m_Type = EIT_DOUBLE; - ei.m_strName = szName; - ei.m_fValue = fValue; - ei.m_strComment = szComment; - ei.m_bPropagate = bPropagate; - m_vExtras.push_back(ei); - }; - - void Clear() - { - m_vExtras.clear(); - }; -}; - - -class CMemoryBitmap -{ -public: - CBitmapExtraInfo m_ExtraInfo; - SYSTEMTIME m_DateTime; - -protected: - bool m_bTopDown; - bool m_bMaster; - bool m_bCFA; - double m_fExposure; - double m_fAperture; - int m_lISOSpeed; - int m_lGain; - int m_lNrFrames; - CString m_strDescription; - QString m_filterName; - -protected: - void CopyFrom(const CMemoryBitmap& mb) - { - m_ExtraInfo = mb.m_ExtraInfo; - m_bTopDown = mb.m_bTopDown; - m_bMaster = mb.m_bMaster; - m_bCFA = mb.m_bCFA; - m_fExposure = mb.m_fExposure; - m_fAperture = mb.m_fAperture; - m_lISOSpeed = mb.m_lISOSpeed; - m_lGain = mb.m_lGain; - m_lNrFrames = mb.m_lNrFrames; - m_strDescription = mb.m_strDescription; - m_DateTime = mb.m_DateTime; - m_filterName = mb.m_filterName; - } - -public: - CMemoryBitmap() : - m_bTopDown{ false }, - m_bMaster{ false }, - m_bCFA{ false }, - m_fExposure{ 0.0 }, - m_fAperture{ 0.0 }, - m_lISOSpeed{ 0 }, - m_lGain{ -1 }, - m_lNrFrames{ 0 } - { - m_DateTime.wYear = 0; - } - virtual ~CMemoryBitmap() - { - // ZTRACE_RUNTIME("Destroying memory bitmap %p", this); - }; - - virtual double GetExposure() - { - return m_fExposure; - }; - - virtual CMemoryBitmap& SetExposure(double fExposure) - { - m_fExposure = fExposure; - return *this; - }; - - virtual double GetAperture() - { - return m_fAperture; - }; - - virtual CMemoryBitmap& SetAperture(double fAperture) - { - m_fAperture = fAperture; - return *this; - }; - - virtual int GetISOSpeed() - { - return m_lISOSpeed; - }; - - virtual CMemoryBitmap& SetISOSpeed(int lISOSpeed) - { - m_lISOSpeed = lISOSpeed; - return *this; - }; - - virtual int GetGain() - { - return m_lGain; - }; - - virtual CMemoryBitmap& SetGain(int lGain) - { - m_lGain = lGain; - return *this; - }; - - virtual int GetNrFrames() - { - return m_lNrFrames; - }; - - virtual CMemoryBitmap& SetNrFrames(int lNrFrames) - { - m_lNrFrames = lNrFrames; - return *this; - }; - - virtual CMemoryBitmap& SetDescription(LPCTSTR szDescription) - { - m_strDescription = szDescription; - return *this; - }; - - virtual CMemoryBitmap& GetDescription(CString& strDescription) - { - strDescription = m_strDescription; - return *this; - }; - - virtual CMemoryBitmap& setFilterName(const QString& name) - { - m_filterName = name; - return *this; - } - - virtual QString filterName() - { - return m_filterName; - } - - virtual bool Init(int lWidth, int lHeight) = 0; - - virtual void SetPixel(size_t i, size_t j, double fRed, double fGreen, double fBlue) = 0; - virtual void SetPixel(size_t i, size_t j, double fGray) = 0; - virtual void GetPixel(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) = 0; - virtual void GetPixel(size_t i, size_t j, double& fGray) = 0; - - virtual void SetValue(size_t i, size_t j, double fRed, double fGreen, double fBlue) {}; - virtual void GetValue(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) const {}; - virtual void SetValue(size_t i, size_t j, double fGray) {}; - virtual void GetValue(size_t i, size_t j, double& fGray) const {}; - - virtual bool GetScanLine(size_t j, void* pScanLine) = 0; - virtual bool SetScanLine(size_t j, void* pScanLine) = 0; - - void GetPixel16(const size_t i, const size_t j, COLORREF16& crResult) - { - constexpr double scalingFactor = double{ 1. + std::numeric_limits::max() }; - constexpr double maxValue = double{ std::numeric_limits::max() }; - // Use get pixel - double fRed, fGreen, fBlue; - GetPixel(i, j, fRed, fGreen, fBlue); - - crResult.red = static_cast(std::min(fRed * scalingFactor, maxValue)); - crResult.green = static_cast(std::min(fGreen * scalingFactor, maxValue)); - crResult.blue = static_cast(std::min(fBlue * scalingFactor, maxValue)); - } - - virtual int Width() const = 0; - virtual int Height() const = 0; - virtual int BitPerSample() = 0; - virtual int IsFloat() = 0; - - virtual int RealWidth() const - { - return Width(); - } - - virtual int RealHeight() const - { - return Height(); - } - - void SetOrientation(bool bTopDown) - { - m_bTopDown = bTopDown; - } - - virtual bool IsMonochrome() const = 0; - - virtual void SetMaster(bool bMaster) - { - m_bMaster = bMaster; - } - - virtual bool IsMaster() - { - return m_bMaster; - } - - virtual bool isTopDown() - { - return m_bTopDown; - } - - virtual void SetCFA(bool bCFA) - { - m_bCFA = bCFA; - } - - virtual bool IsCFA() const - { - return m_bCFA; - } - - virtual BAYERCOLOR GetBayerColor(int x, int y) - { - return BAYER_UNKNOWN; - } - - bool IsOk() - { - return (Width() > 0) && (Height() > 0); - } - - virtual std::unique_ptr Clone(bool bEmpty = false) const = 0; - - virtual std::shared_ptr CreateEmptyMultiBitmap() const = 0; - virtual void AverageBitmap(CMemoryBitmap* pBitmap, ProgressBase* pProgress) {}; - virtual void RemoveHotPixels(ProgressBase* pProgress = nullptr) = 0; - virtual std::shared_ptr GetMedianFilterEngine() const = 0; - - virtual double GetMaximumValue() const = 0; - virtual void GetCharacteristics(CBitmapCharacteristics& bc) = 0; - - virtual void InitIterator(void*& pRed, void*& pGreen, void*& pBlue, size_t& elementSize, const size_t x, const size_t y) = 0; - virtual void InitIterator(const void*& pRed, const void*& pGreen, const void*& pBlue, size_t& elementSize, const size_t x, const size_t y) const = 0; - virtual std::tuple ConvertValue3(const void* pRed, const void* pGreen, const void* pBlue) const = 0; - virtual double ConvertValue1(const void* pRed, const void* pGreen, const void* pBlue) const = 0; - virtual void ReceiveValue(void* pRed, void* pGreen, void* pBlue, const double gray) const = 0; - virtual void ReceiveValue(void* pRed, void* pGreen, void* pBlue, const double red, const double green, const double blue) const = 0; -}; - - -enum CFATYPE : std::uint32_t -{ - CFATYPE_NONE = 0, - CFATYPE_BGGR = 1, - CFATYPE_GRBG = 2, - CFATYPE_GBRG = 3, - CFATYPE_RGGB = 4, - - // A = Cyan B = Green C = Magenta D = Yellow - CFATYPE_CGMY = 0xABCD, - CFATYPE_CGYM = 0xABDC, - CFATYPE_CMGY = 0xACBD, - CFATYPE_CMYG = 0xACDB, - CFATYPE_CYMG = 0xADCB, - CFATYPE_CYGM = 0xADBC, - - CFATYPE_GCMY = 0xBACD, - CFATYPE_GCYM = 0xBADC, - CFATYPE_GMCY = 0xBCAD, - CFATYPE_GMYC = 0xBCDA, - CFATYPE_GYCM = 0xBDAC, - CFATYPE_GYMC = 0xBDCA, - - CFATYPE_MCGY = 0xCABD, - CFATYPE_MCYG = 0xCADB, - CFATYPE_MGYC = 0xCBDA, - CFATYPE_MGCY = 0xCBAD, - CFATYPE_MYGC = 0xCDBA, - CFATYPE_MYCG = 0xCDAB, - - CFATYPE_YCGM = 0xDABC, - CFATYPE_YCMG = 0xDACB, - CFATYPE_YGMC = 0xDBCA, - CFATYPE_YGCM = 0xDBAC, - CFATYPE_YMCG = 0xDCAB, - CFATYPE_YMGC = 0xDCBA, - - CFATYPE_CYMGCYGM = 0xADCBADBC, - CFATYPE_YCGMYCMG = 0xDABCDACB, - CFATYPE_CYGMCYMG = 0xADBCADCB, - CFATYPE_YCMGYCGM = 0xDACBDABC, - - CFATYPE_MGYCMGCY = 0xCBDACBAD, - CFATYPE_GMCYGMYC = 0xBCADBCDA, - CFATYPE_MGCYMGYC = 0xCBADCBDA, - CFATYPE_GMYCGMCY = 0xBCDABCAD, - - CFATYPE_GMCYMGCY = 0xBCADCBAD, - CFATYPE_MGYCGMYC = 0xCBDABCDA, - CFATYPE_MGCYGMCY = 0xCBADBCAD, - CFATYPE_GMYCMGYC = 0xBCDACBDA, - - CFATYPE_CYMGYCMG = 0xADCBDACB, - CFATYPE_YCGMCYGM = 0xDABCADBC, - CFATYPE_YCMGCYMG = 0xDACBADCB, - CFATYPE_CYGMYCGM = 0xADBCDABC -}; - - -typedef enum CFATRANSFORMATION -{ - CFAT_NONE = 0, - CFAT_SUPERPIXEL = 1, - CFAT_RAWBAYER = 2, - CFAT_BILINEAR = 3, - CFAT_GRADIENT = 4, - CFAT_AHD = 5 -} CFATRANSFORMATION; - - -inline bool IsCYMGType(CFATYPE Type) -{ - return ((Type & 0xFFFFFFF0) != 0); -} - -inline bool IsSimpleCYMG(CFATYPE Type) -{ - return !(Type & 0xFFFF0000); -}; - -inline int CMYGZeroIndex(BAYERCOLOR Color) -{ - return Color - BAYER_CYAN; -}; - - -inline BAYERCOLOR GetBayerColor(size_t baseX, size_t baseY, CFATYPE CFAType, int xOffset = 0, int yOffset = 0) -{ - const size_t x = baseX + xOffset; // Apply the X Bayer offset if supplied - const size_t y = baseY + yOffset; // Apply the Y Bayer offset if supplied - - switch (CFAType) - { - case CFATYPE_NONE: - return BAYER_UNKNOWN; - break; - case CFATYPE_BGGR: - if (x & 1) - { - if (y & 1) - return BAYER_RED; - else - return BAYER_GREEN; - } - else - { - if (y & 1) - return BAYER_GREEN; - else - return BAYER_BLUE; - }; - break; - case CFATYPE_GRBG: - if (x & 1) - { - if (y & 1) - return BAYER_GREEN; - else - return BAYER_RED; - } - else - { - if (y & 1) - return BAYER_BLUE; - else - return BAYER_GREEN; - }; - break; - case CFATYPE_GBRG: - if (x & 1) - { - if (y & 1) - return BAYER_GREEN; - else - return BAYER_BLUE; - } - else - { - if (y & 1) - return BAYER_RED; - else - return BAYER_GREEN; - }; - break; - case CFATYPE_RGGB: - if (x & 1) - { - if (y & 1) - return BAYER_BLUE; - else - return BAYER_GREEN; - } - else - { - if (y & 1) - return BAYER_GREEN; - else - return BAYER_RED; - }; - break; - default: - { // CYMG Type - if (IsSimpleCYMG(CFAType)) - { - // 2 lines and 2 columns repeated pattern - if (y & 1) - { - if (x & 1) - return (BAYERCOLOR)(CFAType & 0xF); - else - return (BAYERCOLOR)((CFAType >> 4) & 0xF); - } - else - { - if (x & 1) - return (BAYERCOLOR)((CFAType >> 8) & 0xF); - else - return (BAYERCOLOR)((CFAType >> 12) & 0xF); - }; - } - else - { - // 4 lines and 2 columns repeated pattern - if (y % 4 == 0) - { - if (x & 1) - return (BAYERCOLOR)((CFAType >> 24) & 0xF); - else - return (BAYERCOLOR)((CFAType >> 28) & 0xF); - } - else if (y % 4 == 1) - { - if (x & 1) - return (BAYERCOLOR)((CFAType >> 16) & 0xF); - else - return (BAYERCOLOR)((CFAType >> 20) & 0xF); - } - else if (y % 4 == 2) - { - if (x & 1) - return (BAYERCOLOR)((CFAType >> 8) & 0xF); - else - return (BAYERCOLOR)((CFAType >> 12) & 0xF); - } - else - { - if (x & 1) - return (BAYERCOLOR)((CFAType >> 0) & 0xF); - else - return (BAYERCOLOR)((CFAType >> 4) & 0xF); - }; - }; - }; - }; - return BAYER_UNKNOWN; -}; - - -// -// Add parameter yOffset to specify CFA Matrix offset to be applied (for FITS files) -// -inline bool IsBayerBlueLine(size_t baseY, CFATYPE CFAType, int yOffset = 0) -{ - size_t y = baseY + yOffset; - - if ((CFAType == CFATYPE_GRBG) || (CFAType == CFATYPE_RGGB)) - return (y & 1) ? true : false; - else - return (y & 1) ? false : true; -}; - -// -// Add parameter xOffset to specify CFA Matrix offset to be applied (for FITS files) -// -inline bool IsBayerBlueColumn(size_t baseX, CFATYPE CFAType, int xOffset = 0) -{ - size_t x = baseX + xOffset; - - if ((CFAType == CFATYPE_GBRG) || (CFAType == CFATYPE_RGGB)) - return (x & 1) ? true : false; - else - return (x & 1) ? false : true; -}; - -inline bool IsBayerRedLine(size_t baseY, CFATYPE CFAType, int yOffset = 0) -{ - return !IsBayerBlueLine(baseY, CFAType, yOffset); -}; - -// -// Add parameter xOffset to specify CFA Matrix offset to be applied (for FITS files) -// -inline bool IsBayerRedColumn(size_t baseX, CFATYPE CFAType, int xOffset = 0) -{ - return !IsBayerBlueColumn(baseX, CFAType, xOffset); -}; - - -void CYMGToRGB(double fCyan, double fYellow, double fMagenta, double fGreen2, double& fRed, double& fGreen, double& fBlue); - - -inline void ToHSL(double Red, double Green, double Blue, double& H, double& S, double& L) -{ - double minval = std::min(Red, std::min(Green, Blue)); - double maxval = std::max(Red, std::max(Green, Blue)); - double mdiff = maxval - minval; - double msum = maxval + minval; - - L = msum / 510.0f; - - if (maxval == minval) - { - S = 0.0f; - H = 0.0f; - } - else - { - double rnorm = (maxval - Red) / mdiff; - double gnorm = (maxval - Green) / mdiff; - double bnorm = (maxval - Blue) / mdiff; - - S = (L <= 0.5f) ? (mdiff / msum) : (mdiff / (510.0f - msum)); - - if (Red == maxval) H = 60.0f * (6.0f + bnorm - gnorm); - if (Green == maxval) H = 60.0f * (2.0f + rnorm - bnorm); - if (Blue == maxval) H = 60.0f * (4.0f + gnorm - rnorm); - if (H > 360.0f) - H = H - 360.0f; - } -}; - - -class CBitmapCharacteristics -{ -public: - int m_lNrChannels; - int m_lBitsPerPixel; - bool m_bFloat; - std::uint32_t m_dwWidth, m_dwHeight; - -private: - void CopyFrom(const CBitmapCharacteristics& bc) - { - m_lNrChannels = bc.m_lNrChannels; - m_lBitsPerPixel = bc.m_lBitsPerPixel; - m_bFloat = bc.m_bFloat; - m_dwWidth = bc.m_dwWidth; - m_dwHeight = bc.m_dwHeight; - }; - -public: - CBitmapCharacteristics() : - m_lNrChannels{ 0 }, - m_lBitsPerPixel{ 0 }, - m_bFloat{ false }, - m_dwWidth{ 0 }, - m_dwHeight{ 0 } - {} - ~CBitmapCharacteristics() {}; - - CBitmapCharacteristics(const CBitmapCharacteristics& bc) - { - CopyFrom(bc); - }; - - CBitmapCharacteristics& operator= (const CBitmapCharacteristics& bc) - { - CopyFrom(bc); - return *this; - }; -}; - std::shared_ptr CreateBitmap(const CBitmapCharacteristics& bc); - - -class CCFABitmapInfo -{ -protected: - CFATRANSFORMATION m_CFATransform; - CFATYPE m_CFAType; - bool m_bCYMG; - int m_xBayerOffset; - int m_yBayerOffset; - -protected: - virtual void SetCFA(bool bCFA) = 0; - -public: - void InitFrom(const CCFABitmapInfo* const pCFABitmapInfo) - { - m_CFATransform = pCFABitmapInfo->m_CFATransform; - m_CFAType = pCFABitmapInfo->m_CFAType; - m_bCYMG = pCFABitmapInfo->m_bCYMG; - m_xBayerOffset = pCFABitmapInfo->m_xBayerOffset; - m_yBayerOffset = pCFABitmapInfo->m_yBayerOffset; - }; - -public: - CCFABitmapInfo() : - m_CFATransform{ CFAT_NONE }, - m_CFAType{ CFATYPE_NONE }, - m_bCYMG{ false }, - m_xBayerOffset{ 0 }, - m_yBayerOffset{ 0 } - {} - - void SetCFAType(CFATYPE Type) - { - m_CFAType = Type; - m_bCYMG = IsCYMGType(m_CFAType); - }; - - CCFABitmapInfo& setXoffset(int xOffset) noexcept - { - m_xBayerOffset = xOffset; - return *this; - }; - - inline int xOffset() noexcept - { - return m_xBayerOffset; - } - - CCFABitmapInfo& setYoffset(int yOffset) noexcept - { - m_yBayerOffset = yOffset; - return *this; - }; - - inline int yOffset() noexcept - { - return m_yBayerOffset; - } - - inline CFATYPE GetCFAType() noexcept - { - return m_CFAType; - }; - - void UseSuperPixels(bool bUse) - { - if (bUse) - { - m_CFATransform = CFAT_SUPERPIXEL; - SetCFA(true); - } - else - m_CFATransform = CFAT_NONE; - }; - - void UseRawBayer(bool bUse) - { - if (bUse) - { - m_CFATransform = CFAT_RAWBAYER; - SetCFA(true); - } - else - m_CFATransform = CFAT_NONE; - }; - - void UseBilinear(bool bUse) - { - if (bUse) - { - m_CFATransform = CFAT_BILINEAR; - SetCFA(true); - } - else - m_CFATransform = CFAT_NONE; - }; - - void UseAHD(bool bUse) - { - if (bUse) - { - m_CFATransform = CFAT_AHD; - SetCFA(true); - } - else - m_CFATransform = CFAT_NONE; - }; - - CFATRANSFORMATION GetCFATransformation() const - { - return m_CFATransform; - }; -}; - - -class CBitmapPartFile -{ -public: - CString m_strFile; - int m_lStartRow; - int m_lEndRow; - int m_lWidth; - int m_lNrBitmaps; - -private: - void CopyFrom(const CBitmapPartFile& bp) - { - m_strFile = bp.m_strFile; - m_lStartRow = bp.m_lStartRow; - m_lEndRow = bp.m_lEndRow; - m_lWidth = bp.m_lWidth; - m_lNrBitmaps = bp.m_lNrBitmaps; - }; - -public: - CBitmapPartFile(LPCTSTR szFile, int lStartRow, int lEndRow) - { - m_strFile = szFile; - m_lStartRow = lStartRow; - m_lEndRow = lEndRow; - m_lWidth = 0; - m_lNrBitmaps = 0; - }; - - CBitmapPartFile(const CBitmapPartFile& bp) - { - CopyFrom(bp); - }; - - const CBitmapPartFile& operator= (const CBitmapPartFile& bp) - { - CopyFrom(bp); - return *this; - }; - - virtual ~CBitmapPartFile() - {} -}; - -typedef std::vector BITMAPPARTFILEVECTOR; - - -class CMultiBitmap -{ -protected: - std::shared_ptr m_pBitmapModel; - mutable std::shared_ptr m_pHomBitmap; - MULTIBITMAPPROCESSMETHOD m_Method; - double m_fKappa; - int m_lNrIterations; - int m_lNrBitmaps; - int m_lNrAddedBitmaps; - BITMAPPARTFILEVECTOR m_vFiles; - int m_lWidth; - int m_lHeight; - bool m_bInitDone; - bool m_bHomogenization; - double m_fMaxWeight; - std::vector m_vImageOrder; - -private: - void DestroyTempFiles(); - void InitParts(); - std::shared_ptr SmoothOut(CMemoryBitmap* pBitmap, ProgressBase *const pProgress) const; - -public: - CMultiBitmap() : - m_lNrBitmaps{ 0 }, - m_lWidth{ 0 }, - m_lHeight{ 0 }, - m_bInitDone{ false }, - m_lNrAddedBitmaps{ 0 }, - m_bHomogenization{ false }, - m_fMaxWeight{ 0 }, - m_Method{ MULTIBITMAPPROCESSMETHOD{0} }, - m_fKappa{ 0.0 }, - m_lNrIterations{ 0 } - {} - - virtual ~CMultiBitmap() - { - DestroyTempFiles(); - }; - - void SetBitmapModel(const CMemoryBitmap* pBitmap); - virtual bool SetScanLines(CMemoryBitmap* pBitmap, int lLine, const std::vector& vScanLines) = 0; - virtual std::shared_ptr CreateNewMemoryBitmap() const = 0; - virtual std::shared_ptr CreateOutputMemoryBitmap() const = 0; - - virtual void SetNrBitmaps(int lNrBitmaps) - { - m_lNrBitmaps = lNrBitmaps; - }; - - int GetNrBitmaps() - { - return m_lNrBitmaps; - }; - - int GetNrAddedBitmaps() - { - return m_lNrAddedBitmaps; - }; - - void SetImageOrder(const std::vector& vImageOrder) - { - m_vImageOrder = vImageOrder; - }; - - const std::vector& GetImageOrder() const - { - return this->m_vImageOrder; - } - - virtual bool AddBitmap(CMemoryBitmap* pMemoryBitmap, ProgressBase* pProgress = nullptr); - virtual std::shared_ptr GetResult(ProgressBase* pProgress = nullptr); - virtual int GetNrChannels() const = 0; - virtual int GetNrBytesPerChannel() const = 0; - - void SetProcessingMethod(MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations) - { - m_Method = Method; - m_fKappa = fKappa; - m_lNrIterations = lNrIterations; - }; - - void SetHomogenization(bool bSet) - { - m_bHomogenization = bSet; - }; - - bool GetHomogenization() const - { - return m_bHomogenization; - } - - CMemoryBitmap* GetHomogenBitmap() const - { - if (static_cast(this->m_pHomBitmap)) - return m_pHomBitmap.get(); - return nullptr; - } - - int GetProcessingMethod() const - { - return m_Method; - } - - auto GetProcessingParameters() const - { - return std::make_tuple(m_fKappa, m_lNrIterations); - } -}; - - -template -class CGrayMultiBitmapT : public CMultiBitmap -{ -protected: - virtual std::shared_ptr CreateNewMemoryBitmap() const override - { - std::shared_ptr pBitmap; - if (static_cast(m_pBitmapModel)) - { - CBitmapCharacteristics bc; - m_pBitmapModel->GetCharacteristics(bc); - if (bc.m_lNrChannels == 1) - return m_pBitmapModel->Clone(true); - else - { - bc.m_lNrChannels = 1; - return CreateBitmap(bc); - } - } - else - return std::make_shared>(); - } - - virtual std::shared_ptr CreateOutputMemoryBitmap() const override - { - std::shared_ptr pBitmap = std::make_shared>(); - - if (static_cast(pBitmap) && static_cast(m_pBitmapModel)) - { - CCFABitmapInfo* pSrc; - CCFABitmapInfo* pDst; - - pBitmap->SetCFA(m_pBitmapModel->IsCFA()); - pSrc = dynamic_cast(m_pBitmapModel.get()); - pDst = dynamic_cast(pBitmap.get()); - - if (pSrc != nullptr && pDst != nullptr) - pDst->InitFrom(pSrc); - } - - return pBitmap; - } - - virtual bool SetScanLines(CMemoryBitmap* pBitmap, int lLine, const std::vector& vScanLines) override - { - bool bResult = false; - // Each scan line consist of lWidth TType values - std::vector vValues; - std::vector vAuxValues; - std::vector vWorkingBuffer1; - std::vector vWorkingBuffer2; - std::vector vdWork1; // Used for AutoAdaptiveWeightedAverage - std::vector vdWork2; // Used for AutoAdaptiveWeightedAverage - - const double fMaximum = pBitmap->GetMaximumValue(); - const int lWidth = pBitmap->RealWidth(); - - std::vector outputScanBuffer; - try { - outputScanBuffer.resize(lWidth); - } catch (...) { - ZOutOfMemory e("Could not allocate storage for output scanline"); - ZTHROW(e); - } - TTypeOutput* pCurrentValue = outputScanBuffer.data(); - - vValues.reserve(vScanLines.size()); - vWorkingBuffer1.reserve(vScanLines.size()); - vWorkingBuffer2.reserve(vScanLines.size()); - vdWork1.reserve(vScanLines.size()); - vdWork2.reserve(vScanLines.size()); - - for (int i = 0; i < lWidth; i++) - { - TType* pValue; - double fWeight = 1.0; - - vValues.resize(0); - for (size_t j = 0; j < vScanLines.size(); j++) - { - pValue = (TType*)vScanLines[j]; - pValue += i; - - if (*pValue || m_vImageOrder.size()) // Remove 0 - vValues.push_back(*pValue); - }; - - // Process the value - if (m_bHomogenization) - { - if (static_cast(m_pHomBitmap)) - { - double fAverage; - const double fSigma = Sigma2(vValues, fAverage); - m_pHomBitmap->SetPixel(i, lLine, fSigma / std::max(1.0, fAverage) * 256.0); - } - - if (!m_vImageOrder.empty()) - { - // Change the order to respect the order of the images - vAuxValues = vValues; - vValues.resize(0); - for (size_t k = 0; k < m_vImageOrder.size(); k++) - if (const auto auxVal = vAuxValues[m_vImageOrder[k]]) - vValues.push_back(auxVal); - - Homogenize(vValues, fMaximum); - } - else - { - Homogenize(vValues, fMaximum); - }; - }; - - if (m_Method == MBP_MEDIAN) - *pCurrentValue = Median(vValues); - else if (m_Method == MBP_AVERAGE) - *pCurrentValue = Average(vValues); - else if (m_Method == MBP_MAXIMUM) - *pCurrentValue = Maximum(vValues); - else if (m_Method == MBP_SIGMACLIP) - { - *pCurrentValue = KappaSigmaClip(vValues, m_fKappa, m_lNrIterations, vWorkingBuffer1); - } - else if (m_Method == MBP_MEDIANSIGMACLIP) - *pCurrentValue = MedianKappaSigmaClip(vValues, m_fKappa, m_lNrIterations, vWorkingBuffer1, vWorkingBuffer2); - else if (m_Method == MBP_AUTOADAPTIVE) - *pCurrentValue = AutoAdaptiveWeightedAverage(vValues, m_lNrIterations, vdWork1); - - //if (m_bHomogenization) - // *pCurrentValue = fHomogenization*(double)(*pCurrentValue); - pCurrentValue++; - }; - - pBitmap->SetScanLine(lLine, outputScanBuffer.data()); - bResult = true; - - return bResult; - }; - -public: - CGrayMultiBitmapT() - {} - - virtual ~CGrayMultiBitmapT() - {} - - virtual int GetNrChannels() const override - { - return 1; - }; - - virtual int GetNrBytesPerChannel() const override - { - return sizeof(TType); - }; -}; - - -class CMedianFilterEngine -{ -protected: - int m_lFilterSize; - ProgressBase* m_pProgress; - -public: - CMedianFilterEngine() : - m_lFilterSize{ 1 }, - m_pProgress{ nullptr } - {} - - virtual ~CMedianFilterEngine() {}; - - virtual std::shared_ptr GetFilteredImage(int lFilterSize, ProgressBase* pProgress) const = 0; -}; - - -template -class CGrayMedianFilterEngineT : public CMedianFilterEngine -{ -private: - const CGrayBitmapT* m_pInBitmap; - -public: - CGrayMedianFilterEngineT() : m_pInBitmap{ nullptr } - {}; - virtual ~CGrayMedianFilterEngineT() {}; - - void SetInputBitmap(const CGrayBitmapT* pInBitmap) - { - m_pInBitmap = pInBitmap; - } - - virtual std::shared_ptr GetFilteredImage(const int lFilterSize, ProgressBase* pProgress) const override; -}; - - -template -class CGrayBitmapT : public CMemoryBitmap, public CCFABitmapInfo -{ -public: - friend CColorBitmapT; - friend CGrayMedianFilterEngineT; - - std::vector m_vPixels; - -private: - int m_lWidth; - int m_lHeight; - bool m_bWord; - bool m_bDouble; - bool m_bDWord; - bool m_bFloat; - double m_fMultiplier; - -private: - bool InitInternals() - { - const size_t nrPixels = static_cast(m_lWidth) * static_cast(m_lHeight); - m_vPixels.clear(); - m_vPixels.resize(nrPixels); - - return true; // Otherwise m_vPixels.resize() would have thrown bad_alloc. - } - - inline void CheckXY(size_t x, size_t y) const - { - ZASSERTSTATE(IsXYOk(x, y)); - } - - inline bool IsXYOk(size_t x, size_t y) const - { - return (x >= 0 && x < m_lWidth && y >= 0 && y < m_lHeight); - } - - size_t GetOffset(const size_t x, const size_t y) const - { - return static_cast(m_lWidth) * y + x; - } - size_t GetOffset(int x, int y) const - { - CheckXY(x, y); - return GetOffset(static_cast(x), static_cast(y)); - } - - virtual bool IsMonochrome() const override - { - return true; - } - - TType GetPrimary(int x, int y, const COLORREF16& crColor) - { - switch (::GetBayerColor(x, y, m_CFAType, m_xBayerOffset, m_yBayerOffset)) - { - case BAYER_RED: - return crColor.red; - break; - case BAYER_GREEN: - return crColor.green; - break; - case BAYER_BLUE: - return crColor.blue; - break; - }; - - return 0; - }; - - double GetPrimary(size_t x, size_t y, double fRed, double fGreen, double fBlue) - { - switch (::GetBayerColor(x, y, m_CFAType, m_xBayerOffset, m_yBayerOffset)) - { - case BAYER_RED: - return fRed; - break; - case BAYER_GREEN: - return fGreen; - break; - case BAYER_BLUE: - return fBlue; - break; - }; - - return 0; - }; - - double InterpolateGreen(size_t x, size_t y, TType* pValue = nullptr) - { - double fResult = 0.0; - int lNrValues = 0; - - if (!pValue) - pValue = &m_vPixels[GetOffset(x, y)]; - - if (x > 0) - { - fResult += *(pValue - 1); - lNrValues++; - }; - if (x < m_lWidth - 1) - { - fResult += *(pValue + 1); - lNrValues++; - }; - if (y > 0) - { - fResult += *(pValue - m_lWidth); - lNrValues++; - }; - if (y < m_lHeight - 1) - { - fResult += *(pValue + m_lWidth); - lNrValues++; - }; - - return fResult / lNrValues; - }; - - double InterpolateBlue(size_t x, size_t y, TType* pValue = nullptr) - { - double fResult = 0.0; - int lNrValues = 0; - - if (!pValue) - pValue = &m_vPixels[GetOffset(x, y)]; - - if (IsBayerBlueLine(y, m_CFAType, m_yBayerOffset)) - { - // Pixel between 2 blue pixel (horizontaly) - if (x > 0) - { - fResult += *(pValue - 1); - lNrValues++; - }; - if (x < m_lWidth - 1) - { - fResult += *(pValue + 1); - lNrValues++; - }; - } - else if (IsBayerBlueColumn(x, m_CFAType, m_xBayerOffset)) - { - // Pixel between 2 blue pixels (verticaly) - if (y > 0) - { - fResult += *(pValue - m_lWidth); - lNrValues++; - }; - if (y < m_lHeight - 1) - { - fResult += *(pValue + m_lWidth); - lNrValues++; - }; - } - else - { - // Use 4 pixels to interpolate - if (x > 0 && y > 0) - { - fResult += *(pValue - 1 - m_lWidth); - lNrValues++; - } - if ((x > 0) && (y < m_lHeight - 1)) - { - fResult += *(pValue - 1 + m_lWidth); - lNrValues++; - }; - if ((x < m_lWidth - 1) && (y < m_lHeight - 1)) - { - fResult += *(pValue + 1 + m_lWidth); - lNrValues++; - }; - if ((x < m_lWidth - 1) && (y > 0)) - { - fResult += *(pValue + 1 - m_lWidth); - lNrValues++; - }; - }; - - return fResult / lNrValues; - }; - - double InterpolateRed(size_t x, size_t y, TType* pValue = nullptr) - { - double fResult = 0.0; - int lNrValues = 0; - - if (!pValue) - pValue = &m_vPixels[GetOffset(x, y)]; - - if (IsBayerRedLine(y, m_CFAType, m_yBayerOffset)) - { - // Pixel between 2 blue pixel (horizontaly) - if (x > 0) - { - fResult += *(pValue - 1); - lNrValues++; - }; - if (x < m_lWidth - 1) - { - fResult += *(pValue + 1); - lNrValues++; - }; - } - else if (IsBayerRedColumn(x, m_CFAType, m_xBayerOffset)) - { - // Pixel between 2 blue pixels (verticaly) - if (y > 0) - { - fResult += *(pValue - m_lWidth); - lNrValues++; - }; - if (y < m_lHeight - 1) - { - fResult += *(pValue + m_lWidth); - lNrValues++; - }; - } - else - { - // Use 4 pixels to interpolate - if (x > 0 && y > 0) - { - fResult += *(pValue - 1 - m_lWidth); - lNrValues++; - } - if ((x > 0) && (y < m_lHeight - 1)) - { - fResult += *(pValue - 1 + m_lWidth); - lNrValues++; - }; - if ((x < m_lWidth - 1) && (y < m_lHeight - 1)) - { - fResult += *(pValue + 1 + m_lWidth); - lNrValues++; - }; - if ((x < m_lWidth - 1) && (y > 0)) - { - fResult += *(pValue + 1 - m_lWidth); - lNrValues++; - }; - }; - - return fResult / lNrValues; - }; - - void InterpolateAll(double* pfValues, size_t x, size_t y) - { - size_t lIndice; - size_t lNrValues[4] = { 0 }; - - pfValues[0] = pfValues[1] = pfValues[2] = pfValues[3] = 0; - - for (size_t i = std::max(static_cast(0), x - 1); i <= std::min(static_cast(m_lWidth - 1), x + 1); i++) - for (size_t j = std::max(static_cast(0), y - 1); j <= std::min(static_cast(m_lHeight - 1), y + 1); j++) - { - lIndice = CMYGZeroIndex(::GetBayerColor(i, j, m_CFAType, m_xBayerOffset, m_yBayerOffset)); - pfValues[lIndice] += m_vPixels[GetOffset(i, j)]; - lNrValues[lIndice] ++; - }; - - pfValues[0] /= std::max(static_cast(1), lNrValues[0]); - pfValues[1] /= std::max(static_cast(1), lNrValues[1]); - pfValues[2] /= std::max(static_cast(1), lNrValues[2]); - pfValues[3] /= std::max(static_cast(1), lNrValues[3]); - - /* - // It's used only for CYMG - so cut it down to the basic - - if (x==m_lWidth-1) - x = m_lWidth-2; - if (y==m_lHeight-1) - y = m_lHeight-2; - - pfValues[0] = pfValues[1] = pfValues[2] = pfValues[3] = 0; - - for (int i = x;i<=x+1;i++) - for (int j = y;j<=y+1;j++) - pfValues[CMYGZeroIndex(::GetBayerColor(i, j, m_CFAType))] = m_vPixels[GetOffset(i, j)]; - */ - }; - -protected: - virtual void SetCFA(bool bCFA) override - { - m_bCFA = bCFA; - }; - -public: - CGrayBitmapT() : - m_lWidth{ 0 }, - m_lHeight{ 0 }, - m_bWord{ std::is_same_v }, - m_bDouble{ std::is_same_v }, - m_bDWord{ std::is_same_v }, - m_bFloat{ std::is_same_v }, - m_fMultiplier{ 1.0 } - { - if (m_bWord || m_bDouble || m_bFloat) - m_fMultiplier = 256.0; - else if (m_bDWord) - m_fMultiplier = 256.0 * 65536.0; - }; - - virtual ~CGrayBitmapT() {}; - - void SetMultiplier(double fMultiplier) - { - m_fMultiplier = fMultiplier; - }; - - virtual bool Init(int lWidth, int lHeight) override - { - m_lWidth = lWidth; - m_lHeight = lHeight; - return InitInternals(); - }; - - virtual std::unique_ptr Clone(bool bEmpty = false) const override - { - auto pResult = std::make_unique>(); - if (!bEmpty) - { - pResult->m_vPixels = m_vPixels; - pResult->m_lWidth = m_lWidth; - pResult->m_lHeight = m_lHeight; - }; - pResult->m_bWord = m_bWord; - pResult->m_bDouble = m_bDouble; - pResult->m_bDWord = m_bDWord; - pResult->m_bFloat = m_bFloat; - pResult->m_CFATransform = m_CFATransform; - pResult->m_CFAType = m_CFAType; - pResult->m_bCYMG = m_bCYMG; - pResult->CopyFrom(*this); - - return pResult; - } - - virtual BAYERCOLOR GetBayerColor(int x, int y) override - { - return ::GetBayerColor(x, y, m_CFAType, m_xBayerOffset, m_yBayerOffset); - } - - virtual int BitPerSample() override - { - return sizeof(TType) * 8; - } - - virtual int IsFloat() override - { - return m_bFloat; - } - - virtual int Width() const override - { - if (m_CFATransform == CFAT_SUPERPIXEL) - return m_lWidth / 2; - else - return m_lWidth; - } - - virtual int Height() const override - { - if (m_CFATransform == CFAT_SUPERPIXEL) - return m_lHeight / 2; - else - return m_lHeight; - } - - virtual int RealHeight() const override - { - return m_lHeight; - } - - virtual int RealWidth() const override - { - return m_lWidth; - } - - virtual void SetValue(size_t i, size_t j, double fGray) override - { - CheckXY(i, j); - m_vPixels[GetOffset(i, j)] = fGray; - } - - virtual void GetValue(size_t i, size_t j, double& fGray) const override - { - //if (CFAT_SUPERPIXEL == m_CFATransform) Bug fix 15th August 2020 - //{ - // i *= 2; j *= 2; - //} - CheckXY(i, j); - fGray = m_vPixels[GetOffset(i, j)]; - } - - virtual void SetPixel(size_t i, size_t j, double fRed, double fGreen, double fBlue) override - { - if (m_CFATransform == CFAT_SUPERPIXEL) - { - SetPixel(i * 2, j * 2, fRed); - SetPixel(i * 2, j * 2 + 1, fGreen); - SetPixel(i * 2 + 1, j * 2, fGreen); - SetPixel(i * 2 + 1, j * 2 + 1, fBlue); - } - else if (m_CFATransform == CFAT_NONE) - SetPixel(i, j, fRed); - else - SetPixel(i, j, GetPrimary(i, j, fRed, fGreen, fBlue)); - } - - inline virtual void SetPixel(size_t i, size_t j, double fGray) override - { - SetValue(i, j, fGray * m_fMultiplier); - } - - virtual void GetPixel(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) override - { - CheckXY(i, j); - fRed = fGreen = fBlue = 0.0; - - if (m_CFATransform == CFAT_SUPERPIXEL) - { - assert(m_bWord); - if (IsXYOk((i - 1) * 2, (j - 1) * 2) && IsXYOk((i + 1) * 2 + 1, (j + 1) * 2 + 1)) - { - TType* pValue = &(m_vPixels[GetOffset(i * 2, j * 2)]); - - switch (m_CFAType) - { - case CFATYPE_GRBG: - fRed = (*(pValue + 1)) / m_fMultiplier; - fGreen = ((*pValue) + (*(pValue + 1 + m_lWidth))) / 2.0 / m_fMultiplier; - fBlue = (*(pValue + m_lWidth)) / m_fMultiplier; - break; - case CFATYPE_GBRG: - fRed = (*(pValue + m_lWidth)) / m_fMultiplier; - fGreen = ((*pValue) + (*(pValue + 1 + m_lWidth))) / 2.0 / m_fMultiplier; - fBlue = (*(pValue + 1)) / m_fMultiplier; - break; - case CFATYPE_BGGR: - fRed = (*(pValue + 1 + m_lWidth)) / m_fMultiplier; - fGreen = ((*(pValue + m_lWidth)) + (*(pValue + 1))) / 2.0 / m_fMultiplier; - fBlue = (*pValue) / m_fMultiplier; - break; - case CFATYPE_RGGB: - fRed = (*pValue) / m_fMultiplier; - fGreen = ((*(pValue + m_lWidth)) + (*(pValue + 1))) / 2.0 / m_fMultiplier; - fBlue = (*(pValue + 1 + m_lWidth)) / m_fMultiplier; - break; - } - } - } - else if (m_CFATransform == CFAT_RAWBAYER) - { - assert(m_bWord); - TType* pValue = &(m_vPixels[GetOffset(i, j)]); - - switch (::GetBayerColor(i, j, m_CFAType, m_xBayerOffset, m_yBayerOffset)) - { - case BAYER_RED: - fRed = (*pValue) / m_fMultiplier; - break; - case BAYER_GREEN: - fGreen = (*pValue) / m_fMultiplier; - break; - case BAYER_BLUE: - fBlue = (*pValue) / m_fMultiplier; - break; - }; - } - else if ((m_CFATransform == CFAT_BILINEAR) || (m_CFATransform == CFAT_AHD)) - { - assert(m_bWord); - if (m_bCYMG) - { - double fValue[4]; // Myself - InterpolateAll(fValue, i, j); - - CYMGToRGB(fValue[CMYGZeroIndex(BAYER_CYAN)] / m_fMultiplier, - fValue[CMYGZeroIndex(BAYER_YELLOW)] / m_fMultiplier, - fValue[CMYGZeroIndex(BAYER_MAGENTA)] / m_fMultiplier, - fValue[CMYGZeroIndex(BAYER_GREEN2)] / m_fMultiplier, - fRed, fGreen, fBlue - ); - } - else - { - TType* pValue = &(m_vPixels[GetOffset(i, j)]); - switch (::GetBayerColor(i, j, m_CFAType, m_xBayerOffset, m_yBayerOffset)) - { - case BAYER_RED: - fRed = (*pValue) / m_fMultiplier; - fGreen = InterpolateGreen(i, j, pValue) / m_fMultiplier; - fBlue = InterpolateBlue(i, j, pValue) / m_fMultiplier; - break; - case BAYER_GREEN: - fRed = InterpolateRed(i, j, pValue) / m_fMultiplier; - fGreen = (*pValue) / m_fMultiplier; - fBlue = InterpolateBlue(i, j, pValue) / m_fMultiplier; - break; - case BAYER_BLUE: - fRed = InterpolateRed(i, j, pValue) / m_fMultiplier; - fGreen = InterpolateGreen(i, j, pValue) / m_fMultiplier; - fBlue = (*pValue) / m_fMultiplier; - break; - }; - }; - - } - else if (m_CFATransform == CFAT_GRADIENT) - { - } - else - { - fRed = fBlue = fGreen = m_vPixels[GetOffset(i, j)] / m_fMultiplier; - } - } - - virtual void inline GetPixel(size_t i, size_t j, double& fGray) override - { - GetValue(i, j, fGray); - fGray /= m_fMultiplier; - } - - virtual bool GetScanLine(size_t j, void* pScanLine) override - { - bool bResult = false; - - if (j < m_lHeight) - { - memcpy(pScanLine, &(m_vPixels[j * m_lWidth]), sizeof(TType) * m_lWidth); - bResult = true; - }; - - return bResult; - } - - virtual bool SetScanLine(size_t j, void* pScanLine) override - { - bool bResult = false; - - if (j < m_lHeight) - { - memcpy(&(m_vPixels[j * m_lWidth]), pScanLine, sizeof(TType) * m_lWidth); - bResult = true; - }; - - return bResult; - } - - virtual std::shared_ptr CreateEmptyMultiBitmap() const override - { - std::shared_ptr> pResult = std::make_shared>(); - pResult->SetBitmapModel(this); - return pResult; - } - - virtual void RemoveHotPixels(ProgressBase* pProgress = nullptr) override; - - TType* GetGrayPixel(int i, int j) - { - return m_vPixels.data() + GetOffset(i, j); - } - const TType* GetGrayPixel(const int i, const int j) const - { - return m_vPixels.data() + GetOffset(i, j); - } - - double GetMultiplier() const - { - return m_fMultiplier; - } - - virtual std::shared_ptr GetMedianFilterEngine() const override - { - std::shared_ptr> pFilter = std::make_shared>(); - pFilter->SetInputBitmap(this); - return pFilter; - } - - virtual double GetMaximumValue() const override - { - return m_fMultiplier * 256.0; - } - - virtual void GetCharacteristics(CBitmapCharacteristics& bc) override - { - bc.m_bFloat = m_bFloat; - bc.m_dwHeight = m_lHeight; - bc.m_dwWidth = m_lWidth; - bc.m_lNrChannels = 1; - bc.m_lBitsPerPixel = BitPerSample(); - } - - virtual void InitIterator(void*& pRed, void*& pGreen, void*& pBlue, size_t& elementSize, const size_t x, const size_t y) override - { - pRed = static_cast(this->m_vPixels.data() + GetOffset(x, y)); - pGreen = pRed; - pBlue = pRed; - elementSize = sizeof(TType); - } - virtual void InitIterator(const void*& pRed, const void*& pGreen, const void*& pBlue, size_t& elementSize, const size_t x, const size_t y) const override - { - pRed = static_cast(this->m_vPixels.data() + GetOffset(x, y)); - pGreen = pRed; - pBlue = pRed; - elementSize = sizeof(TType); - } - - virtual std::tuple ConvertValue3(const void* pRed, const void*, const void*) const override - { - const double value = static_cast(*static_cast(pRed)) / this->m_fMultiplier; - return { value, value, value }; - } - virtual double ConvertValue1(const void* pRed, const void*, const void*) const override - { - return static_cast(*static_cast(pRed)) / this->m_fMultiplier; - } - - virtual void ReceiveValue(void*, void*, void*, const double, const double, const double) const override - {} - virtual void ReceiveValue(void* pRed, void*, void*, const double gray) const override - { - *static_cast(pRed) = static_cast(gray * this->m_fMultiplier); - } -}; - - -typedef CGrayBitmapT CGrayBitmap; -typedef CGrayBitmapT C8BitGrayBitmap; -typedef CGrayBitmapT C16BitGrayBitmap; -typedef CGrayBitmapT C32BitGrayBitmap; -typedef CGrayBitmapT C32BitFloatGrayBitmap; - - -template -class CColorMultiBitmapT : public CMultiBitmap -{ -protected: - virtual std::shared_ptr CreateNewMemoryBitmap() const override - { - if (static_cast(m_pBitmapModel)) - { - CBitmapCharacteristics bc; - m_pBitmapModel->GetCharacteristics(bc); - if (bc.m_lNrChannels == 3) - return m_pBitmapModel->Clone(true); - else - { - bc.m_lNrChannels = 3; - return CreateBitmap(bc); - } - } - else - return std::make_shared>(); - } - - virtual std::shared_ptr CreateOutputMemoryBitmap() const override - { - return std::make_shared>(); - } - - virtual bool SetScanLines(CMemoryBitmap* pBitmap, int lLine, const std::vector& vScanLines) override - { - bool bResult = false; - // Each scan line consist of lWidth TType values - TTypeOutput* pRedCurrentValue; - TTypeOutput* pGreenCurrentValue; - TTypeOutput* pBlueCurrentValue; - std::vector vRedValues; - std::vector vGreenValues; - std::vector vBlueValues; - std::vector vWorkingBuffer1; - std::vector vWorkingBuffer2; - std::vector vdWork1; // Used for AutoAdaptiveWeightedAverage - std::vector vdWork2; // Used for AutoAdaptiveWeightedAverage - double fMaximum = pBitmap->GetMaximumValue(); - const int lWidth = pBitmap->RealWidth(); - - std::vector outputScanBuffer; - try { - outputScanBuffer.resize(lWidth * 3); - } - catch (...) { - ZOutOfMemory e("Could not allocate storage for output scanline"); - ZTHROW(e); - } - - pRedCurrentValue = outputScanBuffer.data(); - pGreenCurrentValue = pRedCurrentValue + lWidth; - pBlueCurrentValue = pGreenCurrentValue + lWidth; - - vRedValues.reserve(vScanLines.size()); - vGreenValues.reserve(vScanLines.size()); - vBlueValues.reserve(vScanLines.size()); - vWorkingBuffer1.reserve(vScanLines.size()); - vWorkingBuffer2.reserve(vScanLines.size()); - vdWork1.reserve(vScanLines.size()); - vdWork2.reserve(vScanLines.size()); - - for (int i = 0; i < lWidth; i++) - { - TType* pRedValue; - TType* pGreenValue; - TType* pBlueValue; - - vRedValues.resize(0); - vGreenValues.resize(0); - vBlueValues.resize(0); - for (auto p : vScanLines) - { - pRedValue = static_cast(p) + i; - pGreenValue = pRedValue + lWidth; - pBlueValue = pGreenValue + lWidth; - - if (*pRedValue || !m_vImageOrder.empty()) // Remove 0 - vRedValues.push_back(*pRedValue); - if (*pGreenValue || !m_vImageOrder.empty()) // Remove 0 - vGreenValues.push_back(*pGreenValue); - if (*pBlueValue || !m_vImageOrder.empty()) // Remove 0 - vBlueValues.push_back(*pBlueValue); - } - - if (m_bHomogenization) - { - // if ((i==843) && (lLine==934)) - // DebugBreak(); - - if (static_cast(m_pHomBitmap)) - { - double fAverage, fSigma; - double fRed, fGreen, fBlue; - - fSigma = Sigma2(vRedValues, fAverage); - fRed = fSigma / std::max(1.0, fAverage) * 256.0; - fSigma = Sigma2(vGreenValues, fAverage); - fGreen = fSigma / std::max(1.0, fAverage) * 256.0; - fSigma = Sigma2(vBlueValues, fAverage); - fBlue = fSigma / std::max(1.0, fAverage) * 256.0; - - m_pHomBitmap->SetPixel(i, lLine, fRed, fGreen, fBlue); - } - - if (!m_vImageOrder.empty()) - { - std::vector vAuxRedValues; - std::vector vAuxGreenValues; - std::vector vAuxBlueValues; - // Change the order to respect the order of the images - std::swap(vAuxRedValues, vRedValues); - std::swap(vAuxGreenValues, vGreenValues); - std::swap(vAuxBlueValues, vBlueValues); - for (const size_t imgOrder : m_vImageOrder) - { - if (vAuxRedValues[imgOrder] || vAuxGreenValues[imgOrder] || vAuxBlueValues[imgOrder]) - { - vRedValues.push_back(vAuxRedValues[imgOrder]); - vGreenValues.push_back(vAuxGreenValues[imgOrder]); - vBlueValues.push_back(vAuxBlueValues[imgOrder]); - } - } - - Homogenize(vRedValues, fMaximum); - Homogenize(vGreenValues, fMaximum); - Homogenize(vBlueValues, fMaximum); - } - else - { - Homogenize(vRedValues, fMaximum); - Homogenize(vGreenValues, fMaximum); - Homogenize(vBlueValues, fMaximum); - } - - if (vRedValues.empty() || vGreenValues.empty() || vBlueValues.empty()) - { - vRedValues.resize(0); - vGreenValues.resize(0); - vBlueValues.resize(0); - } - } - else - { - if constexpr (sizeof(TType) == 4 && std::is_integral::value) - { - - for (auto& x : vRedValues) x >>= 16; - for (auto& x : vGreenValues) x >>= 16; - for (auto& x : vBlueValues) x >>= 16; - } - } - - // Process the value - if (m_Method == MBP_MEDIAN) - { - *pRedCurrentValue = Median(vRedValues); - *pGreenCurrentValue = Median(vGreenValues); - *pBlueCurrentValue = Median(vBlueValues); - } - else if (m_Method == MBP_AVERAGE) - { - *pRedCurrentValue = Average(vRedValues); - *pGreenCurrentValue = Average(vGreenValues); - *pBlueCurrentValue = Average(vBlueValues); - } - else if (m_Method == MBP_MAXIMUM) - { - *pRedCurrentValue = Maximum(vRedValues); - *pGreenCurrentValue = Maximum(vGreenValues); - *pBlueCurrentValue = Maximum(vBlueValues); - } - else if (m_Method == MBP_SIGMACLIP) - { - *pRedCurrentValue = KappaSigmaClip(vRedValues, m_fKappa, m_lNrIterations, vWorkingBuffer1); - *pGreenCurrentValue = KappaSigmaClip(vGreenValues, m_fKappa, m_lNrIterations, vWorkingBuffer1); - *pBlueCurrentValue = KappaSigmaClip(vBlueValues, m_fKappa, m_lNrIterations, vWorkingBuffer1); - } - else if (m_Method == MBP_MEDIANSIGMACLIP) - { - *pRedCurrentValue = MedianKappaSigmaClip(vRedValues, m_fKappa, m_lNrIterations, vWorkingBuffer1, vWorkingBuffer2); - *pGreenCurrentValue = MedianKappaSigmaClip(vGreenValues, m_fKappa, m_lNrIterations, vWorkingBuffer1, vWorkingBuffer2); - *pBlueCurrentValue = MedianKappaSigmaClip(vBlueValues, m_fKappa, m_lNrIterations, vWorkingBuffer1, vWorkingBuffer2); - } - else if (m_Method == MBP_AUTOADAPTIVE) - { - *pRedCurrentValue = AutoAdaptiveWeightedAverage(vRedValues, m_lNrIterations, vdWork1); - *pGreenCurrentValue = AutoAdaptiveWeightedAverage(vGreenValues, m_lNrIterations, vdWork1); - *pBlueCurrentValue = AutoAdaptiveWeightedAverage(vBlueValues, m_lNrIterations, vdWork1); - }; - - pRedCurrentValue++; - pGreenCurrentValue++; - pBlueCurrentValue++; - }; - - pBitmap->SetScanLine(lLine, outputScanBuffer.data()); - bResult = true; - - return bResult; - }; - -public: - CColorMultiBitmapT() - { - }; - - virtual ~CColorMultiBitmapT() - { - }; - - virtual int GetNrChannels() const override - { - return 3; - }; - - virtual int GetNrBytesPerChannel() const override - { - return sizeof(TType); - }; -}; - - -template -class CColorMedianFilterEngineT : public CMedianFilterEngine -{ -private: - const CColorBitmapT* m_pInBitmap; - -public: - CColorMedianFilterEngineT() {}; - virtual ~CColorMedianFilterEngineT() {}; - - void SetInputBitmap(const CColorBitmapT* pInBitmap) - { - m_pInBitmap = pInBitmap; - } - - virtual std::shared_ptr GetFilteredImage(int lFilterSize, ProgressBase* pProgress) const override; -}; - - -class CColorBitmap -{ -public: - CColorBitmap() - {} - - virtual ~CColorBitmap() - {} - - virtual CMemoryBitmap* GetRed() = 0; - virtual CMemoryBitmap* GetGreen() = 0; - virtual CMemoryBitmap* GetBlue() = 0; -}; - - -template -class CColorBitmapT : public CMemoryBitmap, public CColorBitmap -{ -public: - friend CColorMedianFilterEngineT; - -private: - int m_lHeight; - int m_lWidth; - bool m_bWord; - bool m_bDouble; - bool m_bDWord; - bool m_bFloat; - const double m_fMultiplier; - -public: - CGrayBitmapT m_Red; - CGrayBitmapT m_Green; - CGrayBitmapT m_Blue; - -private: - inline void CheckXY(size_t x, size_t y) const - { - ZASSERTSTATE(x >= 0 && x < m_lWidth && y >= 0 && y < m_lHeight); - } - - size_t GetOffset(const size_t x, const size_t y) const - { - return m_bTopDown ? static_cast(m_lWidth) * y + x : static_cast(m_lWidth) * (static_cast(m_lHeight) - 1 - y) + x; - } - size_t GetOffset(int x, int y) const - { - CheckXY(x, y); - return GetOffset(static_cast(x), static_cast(y)); - } - -public: - CColorBitmapT() : - m_lWidth{ 0 }, - m_lHeight{ 0 }, - m_bWord{ std::is_same_v }, - m_bDouble{ std::is_same_v }, - m_bDWord{ std::is_same_v }, - m_bFloat{ std::is_same_v }, - m_fMultiplier{ (std::is_same_v || std::is_same_v || std::is_same_v) ? 256.0 : (std::is_same_v ? 256.0 * 65536.0 : 1.0) } - { - m_bTopDown = true; - } - - virtual ~CColorBitmapT() = default; - - virtual std::unique_ptr Clone(bool bEmpty = false) const override - { - auto pResult = std::make_unique>(); - if (!bEmpty) - { - pResult->m_lHeight = m_lHeight; - pResult->m_lWidth = m_lWidth; - pResult->m_Red.m_vPixels = m_Red.m_vPixels; - pResult->m_Green.m_vPixels = m_Green.m_vPixels; - pResult->m_Blue.m_vPixels = m_Blue.m_vPixels; - } - pResult->m_bWord = m_bWord; - pResult->m_bDouble = m_bDouble; - pResult->m_bDWord = m_bDWord; - pResult->m_bFloat = m_bFloat; - - pResult->CopyFrom(*this); - - return pResult; - } - - virtual int BitPerSample() override - { - return sizeof(TType) * 8; - } - - virtual int IsFloat() override - { - return m_bFloat; - } - - virtual int Width() const override - { - return m_lWidth; - } - - virtual int Height() const override - { - return m_lHeight; - } - - virtual bool Init(int lWidth, int lHeight) override - { - m_lWidth = lWidth; - m_lHeight = lHeight; - - const bool bResult = m_Red.Init(lWidth, lHeight) && m_Green.Init(lWidth, lHeight) && m_Blue.Init(lWidth, lHeight); - return bResult; - } - - virtual bool IsMonochrome() const override - { - return false; - } - - virtual void SetValue(size_t i, size_t j, double fRed, double fGreen, double fBlue) override - { - CheckXY(i, j); - - const size_t lOffset = GetOffset(i, j); - - m_Red.m_vPixels[lOffset] = fRed; - m_Green.m_vPixels[lOffset] = fGreen; - m_Blue.m_vPixels[lOffset] = fBlue; - } - - virtual void GetValue(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) const override - { - CheckXY(i, j); - - const size_t lOffset = GetOffset(i, j); - - fRed = m_Red.m_vPixels[lOffset]; - fGreen = m_Green.m_vPixels[lOffset]; - fBlue = m_Blue.m_vPixels[lOffset]; - } - - virtual void SetPixel(size_t i, size_t j, double fRed, double fGreen, double fBlue) override - { - CheckXY(i, j); - - const size_t lOffset = GetOffset(i, j); - m_Red.m_vPixels[lOffset] = fRed * m_fMultiplier; - m_Green.m_vPixels[lOffset] = fGreen * m_fMultiplier; - m_Blue.m_vPixels[lOffset] = fBlue * m_fMultiplier; - } - - virtual void SetPixel(size_t i, size_t j, double fGray) override - { - - CheckXY(i, j); // Throw if not - - const size_t lOffset = GetOffset(i, j); - const double value = fGray * m_fMultiplier; - m_Red.m_vPixels[lOffset] = value; - m_Green.m_vPixels[lOffset] = value; - m_Blue.m_vPixels[lOffset] = value; - } - - virtual void GetPixel(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) override - { - fRed = fGreen = fBlue = 0.0; - - CheckXY(i, j); - - const size_t lOffset = GetOffset(i, j); - - fRed = m_Red.m_vPixels[lOffset] / m_fMultiplier; - fGreen = m_Green.m_vPixels[lOffset] / m_fMultiplier; - fBlue = m_Blue.m_vPixels[lOffset] / m_fMultiplier; - } - - virtual void GetPixel(size_t i, size_t j, double& fGray) override - { - double fRed, fGreen, fBlue; - fGray = 0.0; - - GetPixel(i, j, fRed, fGreen, fBlue); - double H, S, L; - - ToHSL(fRed, fGreen, fBlue, H, S, L); - fGray = L * 255.0; - } - - virtual bool GetScanLine(size_t j, void* pScanLine) override - { - bool bResult = false; - - if (j < m_lHeight) - { - auto* const pTempScan = static_cast(pScanLine); - const size_t w = static_cast(m_lWidth); - const size_t index = static_cast(j) * w; - - memcpy(pTempScan, &(m_Red.m_vPixels[index]), sizeof(TType) * w); - memcpy(pTempScan + sizeof(TType) * w, &(m_Green.m_vPixels[index]), sizeof(TType) * w); - memcpy(pTempScan + sizeof(TType) * 2 * w, &(m_Blue.m_vPixels[index]), sizeof(TType) * w); - bResult = true; - } - - return bResult; - } - - virtual bool SetScanLine(size_t j, void* pScanLine) override - { - bool bResult = false; - - if (j < m_lHeight) - { - const auto* const pTempScan = static_cast(pScanLine); - const size_t w = static_cast(m_lWidth); - const size_t index = static_cast(j) * w; - - memcpy(&(m_Red.m_vPixels[index]), pTempScan, sizeof(TType) * w); - memcpy(&(m_Green.m_vPixels[index]), pTempScan + sizeof(TType) * w, sizeof(TType) * w); - memcpy(&(m_Blue.m_vPixels[index]), pTempScan + sizeof(TType) * 2 * w, sizeof(TType) * w); - bResult = true; - } - - return bResult; - } - - void Clear() - { - m_lHeight = 0; - m_lWidth = 0; - m_Red.m_vPixels.clear(); - m_Green.m_vPixels.clear(); - m_Blue.m_vPixels.clear(); - } - - virtual std::shared_ptr CreateEmptyMultiBitmap() const override - { - std::shared_ptr> pResult = std::make_shared>(); - pResult->SetBitmapModel(this); - return pResult; - } - - virtual std::shared_ptr GetMedianFilterEngine() const override - { - std::shared_ptr> pFilter = std::make_shared>(); - pFilter->SetInputBitmap(this); - return pFilter; - } - - TType* GetRedPixel(int i, int j) - { - return m_Red.m_vPixels.data() + GetOffset(i, j); - } - TType* GetGreenPixel(int i, int j) - { - return m_Green.m_vPixels.data() + GetOffset(i, j); - } - TType* GetBluePixel(int i, int j) - { - return m_Blue.m_vPixels.data() + GetOffset(i, j); - } - - virtual CMemoryBitmap* GetRed() override - { - return &m_Red; - } - - virtual CMemoryBitmap* GetGreen() override - { - return &m_Green; - } - - virtual CMemoryBitmap* GetBlue() override - { - return &m_Blue; - } - - double GetMultiplier() - { - return m_fMultiplier; - } - - virtual double GetMaximumValue() const override - { - return m_fMultiplier * 256.0; - } - - virtual void RemoveHotPixels(ProgressBase* pProgress = nullptr) override - { - m_Red.RemoveHotPixels(pProgress); - m_Green.RemoveHotPixels(pProgress); - m_Blue.RemoveHotPixels(pProgress); - } - - virtual void GetCharacteristics(CBitmapCharacteristics& bc) override - { - bc.m_bFloat = m_bFloat; - bc.m_dwHeight = m_lHeight; - bc.m_dwWidth = m_lWidth; - bc.m_lNrChannels = 3; - bc.m_lBitsPerPixel = BitPerSample(); - } - - virtual void InitIterator(void*& pRed, void*& pGreen, void*& pBlue, size_t& elementSize, const size_t x, const size_t y) override - { - const size_t index = GetOffset(x, y); - pRed = static_cast(this->m_Red.m_vPixels.data() + index); - pGreen = static_cast(this->m_Green.m_vPixels.data() + index); - pBlue = static_cast(this->m_Blue.m_vPixels.data() + index); - elementSize = sizeof(TType); - } - virtual void InitIterator(const void*& pRed, const void*& pGreen, const void*& pBlue, size_t& elementSize, const size_t x, const size_t y) const override - { - const size_t index = GetOffset(x, y); - pRed = static_cast(this->m_Red.m_vPixels.data() + index); - pGreen = static_cast(this->m_Green.m_vPixels.data() + index); - pBlue = static_cast(this->m_Blue.m_vPixels.data() + index); - elementSize = sizeof(TType); - } - - virtual std::tuple ConvertValue3(const void* pRed, const void* pGreen, const void* pBlue) const override - { - const double r = static_cast(*static_cast(pRed)) / this->m_fMultiplier; - const double g = static_cast(*static_cast(pGreen)) / this->m_fMultiplier; - const double b = static_cast(*static_cast(pBlue)) / this->m_fMultiplier; - return { r, g, b }; - } - virtual double ConvertValue1(const void* pRed, const void* pGreen, const void* pBlue) const override - { - const double r = static_cast(*static_cast(pRed)) / this->m_fMultiplier; - const double g = static_cast(*static_cast(pGreen)) / this->m_fMultiplier; - const double b = static_cast(*static_cast(pBlue)) / this->m_fMultiplier; - double H, S, L; - ToHSL(r, g, b, H, S, L); - return L * 255.0; - } - - virtual void ReceiveValue(void* pRed, void* pGreen, void* pBlue, const double red, const double green, const double blue) const override - { - *static_cast(pRed) = static_cast(red * this->m_fMultiplier); - *static_cast(pGreen) = static_cast(green * this->m_fMultiplier); - *static_cast(pBlue) = static_cast(blue * this->m_fMultiplier); - } - virtual void ReceiveValue(void* pRed, void* pGreen, void* pBlue, const double gray) const override - { - const TType value = static_cast(gray * this->m_fMultiplier); - *static_cast(pRed) = value; - *static_cast(pGreen) = value; - *static_cast(pBlue) = value; - } -}; - - -typedef CColorBitmapT C24BitColorBitmap; -typedef CColorBitmapT C48BitColorBitmap; -typedef CColorBitmapT C96BitColorBitmap; -typedef CColorBitmapT C96BitFloatColorBitmap; - - -template -class CopyableSmartPtr final -{ -private: - std::unique_ptr p; -public: - template CopyableSmartPtr(std::unique_ptr&) = delete; - CopyableSmartPtr() = delete; - CopyableSmartPtr& operator=(const CopyableSmartPtr&) = delete; - - template - CopyableSmartPtr(std::unique_ptr&& rhs) : p{ std::move(rhs) } {} - - CopyableSmartPtr(const CopyableSmartPtr& rhs) : p{ rhs->clone() } {} - - typename std::unique_ptr::pointer get() const noexcept { return p.get(); } - typename std::unique_ptr::pointer operator->() const noexcept { return this->get(); } -}; diff --git a/DeepSkyStacker/BitmapCharacteristics.h b/DeepSkyStacker/BitmapCharacteristics.h new file mode 100644 index 000000000..196d46729 --- /dev/null +++ b/DeepSkyStacker/BitmapCharacteristics.h @@ -0,0 +1,41 @@ +#pragma once + +class CBitmapCharacteristics +{ +public: + int m_lNrChannels; + int m_lBitsPerPixel; + bool m_bFloat; + std::uint32_t m_dwWidth, m_dwHeight; + +private: + void CopyFrom(const CBitmapCharacteristics& bc) + { + m_lNrChannels = bc.m_lNrChannels; + m_lBitsPerPixel = bc.m_lBitsPerPixel; + m_bFloat = bc.m_bFloat; + m_dwWidth = bc.m_dwWidth; + m_dwHeight = bc.m_dwHeight; + }; + +public: + CBitmapCharacteristics() : + m_lNrChannels{ 0 }, + m_lBitsPerPixel{ 0 }, + m_bFloat{ false }, + m_dwWidth{ 0 }, + m_dwHeight{ 0 } + {} + ~CBitmapCharacteristics() {}; + + CBitmapCharacteristics(const CBitmapCharacteristics& bc) + { + CopyFrom(bc); + }; + + CBitmapCharacteristics& operator= (const CBitmapCharacteristics& bc) + { + CopyFrom(bc); + return *this; + }; +}; \ No newline at end of file diff --git a/DeepSkyStacker/BitmapConstants.h b/DeepSkyStacker/BitmapConstants.h new file mode 100644 index 000000000..6f70f09be --- /dev/null +++ b/DeepSkyStacker/BitmapConstants.h @@ -0,0 +1 @@ +#pragma once diff --git a/DeepSkyStacker/BitmapExt.cpp b/DeepSkyStacker/BitmapExt.cpp index 46ba2fc1c..d8f504282 100644 --- a/DeepSkyStacker/BitmapExt.cpp +++ b/DeepSkyStacker/BitmapExt.cpp @@ -1,137 +1,28 @@ #include -#include -#include -#include -#include -#include -#include - -#include "resource.h" -#ifndef _CONSOLE -#include -#include -#include -#include "DeepSkyStacker.h" -#endif -#include - #include "BitmapExt.h" -#include "DSSTools.h" #include "DSSProgress.h" - +#include "MemoryBitmap.h" +#include "GrayBitmap.h" +#include "ColorBitmap.h" +#include "BitmapIterator.h" +#include "AHDDemosaicing.h" +#include "Multitask.h" +#include "Ztrace.h" +#include "ZExcBase.h" +#include "ZExcept.h" +#include "RationalInterpolation.h" +#include "RAWUtils.h" #include "TIFFUtil.h" #include "FITSUtil.h" -#include "RAWUtils.h" -#include "Multitask.h" -#include "Workspace.h" -#include "BitmapIterator.h" - +#include "File.h" +#include "MedianFilterEngine.h" +#include "omp.h" -#include -using namespace Gdiplus; +#ifndef _CONSOLE +#include "DeepSkyStacker.h" +#endif//_CONSOLE -#ifdef PCL_PROJECT -#include -#endif - -/* ------------------------------------------------------------------- */ - -void CYMGToRGB12(double fCyan, double fYellow, double fMagenta, double fGreen2, double& fRed, double& fGreen, double& fBlue) -{ - double Y, U, V; - double R, G, B; - - Y = (fCyan + fYellow + fMagenta + fGreen2) / 2.0; - U = -(fMagenta + fCyan - fYellow - fGreen2);//*0.492; - V = (fMagenta + fYellow - fCyan - fGreen2);//*0.877; - - R = 1.164 * Y + 1.596 * (V - 128.0); - G = 1.164 * Y - 0.813 * (V - 128.0) - 0.391 * (U - 128); - B = 1.164 * Y + 2.018 * (U - 128.0); - - - fRed = R * 1.29948 + G * 0.0289296 - B * 0.934432; - fGreen = -0.409754 * R + 1.31042 * G - 0.523692 * B; - fBlue = 0.110277 * R - 0.339351 * G + 2.45812 * B; - - // fRed = (Y+1.13983*V)*255.0; - // fGreen = (Y-0.39465*U-0.5806*V)*255.0; - // fBlue = (Y+2.03211*U)*255.0; - - fRed = std::max(0.0, std::min(255.0, fRed)); - fGreen = std::max(0.0, std::min(255.0, fGreen)); - fBlue = std::max(0.0, std::min(255.0, fBlue)); -}; - - -void CYMGToRGB(double fCyan, double fYellow, double fMagenta, double fGreen2, double& fRed, double& fGreen, double& fBlue) -{ - fRed = fGreen = fBlue = 0; - // Basic formulae - // M = R + B - // Y = R + G - // C = B + G - - - // RGB from CYM - // R = (M+Y-C)/2 - // G = (Y+C-M)/2 - // B = (M+C-Y)/2 - fRed = std::max(0.0, fMagenta + fYellow - fCyan) / 2.0; - fGreen = std::max(0.0, fYellow + fCyan - fMagenta) / 2.0; - fBlue = std::max(0.0, fMagenta + fCyan - fYellow) / 2.0; - - /* if (fGreen2) - { - fRed *= fGreen2/fGreen; - fBlue *= fGreen2/fGreen; - fGreen = fGreen2; - }; - fRed = std::min(fRed, 255); - fBlue = std::min(fBlue, 255); - fGreen = std::min(fGreen, 255);*/ - - // RGB from CYG - // G = G - // R = Y - G - // B = C - G - fGreen += fGreen2; - fRed += fYellow - fGreen2; - fBlue += fCyan - fGreen2; - - // RGB from CMG - // G = G - // B = C - G - // R = M - B = M - C + G -// fGreen += fGreen2; - fBlue += fCyan - fGreen2; - fRed += fMagenta - fCyan + fGreen2; - - // RGB from YMG - // G = G - // R = Y - G - // B = M - R = M - Y + G -// fGreen += fGreen2; - fRed += fYellow - fGreen2; - fBlue += fMagenta - fYellow + fGreen2; - - // Average the results - fRed /= 4.0; - fBlue /= 4.0; - fGreen /= 2.0; - - double R = fRed; - double B = fBlue; - double G = fGreen; - - fRed = R * 1.29948 + G * 0.0289296 - B * 0.934432; - fGreen = -0.409754 * R + 1.31042 * G - 0.523692 * B; - fBlue = 0.110277 * R - 0.339351 * G + 2.45812 * B; - - fRed = std::max(0.0, std::min(255.0, fRed)); - fGreen = std::max(0.0, std::min(255.0, fGreen)); - fBlue = std::max(0.0, std::min(255.0, fBlue)); -}; +using namespace DSS; /* ------------------------------------------------------------------- */ @@ -180,8 +71,6 @@ void CopyBitmapToClipboard(HBITMAP hBitmap) }; /* ------------------------------------------------------------------- */ -#if DSSFILEDECODING==1 - bool DebayerPicture(CMemoryBitmap* pInBitmap, std::shared_ptr& rpOutBitmap, ProgressBase* pProgress) { ZFUNCTRACE_RUNTIME(); @@ -397,11 +286,11 @@ bool LoadPicture(LPCTSTR szFileName, CAllDepthBitmap& AllDepthBitmap, ProgressBa } catch (std::exception & e) { - CString errorMessage(static_cast(CA2CT(e.what()))); + const QString errorMessage(e.what()); #if defined(_CONSOLE) - std::wcerr << errorMessage; + std::wcerr << errorMessage.toStdWString().c_str(); #else - AfxMessageBox(errorMessage, MB_OK | MB_ICONSTOP); + AfxMessageBox(errorMessage.toStdWString().c_str(), MB_OK | MB_ICONSTOP); #endif exit(1); } @@ -415,33 +304,31 @@ bool LoadPicture(LPCTSTR szFileName, CAllDepthBitmap& AllDepthBitmap, ProgressBa #endif catch (ZException & ze) { - CString errorMessage; - CString name(CA2CT(ze.name())); - CString fileName(CA2CT(ze.locationAtIndex(0)->fileName())); - CString functionName(CA2CT(ze.locationAtIndex(0)->functionName())); - CString text(CA2CT(ze.text(0))); - - errorMessage.Format( - _T("Exception %s thrown from %s Function: %s() Line: %lu\n\n%s"), - name, - fileName, - functionName, - ze.locationAtIndex(0)->lineNumber(), - text); + const QString name(ze.name()); + const QString fileName(ze.locationAtIndex(0)->fileName()); + const QString functionName(ze.locationAtIndex(0)->functionName()); + const QString text(ze.text(0)); + + const QString errorMessage = QString("Exception %1 thrown from %2 Function: %3() Line: %4\n\n%5") + .arg(name) + .arg(fileName) + .arg(functionName) + .arg(ze.locationAtIndex(0)->lineNumber()) + .arg(text); #if defined(_CONSOLE) - std::wcerr << errorMessage; + std::wcerr << errorMessage.toStdWString().c_str(); #else - AfxMessageBox(errorMessage, MB_OK | MB_ICONSTOP); + AfxMessageBox(errorMessage.toStdWString().c_str(), MB_OK | MB_ICONSTOP); #endif exit(1); } catch (...) { - CString errorMessage(_T("Unknown exception caught")); + const QString errorMessage("Unknown exception caught"); #if defined(_CONSOLE) - std::wcerr << errorMessage; + std::wcerr << errorMessage.toStdWString().c_str(); #else - AfxMessageBox(errorMessage, MB_OK | MB_ICONSTOP); + AfxMessageBox(errorMessage.toStdWString().c_str(), MB_OK | MB_ICONSTOP); #endif exit(1); } @@ -516,208 +403,7 @@ bool LoadOtherPicture(LPCTSTR szFileName, std::shared_ptr& rpBitm } -bool RetrieveEXIFInfo(Gdiplus::Bitmap* pBitmap, CBitmapInfo& BitmapInfo) -{ - ZFUNCTRACE_RUNTIME(); - bool bResult = false; - - const auto getExifItem = [pBitmap, &bResult](const PROPID propertyId, const unsigned short type, auto& field) -> void - { - const auto dwPropertySize = pBitmap->GetPropertyItemSize(propertyId); - if (dwPropertySize != 0) - { - auto buffer = std::make_unique(dwPropertySize); - Gdiplus::PropertyItem* const propertyItem = reinterpret_cast(buffer.get()); - - if (propertyItem->type == type && pBitmap->GetPropertyItem(propertyId, dwPropertySize, propertyItem) == Gdiplus::Status::Ok) - { - if (propertyItem->type == PropertyTagTypeRational) - { - const std::uint32_t* pValues = static_cast(propertyItem->value); - const std::uint32_t dwNumerator = *pValues; - const std::uint32_t dwDenominator = *(pValues + 1); - if (dwDenominator != 0) - { - if constexpr (std::is_same_v) - { - field = static_cast(dwNumerator) / static_cast(dwDenominator); - bResult = true; - } - } - } - else if (propertyItem->type == PropertyTagTypeShort) - { - if constexpr (std::is_same_v) - { - const std::uint16_t* pValue = static_cast(propertyItem->value); - field = static_cast(*pValue); - bResult = true; - } - } - else if (propertyItem->type == PropertyTagTypeASCII) - { - if constexpr (std::is_same_v) - { - field = static_cast(propertyItem->value); - bResult = true; - } - } - } - } - }; - - if (pBitmap != nullptr) - { - getExifItem(PropertyTagExifExposureTime, PropertyTagTypeRational, BitmapInfo.m_fExposure); - getExifItem(PropertyTagExifFNumber, PropertyTagTypeRational, BitmapInfo.m_fAperture); - getExifItem(PropertyTagExifISOSpeed, PropertyTagTypeShort, BitmapInfo.m_lISOSpeed); - - getExifItem(PropertyTagEquipModel, PropertyTagTypeASCII, BitmapInfo.m_strModel); - BitmapInfo.m_strModel.TrimRight(); - BitmapInfo.m_strModel.TrimLeft(); - - CString strDateTime; - getExifItem(PropertyTagDateTime, PropertyTagTypeASCII, strDateTime); - // Parse the string : YYYY/MM/DD hh:mm:ss - // 0123456789012345678 - BitmapInfo.m_DateTime.wYear = _ttol(strDateTime.Left(4)); - BitmapInfo.m_DateTime.wMonth = _ttol(strDateTime.Mid(5, 2)); - BitmapInfo.m_DateTime.wDay = _ttol(strDateTime.Mid(8, 2)); - BitmapInfo.m_DateTime.wHour = _ttol(strDateTime.Mid(11, 2)); - BitmapInfo.m_DateTime.wMinute = _ttol(strDateTime.Mid(14, 2)); - BitmapInfo.m_DateTime.wSecond = _ttol(strDateTime.Mid(17, 2)); - - //UINT dwPropertySize = pBitmap->GetPropertyItemSize(PropertyTagExifExposureTime); - //if (dwPropertySize != 0) - //{ - // auto buffer = std::make_unique(dwPropertySize); - // // PropertyTagTypeRational - // Gdiplus::PropertyItem* const propertyItem = reinterpret_cast(buffer.get()); - - // if (pBitmap->GetPropertyItem(PropertyTagExifExposureTime, dwPropertySize, propertyItem) == Ok) - // { - // if(propertyItem->type == PropertyTagTypeRational) - // { - // std::uint32_t* pValues = static_cast(propertyItem->value); - // std::uint32_t dwNumerator, dwDenominator; - - // dwNumerator = *pValues; - // dwDenominator = *(pValues + 1); - - // if (dwDenominator != 0) - // { - // BitmapInfo.m_fExposure = static_cast(dwNumerator) / static_cast(dwDenominator); - // bResult = true; - // }; - // }; - // }; - //}; - - //dwPropertySize = pBitmap->GetPropertyItemSize(PropertyTagExifFNumber); - //if (dwPropertySize) - //{ - // // PropertyTagTypeRational - // PropertyItem* propertyItem = (PropertyItem*)malloc(dwPropertySize); - - // if (pBitmap->GetPropertyItem(PropertyTagExifFNumber, dwPropertySize, propertyItem) == Ok) - // { - // if (propertyItem->type == PropertyTagTypeRational) - // { - // UINT * pValues = (UINT*)propertyItem->value; - // UINT dwNumerator, - // dwDenominator; - - // dwNumerator = *pValues; - // pValues++; - // dwDenominator = *pValues; - - // if (dwDenominator) - // { - // BitmapInfo.m_fAperture = (double)dwNumerator / (double)dwDenominator; - // bResult = true; - // }; - // }; - // }; - - // free(propertyItem); - //}; - - //dwPropertySize = pBitmap->GetPropertyItemSize(PropertyTagExifISOSpeed); - //if (dwPropertySize) - //{ - // // PropertyTagTypeShort - // PropertyItem* propertyItem = (PropertyItem*)malloc(dwPropertySize); - - // if (pBitmap->GetPropertyItem(PropertyTagExifISOSpeed, dwPropertySize, propertyItem) == Ok) - // { - // if(propertyItem->type == PropertyTagTypeShort) - // { - // BitmapInfo.m_lISOSpeed = *((WORD*)propertyItem->value); - // bResult = true; - // }; - // }; - - // free(propertyItem); - //}; - - //dwPropertySize = pBitmap->GetPropertyItemSize(PropertyTagEquipModel); - //if (dwPropertySize) - //{ - // // PropertyTagTypeASCII - // PropertyItem* propertyItem = (PropertyItem*)malloc(dwPropertySize); - // if (pBitmap->GetPropertyItem(PropertyTagEquipModel, dwPropertySize, propertyItem) == Ok) - // { - // if(propertyItem->type == PropertyTagTypeASCII) - // { - // BitmapInfo.m_strModel = (char*)propertyItem->value; - // BitmapInfo.m_strModel.TrimRight(); - // BitmapInfo.m_strModel.TrimLeft(); - // bResult = true; - // }; - // }; - - // free(propertyItem); - //}; - - //dwPropertySize = pBitmap->GetPropertyItemSize(PropertyTagDateTime); - //if (dwPropertySize) - //{ - // // PropertyTagTypeASCII - // PropertyItem* propertyItem = (PropertyItem*)malloc(dwPropertySize); - // if (pBitmap->GetPropertyItem(PropertyTagDateTime, dwPropertySize, propertyItem) == Ok) - // { - // if(propertyItem->type == PropertyTagTypeASCII) - // { - // CString strDateTime = (char*)propertyItem->value; - - // // Parse the string : YYYY/MM/DD hh:mm:ss - // // 0123456789012345678 - // BitmapInfo.m_DateTime.wYear = _ttol(strDateTime.Left(4)); - // BitmapInfo.m_DateTime.wMonth = _ttol(strDateTime.Mid(5, 2)); - // BitmapInfo.m_DateTime.wDay = _ttol(strDateTime.Mid(8, 2)); - // BitmapInfo.m_DateTime.wHour = _ttol(strDateTime.Mid(11, 2)); - // BitmapInfo.m_DateTime.wMinute= _ttol(strDateTime.Mid(14, 2)); - // BitmapInfo.m_DateTime.wSecond= _ttol(strDateTime.Mid(17, 2)); - - // bResult = true; - // }; - // }; - - // free(propertyItem); - //}; - - }; - - return bResult; -}; - -bool RetrieveEXIFInfo(LPCTSTR szFileName, CBitmapInfo& BitmapInfo) -{ - ZFUNCTRACE_RUNTIME(); - auto pBitmap = std::make_unique(CComBSTR(szFileName)); - return RetrieveEXIFInfo(pBitmap.get(), BitmapInfo); -}; bool IsOtherPicture(LPCTSTR szFileName, CBitmapInfo& BitmapInfo) @@ -749,7 +435,7 @@ bool IsOtherPicture(LPCTSTR szFileName, CBitmapInfo& BitmapInfo) if (bResult) { - BitmapInfo.m_strFileName = szFileName; + BitmapInfo.m_strFileName = QString::fromStdWString(szFileName); BitmapInfo.m_CFAType = CFATYPE_NONE; BitmapInfo.m_lWidth = pBitmap->GetWidth(); BitmapInfo.m_lHeight = pBitmap->GetHeight(); @@ -1147,9 +833,6 @@ bool ApplyGammaTransformation(C32BitsBitmap* pOutBitmap, CMemoryBitmap* pInBitma }; /* ------------------------------------------------------------------- */ - -#endif // DSSFILEDECODING - /* ------------------------------------------------------------------- */ #pragma warning( push ) @@ -1185,7 +868,9 @@ namespace { size_t operator()(const CBitmapInfo& other) const { const auto& str = other.m_strFileName; - return fnv1a_hash(reinterpret_cast(static_cast(str)), str.GetLength() * sizeof(CString::XCHAR)); + const QByteArray data = str.toUtf8(); + const void* pRawData = data.constData(); + return fnv1a_hash(reinterpret_cast(pRawData), data.length()); } }; @@ -1204,10 +889,6 @@ bool GetPictureInfo(LPCTSTR szFileName, CBitmapInfo& BitmapInfo) ZFUNCTRACE_RUNTIME(); bool bResult = false; -#if DSSFILEDECODING==0 - if (IsPCLPicture(szFileName, BitmapInfo)) - bResult = true; -#else // First try to find the info in the cache if (!g_sBitmapInfoCache.empty()) { @@ -1281,8 +962,9 @@ bool GetPictureInfo(LPCTSTR szFileName, CBitmapInfo& BitmapInfo) GetDateFormat(LOCALE_USER_DEFAULT, 0, &BitmapInfo.m_DateTime, nullptr, szDate, sizeof(szDate)/sizeof(TCHAR)); GetTimeFormat(LOCALE_USER_DEFAULT, 0, &BitmapInfo.m_DateTime, nullptr, szTime, sizeof(szTime)/sizeof(TCHAR)); - - BitmapInfo.m_strDateTime.Format(_T("%s %s"), szDate, szTime); + CString strDateTime; + strDateTime.Format(_T("%s %s"), szDate, szTime); + BitmapInfo.m_strDateTime = QString::fromWCharArray(strDateTime.GetString()); std::shared_lock readLock(bitmapInfoMutex); if (g_sBitmapInfoCache.empty()) @@ -1290,8 +972,6 @@ bool GetPictureInfo(LPCTSTR szFileName, CBitmapInfo& BitmapInfo) g_sBitmapInfoCache.insert(BitmapInfo); } } -#endif - return bResult; } @@ -1329,10 +1009,6 @@ bool FetchPicture(const fs::path filePath, std::shared_ptr& rpBit return false; } -#if DSSFILEDECODING==0 - if (IsPCLPicture(szFileName, BitmapInfo)) - bResult = LoadPCLPicture(szFileName, &pBitmap, pProgress); -#else do // do { ... } while (false); to be able to leave with break; { CBitmapInfo BitmapInfo; @@ -1378,74 +1054,9 @@ bool FetchPicture(const fs::path filePath, std::shared_ptr& rpBit bResult = LoadOtherPicture(szFileName, rpBitmap, pProgress); } while (false); - -#endif - return bResult; } - -std::shared_ptr CreateBitmap(const CBitmapCharacteristics& bc) -{ - ZFUNCTRACE_RUNTIME(); - - if (bc.m_lNrChannels == 1) - { - if (bc.m_lBitsPerPixel == 8) - { - ZTRACE_RUNTIME("Creating 8 Gray bit memory bitmap"); - return std::make_shared(); - } - else if (bc.m_lBitsPerPixel == 16) - { - ZTRACE_RUNTIME("Creating 16 Gray bit memory bitmap"); - return std::make_shared(); - } - else if (bc.m_lBitsPerPixel == 32) - { - if (bc.m_bFloat) - { - ZTRACE_RUNTIME("Creating 32 float Gray bit memory bitmap"); - return std::make_shared(); - } - else - { - ZTRACE_RUNTIME("Creating 32 Gray bit memory bitmap"); - return std::make_shared(); - } - } - } - else if (bc.m_lNrChannels == 3) - { - if (bc.m_lBitsPerPixel == 8) - { - ZTRACE_RUNTIME("Creating 8 RGB bit memory bitmap"); - return std::make_shared(); - } - else if (bc.m_lBitsPerPixel == 16) - { - ZTRACE_RUNTIME("Creating 16 RGB bit memory bitmap"); - return std::make_shared(); - } - else if (bc.m_lBitsPerPixel == 32) - { - if (bc.m_bFloat) - { - ZTRACE_RUNTIME("Creating 32 float RGB bit memory bitmap"); - return std::make_shared(); - } - else - { - ZTRACE_RUNTIME("Creating 32 RGB bit memory bitmap"); - return std::make_shared(); - } - } - } - - return std::shared_ptr{}; -} - - class CSubtractTask { private : @@ -1717,20 +1328,7 @@ bool Add(std::shared_ptr pTarget, std::shared_ptrIsCFA()) - { - if (CCFABitmapInfo* pCFABitmapInfo = dynamic_cast(pBitmap)) - { - Result = pCFABitmapInfo->GetCFAType(); - } - } - return Result; -} std::shared_ptr GetFilteredImage(const CMemoryBitmap* pInBitmap, const int lFilterSize, ProgressBase* pProgress) @@ -1742,3 +1340,375 @@ std::shared_ptr GetFilteredImage(const CMemoryBitmap* pInBitmap, else return pInBitmap->GetMedianFilterEngine()->GetFilteredImage(lFilterSize, pProgress); } + +////////////////////////////////////////////////////////////////////////// +// Moved from headers + +void FormatFromMethod(QString& strText, MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations) +{ + strText = ""; + switch (Method) + { + case MBP_FASTAVERAGE: + case MBP_AVERAGE: + strText = QCoreApplication::translate("BitmapExt", "Average", "IDS_RECAP_AVERAGE"); + break; + case MBP_MEDIAN: + strText = QCoreApplication::translate("BitmapExt", "Median", "IDS_RECAP_MEDIAN"); + break; + case MBP_MAXIMUM: + strText = QCoreApplication::translate("BitmapExt", "Maximum", "IDS_RECAP_MAXIMUM"); + break; + case MBP_SIGMACLIP: + strText = QCoreApplication::translate("BitmapExt", "Kappa-Sigma (Kappa = %1, Iterations = %2)", "IDS_RECAP_KAPPASIGMA").arg(fKappa, 0, 'f', 2).arg(lNrIterations); + break; + case MBP_AUTOADAPTIVE: + strText = QCoreApplication::translate("BitmapExt", "Auto Adaptive Weighted Average (Iterations = %1)", "IDS_RECAP_AUTOADAPTIVE").arg(lNrIterations); + break; + case MBP_ENTROPYAVERAGE: + strText = QCoreApplication::translate("BitmapExt", "Entropy Weighted Average", "IDS_RECAP_ENTROPYAVERAGE"); + break; + case MBP_MEDIANSIGMACLIP: + strText = QCoreApplication::translate("BitmapExt", "Median Kappa-Sigma (Kappa = %1, Iterations = %2)", "IDS_RECAP_MEDIANSIGMACLIP").arg(fKappa, 0, 'f', 2).arg(lNrIterations); + }; +} + +void FormatMethod(QString& strText, MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations) +{ + strText = ""; + switch (Method) + { + case MBP_FASTAVERAGE: + case MBP_AVERAGE: + strText = QCoreApplication::translate("StackRecap", "Average", "IDS_RECAP_AVERAGE"); + break; + case MBP_MEDIAN: + strText = QCoreApplication::translate("StackRecap", "Median", "IDS_RECAP_MEDIAN"); + break; + case MBP_MAXIMUM: + strText = QCoreApplication::translate("StackRecap", "Maximum", "IDS_RECAP_MAXIMUM"); + break; + case MBP_SIGMACLIP: + strText = QCoreApplication::translate("StackRecap", "Kappa-Sigma (Kappa = %1, Iterations = %2)", + "IDS_RECAP_KAPPASIGMA") + .arg(fKappa, 0, 'f', 2) + .arg(lNrIterations); + break; + case MBP_AUTOADAPTIVE: + strText = QCoreApplication::translate("StackRecap", + "Auto Adaptive Weighted Average (Iterations = %1)", + "IDS_RECAP_AUTOADAPTIVE") + .arg(lNrIterations); + break; + case MBP_ENTROPYAVERAGE: + strText = QCoreApplication::translate("StackRecap", + "Entropy Weighted Average", + "IDS_RECAP_ENTROPYAVERAGE"); + break; + case MBP_MEDIANSIGMACLIP: + strText = QCoreApplication::translate("StackRecap", + "Median Kappa-Sigma (Kappa = %1, Iterations = %2)", + "IDS_RECAP_MEDIANSIGMACLIP") + .arg(fKappa, 0, 'f', 2) + .arg(lNrIterations); + }; + return; +} + +void CYMGToRGB2(double fCyan, double fYellow, double fMagenta, double fGreen2, double& fRed, double& fGreen, double& fBlue) +{ + double fR, fG, fB; + + fR = (fMagenta + fYellow - fCyan) / 2.0; + fG = (fYellow + fCyan - fMagenta) / 2.0; + fB = (fMagenta + fCyan - fYellow) / 2.0; + + fRed = 2.088034662 * fR + -3.663103328 * fG + 3.069027325 * fB; + fGreen = -0.28607719 * fR + 1.706598409 * fG + 0.24881043 * fB; + fBlue = -0.180853396 * fR + -7.714219397 * fG + 9.438903145 * fB; + + fRed = max(0.0, min(255.0, fRed)); + fGreen = max(0.0, min(255.0, fGreen)); + fBlue = max(0.0, min(255.0, fBlue)); +} + + + +bool CompareBitmapInfoDateTime(const CBitmapInfo& bi1, const CBitmapInfo& bi2) +{ + if (bi1.m_DateTime.wYear < bi2.m_DateTime.wYear) + return true; + else if (bi1.m_DateTime.wYear > bi2.m_DateTime.wYear) + return false; + else if (bi1.m_DateTime.wMonth < bi2.m_DateTime.wMonth) + return true; + else if (bi1.m_DateTime.wMonth > bi2.m_DateTime.wMonth) + return false; + else if (bi1.m_DateTime.wDay < bi2.m_DateTime.wDay) + return true; + else if (bi1.m_DateTime.wDay > bi2.m_DateTime.wDay) + return false; + else if (bi1.m_DateTime.wHour < bi2.m_DateTime.wHour) + return true; + else if (bi1.m_DateTime.wHour > bi2.m_DateTime.wHour) + return false; + else if (bi1.m_DateTime.wMinute < bi2.m_DateTime.wMinute) + return true; + else if (bi1.m_DateTime.wMinute > bi2.m_DateTime.wMinute) + return false; + else if (bi1.m_DateTime.wSecond < bi2.m_DateTime.wSecond) + return true; + else if (bi1.m_DateTime.wSecond > bi2.m_DateTime.wSecond) + return false; + else + return (bi1.m_DateTime.wMilliseconds < bi2.m_DateTime.wMilliseconds); +} + + + +////////////////////////////////////////////////////////////////////////// +C32BitsBitmap::C32BitsBitmap() +{ + m_hBitmap = nullptr; + m_lpBits = nullptr; + m_lWidth = 0; + m_lHeight = 0; + m_pLine = nullptr; + m_dwByteWidth = 0; +} +C32BitsBitmap::~C32BitsBitmap() +{ + Free(); +} +void C32BitsBitmap::InitInternals() +{ + if (m_pLine) + free(m_pLine); + + m_pLine = static_cast(malloc(m_lHeight * sizeof(pByte))); + if (nullptr == m_pLine) + { + ZOutOfMemory e("Could not allocate storage for scanline pointers"); + ZTHROW(e); + } + + m_dwByteWidth = (((m_lWidth * 32 + 31) & ~31) >> 3); + int y = m_lHeight - 1; + + for (int i = 0; y >= 0; y--, i++) + { + m_pLine[i] = static_cast(m_lpBits) + y * m_dwByteWidth; + } +} +void C32BitsBitmap::Init(int lWidth, int lHeight) +{ + Create(lWidth, lHeight); +} +HBITMAP C32BitsBitmap::Create(int lWidth, int lHeight) +{ + Free(); + + HBITMAP hBitmap; + BITMAPINFO bmpInfo; + void* pBits; + + memset(&bmpInfo, 0, sizeof(bmpInfo)); + bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader); + bmpInfo.bmiHeader.biWidth = lWidth; + bmpInfo.bmiHeader.biHeight = lHeight; + bmpInfo.bmiHeader.biPlanes = 1;; + bmpInfo.bmiHeader.biBitCount = 32; + bmpInfo.bmiHeader.biCompression = BI_RGB; + bmpInfo.bmiHeader.biSizeImage = 0; + bmpInfo.bmiHeader.biXPelsPerMeter = (int)(96 * 100.0 / 2.54); + bmpInfo.bmiHeader.biYPelsPerMeter = (int)(96 * 100.0 / 2.54); + bmpInfo.bmiHeader.biClrUsed = 0; + bmpInfo.bmiHeader.biClrImportant = 0; + + HDC hDC; + hDC = GetDC(nullptr); + hBitmap = CreateDIBSection(hDC, &bmpInfo, 0, &pBits, nullptr, 0); + ReleaseDC(nullptr, hDC); + + if (hBitmap) + { + m_hBitmap = hBitmap; + m_lpBits = pBits; + m_lWidth = lWidth; + m_lHeight = lHeight; + InitInternals(); + }; + + return hBitmap; +} +void C32BitsBitmap::Free() +{ + if (m_hBitmap) + { + DeleteObject(m_hBitmap); + }; + m_hBitmap = nullptr; + m_lpBits = nullptr; + if (m_pLine) + free(m_pLine); + m_pLine = nullptr; +} +HBITMAP C32BitsBitmap::Detach() +{ + HBITMAP hResult = m_hBitmap; + + m_hBitmap = nullptr; + Free(); + + return hResult; +}; + +COLORREF C32BitsBitmap::GetPixel(int x, int y) +{ + COLORREF crColor = RGB(0, 0, 0); + + if ((x >= 0) && (x < m_lWidth) && (y >= 0) && (y < m_lHeight)) + { + const pByte pPixel = m_pLine[y] + ((x * 32) >> 3); + const auto dwPixel = *reinterpret_cast(pPixel); + const RGBQUAD rgbq = *reinterpret_cast(&dwPixel); + + crColor = RGB(rgbq.rgbRed, rgbq.rgbGreen, rgbq.rgbBlue); + }; + + return crColor; +} +pByte C32BitsBitmap::GetPixelBase(int x, int y) +{ + return m_pLine[y] + x * 4; +} +void C32BitsBitmap::SetPixel(int x, int y, COLORREF crColor) +{ + if ((x >= 0) && (x < m_lWidth) && (y >= 0) && (y < m_lHeight)) + { + pByte pPixel = m_pLine[y] + ((x * 32) >> 3); + RGBQUAD rgbq; + + rgbq.rgbRed = GetRValue(crColor); + rgbq.rgbGreen = GetGValue(crColor); + rgbq.rgbBlue = GetBValue(crColor); + rgbq.rgbReserved = 0; + + *reinterpret_cast(pPixel) = *reinterpret_cast(&rgbq); + }; +} + +////////////////////////////////////////////////////////////////////////// +void CAllDepthBitmap::Clear() +{ + m_pBitmap.reset(); + m_pWndBitmap.reset(); + m_Image.reset(); +} + +////////////////////////////////////////////////////////////////////////// +CBitmapInfo::CBitmapInfo() +{ + Init(); +} + +CBitmapInfo::CBitmapInfo(const CBitmapInfo& bi) +{ + CopyFrom(bi); +} + +CBitmapInfo::CBitmapInfo(LPCTSTR szFileName) +{ + Init(); + m_strFileName = QString::fromStdWString(szFileName); +} + +void CBitmapInfo::CopyFrom(const CBitmapInfo& bi) +{ + m_strFileName = bi.m_strFileName; + m_strFileType = bi.m_strFileType; + m_strModel = bi.m_strModel; + m_lISOSpeed = bi.m_lISOSpeed; + m_lGain = bi.m_lGain; + m_fExposure = bi.m_fExposure; + m_fAperture = bi.m_fAperture; + m_lWidth = bi.m_lWidth; + m_lHeight = bi.m_lHeight; + m_lBitPerChannel = bi.m_lBitPerChannel; + m_lNrChannels = bi.m_lNrChannels; + m_bCanLoad = bi.m_bCanLoad; + m_bFloat = bi.m_bFloat; + m_CFAType = bi.m_CFAType; + m_bMaster = bi.m_bMaster; + m_bFITS16bit = bi.m_bFITS16bit; + m_strDateTime = bi.m_strDateTime; + m_DateTime = bi.m_DateTime; + m_InfoTime = bi.m_InfoTime; + m_ExtraInfo = bi.m_ExtraInfo; + m_xBayerOffset = bi.m_xBayerOffset; + m_yBayerOffset = bi.m_yBayerOffset; + m_filterName = bi.m_filterName; +} + +void CBitmapInfo::Init() +{ + m_lWidth = 0; + m_lHeight = 0; + m_lBitPerChannel = 0; + m_lNrChannels = 0; + m_bCanLoad = false; + m_CFAType = CFATYPE_NONE; + m_bMaster = false; + m_bFloat = false; + m_lISOSpeed = 0; + m_lGain = -1; + m_fExposure = 0.0; + m_fAperture = 0.0; + m_bFITS16bit = false; + m_DateTime = { 0 }; + m_InfoTime = { 0 }; + m_xBayerOffset = 0; + m_yBayerOffset = 0; +} + +CBitmapInfo& CBitmapInfo::operator=(const CBitmapInfo& bi) +{ + CopyFrom(bi); + return (*this); +} + +bool CBitmapInfo::operator<(const CBitmapInfo& other) const +{ + return (m_strFileName.compare(other.m_strFileName, Qt::CaseInsensitive) < 0); +} + +bool CBitmapInfo::operator==(const CBitmapInfo& other) const +{ + return this->m_strFileName.compare(other.m_strFileName, Qt::CaseInsensitive) == 0; +} +bool CBitmapInfo::CanLoad() const +{ + return m_bCanLoad; +} + +bool CBitmapInfo::IsCFA() +{ + return (m_CFAType != CFATYPE_NONE); +}; + +bool CBitmapInfo::IsMaster() +{ + return m_bMaster; +}; + +void CBitmapInfo::GetDescription(QString& strDescription) +{ + strDescription = m_strFileType; + if (m_strModel.length() > 0) + strDescription = m_strFileType + " " + m_strModel; +}; + +bool CBitmapInfo::IsInitialized() +{ + return m_lWidth && m_lHeight; +}; \ No newline at end of file diff --git a/DeepSkyStacker/BitmapExt.h b/DeepSkyStacker/BitmapExt.h index e76d3519c..d2bedb5dd 100644 --- a/DeepSkyStacker/BitmapExt.h +++ b/DeepSkyStacker/BitmapExt.h @@ -1,801 +1,112 @@ #ifndef _BITMAPEXT_H__ #define _BITMAPEXT_H__ -#include -#include +#include "BitmapConstants.h" +#include "DSSCommon.h" +#include "BitmapExtraInfo.h" +#include "ColorRef.h" +#include "cfa.h" +#include "BitmapInfo.h" -#include "Multitask.h" -#include -#include -#include "BitmapBase.h" - -#ifndef DSSFILEDECODING -#define DSSFILEDECODING 1 -#endif - -#define ALTERNATEHOMOGENEIZATION - -/* ------------------------------------------------------------------- */ - -#if DSSFILEDECODING==1 -bool IsFITSRawBayer(); // From FITSUtil.h -bool IsFITSSuperPixels(); // From FITSUtil.h -#else -inline bool IsFITSRawBayer() { return false; }; // From FITSUtil.h -inline bool IsFITSSuperPixels() { return false; }; // From FITSUtil.h -#endif // !DSSFILEDECODING - - -/* ------------------------------------------------------------------- */ +// Don't want these!!! +#include namespace fs = std::filesystem; -class DSS::ProgressBase; - -/* ------------------------------------------------------------------- */ - -inline double ToRGB1(float rm1, float rm2, float rh) -{ - if (rh > 360.0f) - rh -= 360.0f; - else if (rh < 0.0f) - rh += 360.0f; - - if (rh < 60.0f) - rm1 = rm1 + (rm2 - rm1) * rh / 60.0f; - else if (rh < 180.0f) - rm1 = rm2; - else if (rh < 240.0f) - rm1 = rm1 + (rm2 - rm1) * (240.0f - rh) / 60.0f; - - return (rm1 * 255.0); -} - -inline void ToRGB(double H, double S, double L, double & Red, double & Green, double & Blue) -{ - if (S == 0.0) - { - Red = Green = Blue = L * 255.0; - } - else - { - double rm1, rm2; - - if (L <= 0.5f) - rm2 = (double)(L + L * S); - else - rm2 = (double)(L + S - L * S); - rm1 = (double)(2.0f * L - rm2); - - Red = ToRGB1(rm1, rm2, (double)(H + 120.0f)); - Green = ToRGB1(rm1, rm2, (double)H); - Blue = ToRGB1(rm1, rm2, (double)(H - 120.0f)); - } -}; - -/* Return the HSL luminance value. */ -inline double GetLuminance(const COLORREF crColor) -{ - constexpr double scalingFactor = 1.0 / 256.0; - - const unsigned red = GetRValue(crColor); - const unsigned green = GetGValue(crColor); - const unsigned blue = GetBValue(crColor); - - const unsigned minval = std::min(red, std::min(green, blue)); - const unsigned maxval = std::max(red, std::max(green, blue)); - const unsigned msum = maxval + minval; - - return static_cast(msum) * (0.5 * scalingFactor); -}; - -/* Return the HSL luminance value. */ -inline double GetLuminance(const COLORREF16 & crColor) -{ - constexpr double scalingFactor = 1.0 / 256.0; - - const unsigned minval = std::min(crColor.red, std::min(crColor.green, crColor.blue)); - const unsigned maxval = std::max(crColor.red, std::max(crColor.green, crColor.blue)); - const unsigned msum = maxval + minval; - - return static_cast(msum) * (0.5 * scalingFactor * scalingFactor); // (((double)msum / 256.0) / 510.0); -}; - -/* ------------------------------------------------------------------- */ - -inline double ClampPixel(const double fValue) -{ - constexpr double maxVal = 255.0 * 256.0; - if (fValue < 0.0) - return 0.0; - if (fValue > maxVal) - return maxVal; - return fValue; -} - -/* ------------------------------------------------------------------- */ - +namespace DSS { class ProgressBase; } class CMemoryBitmap; +class CBitmapCharacteristics; /* ------------------------------------------------------------------- */ -inline void FormatFromMethod(QString & strText, MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations) -{ - strText = ""; - switch (Method) - { - case MBP_FASTAVERAGE : - case MBP_AVERAGE : - strText = QCoreApplication::translate("BitmapExt", "Average", "IDS_RECAP_AVERAGE"); - break; - case MBP_MEDIAN : - strText = QCoreApplication::translate("BitmapExt", "Median", "IDS_RECAP_MEDIAN"); - break; - case MBP_MAXIMUM : - strText = QCoreApplication::translate("BitmapExt", "Maximum", "IDS_RECAP_MAXIMUM"); - break; - case MBP_SIGMACLIP : - strText = QCoreApplication::translate("BitmapExt", "Kappa-Sigma (Kappa = %1, Iterations = %2)", "IDS_RECAP_KAPPASIGMA").arg(fKappa, 0, 'f', 2).arg(lNrIterations); - break; - case MBP_AUTOADAPTIVE : - strText = QCoreApplication::translate("BitmapExt", "Auto Adaptive Weighted Average (Iterations = %1)", "IDS_RECAP_AUTOADAPTIVE").arg(lNrIterations); - break; - case MBP_ENTROPYAVERAGE : - strText = QCoreApplication::translate("BitmapExt", "Entropy Weighted Average", "IDS_RECAP_ENTROPYAVERAGE"); - break; - case MBP_MEDIANSIGMACLIP : - strText = QCoreApplication::translate("BitmapExt", "Median Kappa-Sigma (Kappa = %1, Iterations = %2)", "IDS_RECAP_MEDIANSIGMACLIP").arg(fKappa, 0, 'f', 2).arg(lNrIterations); - }; -}; +void FormatFromMethod(QString& strText, MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations); +void FormatMethod(QString& strText, MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations); +bool Subtract(std::shared_ptr pTarget, std::shared_ptr pSource, DSS::ProgressBase* pProgress = nullptr, double fRedFactor = 1.0, double fGreenFactor = 1.0, double fBlueFactor = 1.0); +bool Add(std::shared_ptr pTarget, std::shared_ptr pSource, DSS::ProgressBase* pProgress = nullptr); +bool ShiftAndSubtract(std::shared_ptr pTarget, std::shared_ptr pSource, DSS::ProgressBase* pProgress = nullptr, double fXShift = 0, double fYShift = 0); -inline void FormatFromMethod(CString& strText, MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations) -{ - strText.Empty(); - switch (Method) - { - case MBP_FASTAVERAGE: - case MBP_AVERAGE: - strText.Format(IDS_RECAP_AVERAGE); - break; - case MBP_MEDIAN: - strText.Format(IDS_RECAP_MEDIAN); - break; - case MBP_MAXIMUM: - strText.Format(IDS_RECAP_MAXIMUM); - break; - case MBP_SIGMACLIP: - strText.Format(IDS_RECAP_KAPPASIGMA, fKappa, lNrIterations); - break; - case MBP_AUTOADAPTIVE: - strText.Format(IDS_RECAP_AUTOADAPTIVE, lNrIterations); - break; - case MBP_ENTROPYAVERAGE: - strText.Format(IDS_RECAP_ENTROPYAVERAGE); - break; - case MBP_MEDIANSIGMACLIP: - strText.Format(IDS_RECAP_MEDIANSIGMACLIP, fKappa, lNrIterations); - }; -}; +bool CompareBitmapInfoDateTime(const CBitmapInfo& bi1, const CBitmapInfo& bi2); +bool FetchPicture(const fs::path filePath, std::shared_ptr& rpBitmap, DSS::ProgressBase* const pProgress); +bool GetPictureInfo(LPCTSTR szFileName, CBitmapInfo& BitmapInfo); +std::shared_ptr GetFilteredImage(const CMemoryBitmap* pInBitmap, const int lFilterSize, DSS::ProgressBase* pProgress = nullptr); -inline QString formatMethod(MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations) -{ - QString strText; +////////////////////////////////////////////////////////////////////////// - switch (Method) - { - case MBP_FASTAVERAGE: - case MBP_AVERAGE: - strText = QCoreApplication::translate("StackRecap", "Average", "IDS_RECAP_AVERAGE"); - break; - case MBP_MEDIAN: - strText = QCoreApplication::translate("StackRecap", "Median", "IDS_RECAP_MEDIAN"); - break; - case MBP_MAXIMUM: - strText = QCoreApplication::translate("StackRecap", "Maximum", "IDS_RECAP_MAXIMUM"); - break; - case MBP_SIGMACLIP: - strText = QCoreApplication::translate("StackRecap", "Kappa-Sigma (Kappa = %1, Iterations = %2)", - "IDS_RECAP_KAPPASIGMA") - .arg(fKappa, 0, 'f', 2) - .arg(lNrIterations); - break; - case MBP_AUTOADAPTIVE: - strText = QCoreApplication::translate("StackRecap", - "Auto Adaptive Weighted Average (Iterations = %1)", - "IDS_RECAP_AUTOADAPTIVE") - .arg(lNrIterations); - break; - case MBP_ENTROPYAVERAGE: - strText = QCoreApplication::translate("StackRecap", - "Entropy Weighted Average", - "IDS_RECAP_ENTROPYAVERAGE"); - break; - case MBP_MEDIANSIGMACLIP: - strText = QCoreApplication::translate("StackRecap", - "Median Kappa-Sigma (Kappa = %1, Iterations = %2)", - "IDS_RECAP_MEDIANSIGMACLIP") - .arg(fKappa, 0, 'f', 2) - .arg(lNrIterations); - }; - return strText; -}; - -/* ------------------------------------------------------------------- */ - -bool Subtract(std::shared_ptr pTarget, std::shared_ptr pSource, ProgressBase* pProgress = nullptr, double fRedFactor = 1.0, double fGreenFactor = 1.0, double fBlueFactor = 1.0); -bool Add(std::shared_ptr pTarget, std::shared_ptr pSource, ProgressBase* pProgress = nullptr); -bool ShiftAndSubtract(std::shared_ptr pTarget, std::shared_ptr pSource, ProgressBase* pProgress = nullptr, double fXShift = 0, double fYShift = 0); - -/* ------------------------------------------------------------------- */ - -inline void CYMGToRGB2(double fCyan, double fYellow, double fMagenta, double fGreen2, double & fRed, double & fGreen, double & fBlue) -{ - double fR, fG, fB; - - fR = (fMagenta+fYellow-fCyan)/2.0; - fG = (fYellow+fCyan-fMagenta)/2.0; - fB = (fMagenta+fCyan-fYellow)/2.0; - - fRed = 2.088034662 * fR + -3.663103328 * fG + 3.069027325 * fB; - fGreen = -0.28607719 * fR + 1.706598409 * fG + 0.24881043 * fB; - fBlue = -0.180853396 * fR + -7.714219397 * fG + 9.438903145 * fB; - - fRed = max(0.0, min (255.0, fRed)); - fGreen = max(0.0, min (255.0, fGreen)); - fBlue = max(0.0, min (255.0, fBlue)); -}; - -inline void CYMGToRGB3(double fCyan, double fYellow, double fMagenta, double fGreen2, double & fRed, double & fGreen, double & fBlue) -{ - fRed = fGreen = fBlue = 0; - // Basic formulae - // M = R + B - // Y = R + G - // C = B + G - - // RGB from CYM - // R = (M+Y-C)/2 - // G = (Y+C-M)/2 - // B = (M+C-Y)/2 - fRed = max(0.0, fMagenta+fYellow-fCyan)/2.0; - fGreen = max(0.0, fYellow+fCyan-fMagenta)/2.0; - fBlue = max(0.0 ,fMagenta+fCyan-fYellow)/2.0; - -/* if (fGreen2) - { - fRed *= fGreen2/fGreen; - fBlue *= fGreen2/fGreen; - fGreen = fGreen2; - }; - fRed = min(fRed, 255); - fBlue = min(fBlue, 255); - fGreen = min(fGreen, 255);*/ - - // RGB from CYG - // G = G - // R = Y - G - // B = C - G - fGreen += fGreen2; - fRed += max(0.0, fYellow-fGreen2); - fBlue += max(0.0, fCyan-fGreen2); - - // RGB from CMG - // G = G - // B = C - G - // R = M - B = M - C + G -// fGreen += fGreen2; - fBlue += max(0.0, fCyan-fGreen2); - fRed += max(0.0, fMagenta - fCyan + fGreen2); - - // RGB from YMG - // G = G - // R = Y - G - // B = M - R = M - Y + G -// fGreen += fGreen2; - fRed += max(0.0, fYellow - fGreen2); - fBlue += max(0.0, fMagenta - fYellow + fGreen2); - - // Average the results - fRed /= 4.0; - fBlue /= 4.0; - fGreen /= 2.0; - - fRed = max(0.0, fRed); - fBlue = max(0.0, fBlue); - fGreen = max(0.0, fGreen); -}; - -/* ------------------------------------------------------------------- */ - -#if DSSFILEDECODING==1 -class CWindowsBitmap -{ -private : - HBITMAP m_hBitmap; - -public : - CWindowsBitmap() : m_hBitmap{ nullptr } {} - - ~CWindowsBitmap() - { - if (m_hBitmap) - ::DeleteObject(m_hBitmap); - } - - HBITMAP GetHBitmap() - { - return m_hBitmap; - } - - void SetHBitmap(HBITMAP hBitmap) - { - if (m_hBitmap) - ::DeleteObject(m_hBitmap); - m_hBitmap = hBitmap; - } -}; - -/* ------------------------------------------------------------------- */ +bool IsFITSRawBayer(); // From FITSUtil.h +bool IsFITSSuperPixels(); // From FITSUtil.h +using pByte = std::uint8_t*; class C32BitsBitmap { private: - using pByte = std::uint8_t*; - HBITMAP m_hBitmap; - VOID* m_lpBits; + void* m_lpBits; int m_lWidth; int m_lHeight; pByte* m_pLine; std::uint32_t m_dwByteWidth; private: - void InitInternals() - { - if (m_pLine) - free(m_pLine); - - m_pLine = static_cast(malloc(m_lHeight * sizeof(pByte))); - if (nullptr == m_pLine) - { - ZOutOfMemory e("Could not allocate storage for scanline pointers"); - ZTHROW(e); - } - - m_dwByteWidth = (((m_lWidth * 32 + 31) & ~31) >> 3); - int y = m_lHeight - 1; - - for (int i = 0; y >= 0; y--, i++) - { - m_pLine[i] = static_cast(m_lpBits) + y * m_dwByteWidth; - } - }; + void InitInternals(); public: - C32BitsBitmap() - { - m_hBitmap = nullptr; - m_lpBits = nullptr; - m_lWidth = 0; - m_lHeight = 0; - m_pLine = nullptr; - m_dwByteWidth = 0; - }; - - virtual ~C32BitsBitmap() - { - Free(); - }; - - VOID* GetBits() - { - return m_lpBits; - }; - - virtual int Width() - { - return m_lWidth; - }; - - virtual int Height() - { - return m_lHeight; - }; - - int ByteWidth() - { - return m_dwByteWidth; - }; - - virtual void Init(int lWidth, int lHeight) - { - Create(lWidth, lHeight); - }; - - HBITMAP Create(int lWidth, int lHeight) - { - Free(); - - HBITMAP hBitmap; - BITMAPINFO bmpInfo; - VOID * pBits; - - memset(&bmpInfo, 0, sizeof(bmpInfo)); - bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader); - bmpInfo.bmiHeader.biWidth = lWidth; - bmpInfo.bmiHeader.biHeight= lHeight; - bmpInfo.bmiHeader.biPlanes= 1;; - bmpInfo.bmiHeader.biBitCount= 32; - bmpInfo.bmiHeader.biCompression= BI_RGB; - bmpInfo.bmiHeader.biSizeImage= 0; - bmpInfo.bmiHeader.biXPelsPerMeter = (int)(96*100.0/2.54); - bmpInfo.bmiHeader.biYPelsPerMeter = (int)(96*100.0/2.54); - bmpInfo.bmiHeader.biClrUsed = 0; - bmpInfo.bmiHeader.biClrImportant = 0; - - HDC hDC; - hDC = GetDC(nullptr); - hBitmap = CreateDIBSection(hDC, &bmpInfo, 0, &pBits, nullptr, 0); - ReleaseDC(nullptr, hDC); - - if (hBitmap) - { - m_hBitmap = hBitmap; - m_lpBits = pBits; - m_lWidth = lWidth; - m_lHeight = lHeight; - InitInternals(); - }; - - return hBitmap; - }; - - bool InitFrom( CMemoryBitmap* pBitmap); + C32BitsBitmap(); + virtual ~C32BitsBitmap(); + + virtual int Width() { return m_lWidth; } + virtual int Height() { return m_lHeight; } + virtual void Init(int lWidth, int lHeight); + + void* GetBits() { return m_lpBits; } + int ByteWidth() { return m_dwByteWidth; } + HBITMAP GetHBITMAP() { return m_hBitmap; } + HBITMAP Create(int lWidth, int lHeight); + bool InitFrom(CMemoryBitmap* pBitmap); bool CopyToClipboard(); - - bool IsEmpty() - { - return (m_hBitmap == nullptr); - }; - - HBITMAP GetHBITMAP() - { - return m_hBitmap; - }; - - void Free() - { - if (m_hBitmap) - { - DeleteObject(m_hBitmap); - }; - m_hBitmap = nullptr; - m_lpBits = nullptr; - if (m_pLine) - free(m_pLine); - m_pLine = nullptr; - }; - - HBITMAP Detach() - { - HBITMAP hResult = m_hBitmap; - - m_hBitmap = nullptr; - Free(); - - return hResult; - }; - - COLORREF GetPixel(int x, int y) - { - COLORREF crColor = RGB(0, 0, 0); - - if( (x >= 0) && (x < m_lWidth) && (y >= 0) && (y < m_lHeight)) - { - const pByte pPixel = m_pLine[y] + ((x * 32) >> 3); - const auto dwPixel = *reinterpret_cast(pPixel); - const RGBQUAD rgbq = *reinterpret_cast(&dwPixel); - - crColor = RGB(rgbq.rgbRed, rgbq.rgbGreen, rgbq.rgbBlue); - }; - - return crColor; - }; - - pByte GetPixelBase(int x, int y) - { - return m_pLine[y] + x * 4; - }; - - void SetPixel(int x, int y, COLORREF crColor) - { - if( (x >= 0) && (x < m_lWidth) && (y >=0) && (y < m_lHeight)) - { - pByte pPixel = m_pLine[y] + ((x * 32) >> 3); - RGBQUAD rgbq; - - rgbq.rgbRed = GetRValue(crColor); - rgbq.rgbGreen = GetGValue(crColor); - rgbq.rgbBlue = GetBValue(crColor); - rgbq.rgbReserved = 0; - - *reinterpret_cast(pPixel) = *reinterpret_cast(&rgbq); - }; - }; + bool IsEmpty() { return (m_hBitmap == nullptr); } + void Free(); + HBITMAP Detach(); + COLORREF GetPixel(int x, int y); + pByte GetPixelBase(int x, int y); + void SetPixel(int x, int y, COLORREF crColor); }; class CGammaTransformation { -public : +public: std::vector m_vTransformation; -public : +public: CGammaTransformation() {}; ~CGammaTransformation() {}; - void InitTransformation(double fBlackPoint, double fGrayPoint, double fWhitePoint); - void InitTransformation(double fGamma); - - bool IsInitialized() - { - return (m_vTransformation.size() == 65537); - }; + void InitTransformation(double fBlackPoint, double fGrayPoint, double fWhitePoint); + void InitTransformation(double fGamma); + bool IsInitialized() { return (m_vTransformation.size() == 65537); } }; -bool ApplyGammaTransformation(C32BitsBitmap * pOutBitmap, CMemoryBitmap * pInBitmap, CGammaTransformation & gammatrans); -bool ApplyGammaTransformation(QImage* pImage, CMemoryBitmap* pInBitmap, CGammaTransformation& gammatrans); -#endif // DSSFILEDECODING - -/* ------------------------------------------------------------------- */ - -#include "MedianFilterEngine.h" - -/* ------------------------------------------------------------------- */ - -class CBitmapInfo -{ -public: - CString m_strFileName; - CString m_strFileType; - CString m_strModel; - int m_lISOSpeed; - int m_lGain; - double m_fExposure; - double m_fAperture; - int m_lWidth; - int m_lHeight; - int m_lBitPerChannel; - int m_lNrChannels; - bool m_bCanLoad; - bool m_bFloat; - CFATYPE m_CFAType; - bool m_bMaster; - bool m_bFITS16bit; - CString m_strDateTime; - SYSTEMTIME m_DateTime; - SYSTEMTIME m_InfoTime; - CBitmapExtraInfo m_ExtraInfo; - int m_xBayerOffset; - int m_yBayerOffset; - QString m_filterName; - -private: - void CopyFrom(const CBitmapInfo & bi) - { - m_strFileName =bi.m_strFileName ; - m_strFileType =bi.m_strFileType ; - m_strModel =bi.m_strModel ; - m_lISOSpeed =bi.m_lISOSpeed ; - m_lGain =bi.m_lGain ; - m_fExposure =bi.m_fExposure ; - m_fAperture =bi.m_fAperture; - m_lWidth =bi.m_lWidth ; - m_lHeight =bi.m_lHeight ; - m_lBitPerChannel=bi.m_lBitPerChannel; - m_lNrChannels =bi.m_lNrChannels ; - m_bCanLoad =bi.m_bCanLoad ; - m_bFloat =bi.m_bFloat ; - m_CFAType =bi.m_CFAType ; - m_bMaster =bi.m_bMaster ; - m_bFITS16bit =bi.m_bFITS16bit ; - m_strDateTime =bi.m_strDateTime ; - m_DateTime =bi.m_DateTime ; - m_InfoTime =bi.m_InfoTime ; - m_ExtraInfo =bi.m_ExtraInfo ; - m_xBayerOffset =bi.m_xBayerOffset; - m_yBayerOffset =bi.m_yBayerOffset; - m_filterName =bi.m_filterName; - }; - - void Init() - { - m_lWidth = 0; - m_lHeight = 0; - m_lBitPerChannel = 0; - m_lNrChannels = 0; - m_bCanLoad = false; - m_CFAType = CFATYPE_NONE; - m_bMaster = false; - m_bFloat = false; - m_lISOSpeed = 0; - m_lGain = -1; - m_fExposure = 0.0; - m_fAperture = 0.0; - m_bFITS16bit = false; - m_DateTime = { 0 }; - m_InfoTime = { 0 }; - m_xBayerOffset = 0; - m_yBayerOffset = 0; - } - -public: - CBitmapInfo() - { - Init(); - }; - - CBitmapInfo(const CBitmapInfo & bi) - { - CopyFrom(bi); - }; - - CBitmapInfo(LPCTSTR szFileName) - { - Init(); - - m_strFileName = szFileName; - }; - - CBitmapInfo & operator = (const CBitmapInfo & bi) - { - CopyFrom(bi); - return (*this); - }; - - bool operator<(const CBitmapInfo& other) const - { - return (m_strFileName.CompareNoCase(other.m_strFileName) < 0); - }; - - bool operator==(const CBitmapInfo& other) const - { - return this->m_strFileName.CompareNoCase(other.m_strFileName) == 0; - } - - virtual ~CBitmapInfo() - { - }; - - bool CanLoad() const - { - return m_bCanLoad; - } - - bool IsCFA() - { - return (m_CFAType != CFATYPE_NONE); - }; - - bool IsMaster() - { - return m_bMaster; - }; - - void GetDescription(CString & strDescription) - { - strDescription = m_strFileType; - if (m_strModel.GetLength()) - strDescription.Format(_T("%s (%s)"), (LPCTSTR)m_strFileType, (LPCTSTR)m_strModel); - }; - - bool IsInitialized() - { - return m_lWidth && m_lHeight; - }; -}; - -inline bool CompareBitmapInfoDateTime (const CBitmapInfo & bi1, const CBitmapInfo & bi2) -{ - if (bi1.m_DateTime.wYear < bi2.m_DateTime.wYear) - return true; - else if (bi1.m_DateTime.wYear > bi2.m_DateTime.wYear) - return false; - else if (bi1.m_DateTime.wMonth < bi2.m_DateTime.wMonth) - return true; - else if (bi1.m_DateTime.wMonth > bi2.m_DateTime.wMonth) - return false; - else if (bi1.m_DateTime.wDay < bi2.m_DateTime.wDay) - return true; - else if (bi1.m_DateTime.wDay > bi2.m_DateTime.wDay) - return false; - else if (bi1.m_DateTime.wHour < bi2.m_DateTime.wHour) - return true; - else if (bi1.m_DateTime.wHour > bi2.m_DateTime.wHour) - return false; - else if (bi1.m_DateTime.wMinute < bi2.m_DateTime.wMinute) - return true; - else if (bi1.m_DateTime.wMinute > bi2.m_DateTime.wMinute) - return false; - else if (bi1.m_DateTime.wSecond < bi2.m_DateTime.wSecond) - return true; - else if (bi1.m_DateTime.wSecond > bi2.m_DateTime.wSecond) - return false; - else - return (bi1.m_DateTime.wMilliseconds < bi2.m_DateTime.wMilliseconds); -}; - -/* ------------------------------------------------------------------- */ - -#if DSSFILEDECODING==1 - class CAllDepthBitmap { public: bool m_bDontUseAHD; std::shared_ptr m_pBitmap; std::shared_ptr m_pWndBitmap; - std::shared_ptr m_Image; - - + std::shared_ptr m_Image; CAllDepthBitmap() : m_bDontUseAHD(false) {}; ~CAllDepthBitmap() {}; CAllDepthBitmap(const CAllDepthBitmap& adb) = default; CAllDepthBitmap& operator=(const CAllDepthBitmap& adb) = default; - void Clear() - { - m_pBitmap.reset(); - m_pWndBitmap.reset(); - m_Image.reset(); - } - - void SetDontUseAHD(bool bSet) - { - m_bDontUseAHD = bSet; - } - + void Clear(); + void SetDontUseAHD(bool bSet){m_bDontUseAHD = bSet;} bool initQImage(); }; -void CopyBitmapToClipboard(HBITMAP hBitmap); - -bool RetrieveEXIFInfo(LPCTSTR szFileName, CBitmapInfo & BitmapInfo); -//HBITMAP LoadPicture(LPCTSTR szFileName, CMemoryBitmap ** ppBitmap = nullptr); -bool LoadPicture(LPCTSTR szFileName, CAllDepthBitmap & AllDepthBitmap, ProgressBase * pProgress = nullptr); -bool DebayerPicture(CMemoryBitmap* pInBitmap, std::shared_ptr& rpOutBitmap, ProgressBase * pProgress); - -#endif // DSSFILEDECODING -bool FetchPicture(const fs::path filePath, std::shared_ptr& rpBitmap, ProgressBase* const pProgress); - -bool GetPictureInfo(LPCTSTR szFileName, CBitmapInfo & BitmapInfo); - -std::shared_ptr GetFilteredImage(const CMemoryBitmap* pInBitmap, const int lFilterSize, ProgressBase* pProgress = nullptr); - -/* ------------------------------------------------------------------- */ - -inline bool IsCFA(const CMemoryBitmap* pBitmap) -{ - return pBitmap != nullptr && pBitmap->IsCFA(); -} - -/* ------------------------------------------------------------------- */ - -CFATYPE GetCFAType(CMemoryBitmap * pBitmap); - -/* ------------------------------------------------------------------- */ - -inline bool IsMonochrome(CMemoryBitmap * pBitmap) -{ - if (pBitmap) - return pBitmap->IsMonochrome(); - else - return false; -}; +void CopyBitmapToClipboard(HBITMAP hBitmap); +bool LoadPicture(LPCTSTR szFileName, CAllDepthBitmap & AllDepthBitmap, DSS::ProgressBase* pProgress = nullptr); +bool DebayerPicture(CMemoryBitmap* pInBitmap, std::shared_ptr& rpOutBitmap, DSS::ProgressBase* pProgress); -/* ------------------------------------------------------------------- */ -#include "RAWUtils.h" -#include "TIFFUtil.h" -#include "FITSUtil.h" -#include "AHDDemosaicing.h" +bool ApplyGammaTransformation(C32BitsBitmap* pOutBitmap, CMemoryBitmap* pInBitmap, CGammaTransformation& gammatrans); +bool ApplyGammaTransformation(QImage* pImage, CMemoryBitmap* pInBitmap, CGammaTransformation& gammatrans); #endif // _BITMAPEXT_H__ diff --git a/DeepSkyStacker/BitmapExtraInfo.h b/DeepSkyStacker/BitmapExtraInfo.h new file mode 100644 index 000000000..d181ee741 --- /dev/null +++ b/DeepSkyStacker/BitmapExtraInfo.h @@ -0,0 +1,56 @@ +#pragma once +#include "ExtraInfo.h" + +class CBitmapExtraInfo +{ +public: + EXTRAINFOVECTOR m_vExtras; + +public: + CBitmapExtraInfo() {}; + ~CBitmapExtraInfo() {}; + + void AddInfo(const CExtraInfo& ei) + { + m_vExtras.push_back(ei); + }; + + void AddInfo(const QString& szName, const QString& szValue, const QString& szComment, bool bPropagate = false) + { + CExtraInfo ei; + + ei.m_Type = EIT_STRING; + ei.m_strName = szName; + ei.m_strComment = szComment; + ei.m_strValue = szValue; + ei.m_bPropagate = bPropagate; + m_vExtras.push_back(ei); + }; + void AddInfo(const QString& szName, int lValue, const QString& szComment, bool bPropagate = false) + { + CExtraInfo ei; + + ei.m_Type = EIT_LONG; + ei.m_strName = szName; + ei.m_lValue = lValue; + ei.m_strComment = szComment; + ei.m_bPropagate = bPropagate; + m_vExtras.push_back(ei); + }; + void AddInfo(const QString& szName, double fValue, const QString& szComment = nullptr, bool bPropagate = false) + { + CExtraInfo ei; + + ei.m_Type = EIT_DOUBLE; + ei.m_strName = szName; + ei.m_fValue = fValue; + ei.m_strComment = szComment; + ei.m_bPropagate = bPropagate; + m_vExtras.push_back(ei); + }; + + void Clear() + { + m_vExtras.clear(); + }; +}; \ No newline at end of file diff --git a/DeepSkyStacker/BitmapInfo.cpp b/DeepSkyStacker/BitmapInfo.cpp new file mode 100644 index 000000000..878dbe5de --- /dev/null +++ b/DeepSkyStacker/BitmapInfo.cpp @@ -0,0 +1,211 @@ +#include "stdafx.h" +#include "BitmapInfo.h" +#include "Ztrace.h" + + +// Don't want these really. +#include +#include +#include +using namespace Gdiplus; + +bool RetrieveEXIFInfo(LPCTSTR szFileName, CBitmapInfo& BitmapInfo) +{ + ZFUNCTRACE_RUNTIME(); + auto pBitmap = std::make_unique(CComBSTR(szFileName)); + return RetrieveEXIFInfo(pBitmap.get(), BitmapInfo); +} + +bool RetrieveEXIFInfo(Gdiplus::Bitmap* pBitmap, CBitmapInfo& BitmapInfo) +{ + ZFUNCTRACE_RUNTIME(); + bool bResult = false; + + const auto getExifItem = [pBitmap, &bResult](const PROPID propertyId, const unsigned short type, auto& field) -> void + { + const auto dwPropertySize = pBitmap->GetPropertyItemSize(propertyId); + if (dwPropertySize != 0) + { + auto buffer = std::make_unique(dwPropertySize); + Gdiplus::PropertyItem* const propertyItem = reinterpret_cast(buffer.get()); + + if (propertyItem->type == type && pBitmap->GetPropertyItem(propertyId, dwPropertySize, propertyItem) == Gdiplus::Status::Ok) + { + if (propertyItem->type == PropertyTagTypeRational) + { + const std::uint32_t* pValues = static_cast(propertyItem->value); + const std::uint32_t dwNumerator = *pValues; + const std::uint32_t dwDenominator = *(pValues + 1); + if (dwDenominator != 0) + { + if constexpr (std::is_same_v) + { + field = static_cast(dwNumerator) / static_cast(dwDenominator); + bResult = true; + } + } + } + else if (propertyItem->type == PropertyTagTypeShort) + { + if constexpr (std::is_same_v) + { + const std::uint16_t* pValue = static_cast(propertyItem->value); + field = static_cast(*pValue); + bResult = true; + } + } + else if (propertyItem->type == PropertyTagTypeASCII) + { + if constexpr (std::is_same_v) + { + field = static_cast(propertyItem->value); + bResult = true; + } + } + } + } + }; + + if (pBitmap != nullptr) + { + getExifItem(PropertyTagExifExposureTime, PropertyTagTypeRational, BitmapInfo.m_fExposure); + getExifItem(PropertyTagExifFNumber, PropertyTagTypeRational, BitmapInfo.m_fAperture); + getExifItem(PropertyTagExifISOSpeed, PropertyTagTypeShort, BitmapInfo.m_lISOSpeed); + + getExifItem(PropertyTagEquipModel, PropertyTagTypeASCII, BitmapInfo.m_strModel); + BitmapInfo.m_strModel = BitmapInfo.m_strModel.trimmed(); + + CString strDateTime; + getExifItem(PropertyTagDateTime, PropertyTagTypeASCII, strDateTime); + // Parse the string : YYYY/MM/DD hh:mm:ss + // 0123456789012345678 + BitmapInfo.m_DateTime.wYear = _ttol(strDateTime.Left(4)); + BitmapInfo.m_DateTime.wMonth = _ttol(strDateTime.Mid(5, 2)); + BitmapInfo.m_DateTime.wDay = _ttol(strDateTime.Mid(8, 2)); + BitmapInfo.m_DateTime.wHour = _ttol(strDateTime.Mid(11, 2)); + BitmapInfo.m_DateTime.wMinute = _ttol(strDateTime.Mid(14, 2)); + BitmapInfo.m_DateTime.wSecond = _ttol(strDateTime.Mid(17, 2)); + + //UINT dwPropertySize = pBitmap->GetPropertyItemSize(PropertyTagExifExposureTime); + //if (dwPropertySize != 0) + //{ + // auto buffer = std::make_unique(dwPropertySize); + // // PropertyTagTypeRational + // Gdiplus::PropertyItem* const propertyItem = reinterpret_cast(buffer.get()); + + // if (pBitmap->GetPropertyItem(PropertyTagExifExposureTime, dwPropertySize, propertyItem) == Ok) + // { + // if(propertyItem->type == PropertyTagTypeRational) + // { + // std::uint32_t* pValues = static_cast(propertyItem->value); + // std::uint32_t dwNumerator, dwDenominator; + + // dwNumerator = *pValues; + // dwDenominator = *(pValues + 1); + + // if (dwDenominator != 0) + // { + // BitmapInfo.m_fExposure = static_cast(dwNumerator) / static_cast(dwDenominator); + // bResult = true; + // }; + // }; + // }; + //}; + + //dwPropertySize = pBitmap->GetPropertyItemSize(PropertyTagExifFNumber); + //if (dwPropertySize) + //{ + // // PropertyTagTypeRational + // PropertyItem* propertyItem = (PropertyItem*)malloc(dwPropertySize); + + // if (pBitmap->GetPropertyItem(PropertyTagExifFNumber, dwPropertySize, propertyItem) == Ok) + // { + // if (propertyItem->type == PropertyTagTypeRational) + // { + // UINT * pValues = (UINT*)propertyItem->value; + // UINT dwNumerator, + // dwDenominator; + + // dwNumerator = *pValues; + // pValues++; + // dwDenominator = *pValues; + + // if (dwDenominator) + // { + // BitmapInfo.m_fAperture = (double)dwNumerator / (double)dwDenominator; + // bResult = true; + // }; + // }; + // }; + + // free(propertyItem); + //}; + + //dwPropertySize = pBitmap->GetPropertyItemSize(PropertyTagExifISOSpeed); + //if (dwPropertySize) + //{ + // // PropertyTagTypeShort + // PropertyItem* propertyItem = (PropertyItem*)malloc(dwPropertySize); + + // if (pBitmap->GetPropertyItem(PropertyTagExifISOSpeed, dwPropertySize, propertyItem) == Ok) + // { + // if(propertyItem->type == PropertyTagTypeShort) + // { + // BitmapInfo.m_lISOSpeed = *((WORD*)propertyItem->value); + // bResult = true; + // }; + // }; + + // free(propertyItem); + //}; + + //dwPropertySize = pBitmap->GetPropertyItemSize(PropertyTagEquipModel); + //if (dwPropertySize) + //{ + // // PropertyTagTypeASCII + // PropertyItem* propertyItem = (PropertyItem*)malloc(dwPropertySize); + // if (pBitmap->GetPropertyItem(PropertyTagEquipModel, dwPropertySize, propertyItem) == Ok) + // { + // if(propertyItem->type == PropertyTagTypeASCII) + // { + // BitmapInfo.m_strModel = (char*)propertyItem->value; + // BitmapInfo.m_strModel.TrimRight(); + // BitmapInfo.m_strModel.TrimLeft(); + // bResult = true; + // }; + // }; + + // free(propertyItem); + //}; + + //dwPropertySize = pBitmap->GetPropertyItemSize(PropertyTagDateTime); + //if (dwPropertySize) + //{ + // // PropertyTagTypeASCII + // PropertyItem* propertyItem = (PropertyItem*)malloc(dwPropertySize); + // if (pBitmap->GetPropertyItem(PropertyTagDateTime, dwPropertySize, propertyItem) == Ok) + // { + // if(propertyItem->type == PropertyTagTypeASCII) + // { + // CString strDateTime = (char*)propertyItem->value; + + // // Parse the string : YYYY/MM/DD hh:mm:ss + // // 0123456789012345678 + // BitmapInfo.m_DateTime.wYear = _ttol(strDateTime.Left(4)); + // BitmapInfo.m_DateTime.wMonth = _ttol(strDateTime.Mid(5, 2)); + // BitmapInfo.m_DateTime.wDay = _ttol(strDateTime.Mid(8, 2)); + // BitmapInfo.m_DateTime.wHour = _ttol(strDateTime.Mid(11, 2)); + // BitmapInfo.m_DateTime.wMinute= _ttol(strDateTime.Mid(14, 2)); + // BitmapInfo.m_DateTime.wSecond= _ttol(strDateTime.Mid(17, 2)); + + // bResult = true; + // }; + // }; + + // free(propertyItem); + //}; + + }; + + return bResult; +} \ No newline at end of file diff --git a/DeepSkyStacker/BitmapInfo.h b/DeepSkyStacker/BitmapInfo.h new file mode 100644 index 000000000..271b7acf1 --- /dev/null +++ b/DeepSkyStacker/BitmapInfo.h @@ -0,0 +1,59 @@ +#pragma once +#include "BitmapExtraInfo.h" +#include "cfa.h" + +// Don't want this :( +#include + +class CBitmapInfo +{ +public: + QString m_strFileName; + QString m_strFileType; + QString m_strModel; + int m_lISOSpeed; + int m_lGain; + double m_fExposure; + double m_fAperture; + int m_lWidth; + int m_lHeight; + int m_lBitPerChannel; + int m_lNrChannels; + bool m_bCanLoad; + bool m_bFloat; + CFATYPE m_CFAType; + bool m_bMaster; + bool m_bFITS16bit; + QString m_strDateTime; + SYSTEMTIME m_DateTime; + SYSTEMTIME m_InfoTime; + CBitmapExtraInfo m_ExtraInfo; + int m_xBayerOffset; + int m_yBayerOffset; + QString m_filterName; + +private: + void CopyFrom(const CBitmapInfo& bi); + void Init(); + +public: + CBitmapInfo(); + CBitmapInfo(const CBitmapInfo& bi); + CBitmapInfo(LPCTSTR szFileName); + + virtual ~CBitmapInfo() = default; + + CBitmapInfo& operator = (const CBitmapInfo& bi); + bool operator<(const CBitmapInfo& other) const; + bool operator==(const CBitmapInfo& other) const; + + bool CanLoad() const; + bool IsCFA(); + bool IsMaster(); + void GetDescription(QString& strDescription); + bool IsInitialized(); +}; + +namespace Gdiplus { class Bitmap; } +bool RetrieveEXIFInfo(LPCTSTR szFileName, CBitmapInfo& BitmapInfo); +bool RetrieveEXIFInfo(Gdiplus::Bitmap* pBitmap, CBitmapInfo& BitmapInfo); diff --git a/DeepSkyStacker/BitmapIterator.h b/DeepSkyStacker/BitmapIterator.h index ea88a3946..814dd46ce 100644 --- a/DeepSkyStacker/BitmapIterator.h +++ b/DeepSkyStacker/BitmapIterator.h @@ -1,7 +1,5 @@ #pragma once - -#include "BitmapBase.h" - +class CMemoryBitmap; template class BitmapIt { diff --git a/DeepSkyStacker/BitmapPartFile.h b/DeepSkyStacker/BitmapPartFile.h new file mode 100644 index 000000000..82f625f36 --- /dev/null +++ b/DeepSkyStacker/BitmapPartFile.h @@ -0,0 +1,46 @@ +#pragma once + +class CBitmapPartFile +{ +public: + QString m_strFile; + int m_lStartRow; + int m_lEndRow; + int m_lWidth; + int m_lNrBitmaps; + +private: + void CopyFrom(const CBitmapPartFile& bp) + { + m_strFile = bp.m_strFile; + m_lStartRow = bp.m_lStartRow; + m_lEndRow = bp.m_lEndRow; + m_lWidth = bp.m_lWidth; + m_lNrBitmaps = bp.m_lNrBitmaps; + }; + +public: + CBitmapPartFile(const QString& szFile, int lStartRow, int lEndRow) + { + m_strFile = szFile; + m_lStartRow = lStartRow; + m_lEndRow = lEndRow; + m_lWidth = 0; + m_lNrBitmaps = 0; + }; + + CBitmapPartFile(const CBitmapPartFile& bp) + { + CopyFrom(bp); + }; + + const CBitmapPartFile& operator= (const CBitmapPartFile& bp) + { + CopyFrom(bp); + return *this; + }; + + virtual ~CBitmapPartFile() + {} +}; +typedef std::vector BITMAPPARTFILEVECTOR; diff --git a/DeepSkyStacker/CFABitmapInfo.h b/DeepSkyStacker/CFABitmapInfo.h new file mode 100644 index 000000000..9a4bd74cf --- /dev/null +++ b/DeepSkyStacker/CFABitmapInfo.h @@ -0,0 +1,117 @@ +#pragma once +#include "BitmapConstants.h" + + +class CCFABitmapInfo +{ +protected: + CFATRANSFORMATION m_CFATransform; + CFATYPE m_CFAType; + bool m_bCYMG; + int m_xBayerOffset; + int m_yBayerOffset; + +protected: + virtual void SetCFA(bool bCFA) = 0; + +public: + void InitFrom(const CCFABitmapInfo* const pCFABitmapInfo) + { + m_CFATransform = pCFABitmapInfo->m_CFATransform; + m_CFAType = pCFABitmapInfo->m_CFAType; + m_bCYMG = pCFABitmapInfo->m_bCYMG; + m_xBayerOffset = pCFABitmapInfo->m_xBayerOffset; + m_yBayerOffset = pCFABitmapInfo->m_yBayerOffset; + }; + +public: + CCFABitmapInfo() : + m_CFATransform{ CFAT_NONE }, + m_CFAType{ CFATYPE_NONE }, + m_bCYMG{ false }, + m_xBayerOffset{ 0 }, + m_yBayerOffset{ 0 } + {} + + void SetCFAType(CFATYPE Type) + { + m_CFAType = Type; + m_bCYMG = IsCYMGType(m_CFAType); + }; + + CCFABitmapInfo& setXoffset(int xOffset) noexcept + { + m_xBayerOffset = xOffset; + return *this; + }; + + inline int xOffset() noexcept + { + return m_xBayerOffset; + } + + CCFABitmapInfo& setYoffset(int yOffset) noexcept + { + m_yBayerOffset = yOffset; + return *this; + }; + + inline int yOffset() noexcept + { + return m_yBayerOffset; + } + + inline CFATYPE GetCFAType() const noexcept + { + return m_CFAType; + }; + + void UseSuperPixels(bool bUse) + { + if (bUse) + { + m_CFATransform = CFAT_SUPERPIXEL; + SetCFA(true); + } + else + m_CFATransform = CFAT_NONE; + }; + + void UseRawBayer(bool bUse) + { + if (bUse) + { + m_CFATransform = CFAT_RAWBAYER; + SetCFA(true); + } + else + m_CFATransform = CFAT_NONE; + }; + + void UseBilinear(bool bUse) + { + if (bUse) + { + m_CFATransform = CFAT_BILINEAR; + SetCFA(true); + } + else + m_CFATransform = CFAT_NONE; + }; + + void UseAHD(bool bUse) + { + if (bUse) + { + m_CFATransform = CFAT_AHD; + SetCFA(true); + } + else + m_CFATransform = CFAT_NONE; + }; + + CFATRANSFORMATION GetCFATransformation() const + { + return m_CFATransform; + }; +}; diff --git a/DeepSkyStacker/ChannelAlign.cpp b/DeepSkyStacker/ChannelAlign.cpp index c1bb5eb11..5e2a8e306 100644 --- a/DeepSkyStacker/ChannelAlign.cpp +++ b/DeepSkyStacker/ChannelAlign.cpp @@ -4,6 +4,8 @@ #include "RegisterEngine.h" #include "MatchingStars.h" #include "BitmapIterator.h" +#include "Ztrace.h" +#include "ColorBitmap.h" /* ------------------------------------------------------------------- */ diff --git a/DeepSkyStacker/ChannelAlign.h b/DeepSkyStacker/ChannelAlign.h index ab62df78e..52158ffdc 100644 --- a/DeepSkyStacker/ChannelAlign.h +++ b/DeepSkyStacker/ChannelAlign.h @@ -5,11 +5,12 @@ #include "DSSTools.h" #include "BitmapExt.h" #include "PixelTransform.h" +namespace DSS { class ProgressBase; } class CChannelAlign { private : - std::shared_ptr AlignChannel(CMemoryBitmap* pBitmap, CPixelTransform& PixTransform, ProgressBase* pProgress); + std::shared_ptr AlignChannel(CMemoryBitmap* pBitmap, CPixelTransform& PixTransform, DSS::ProgressBase* pProgress); void CopyBitmap(const CMemoryBitmap* pSrcBitmap, CMemoryBitmap* pTgtBitmap) const; public: @@ -19,7 +20,7 @@ private : ~CChannelAlign() {} - bool AlignChannels(CMemoryBitmap* pBitmap, ProgressBase* pProgress); + bool AlignChannels(CMemoryBitmap* pBitmap, DSS::ProgressBase* pProgress); }; #endif diff --git a/DeepSkyStacker/CheckAbove.cpp b/DeepSkyStacker/CheckAbove.cpp index c4a7272d3..a2a49c7d3 100644 --- a/DeepSkyStacker/CheckAbove.cpp +++ b/DeepSkyStacker/CheckAbove.cpp @@ -2,7 +2,6 @@ // #include "stdafx.h" - #include "CheckAbove.h" #include "ui/ui_CheckAbove.h" diff --git a/DeepSkyStacker/CheckAbove.h b/DeepSkyStacker/CheckAbove.h index bf4505f03..100a69e24 100644 --- a/DeepSkyStacker/CheckAbove.h +++ b/DeepSkyStacker/CheckAbove.h @@ -1,8 +1,5 @@ #pragma once -#include -#include - namespace Ui { class CheckAbove; } diff --git a/DeepSkyStacker/ColorBitmap.cpp b/DeepSkyStacker/ColorBitmap.cpp new file mode 100644 index 000000000..612fc2703 --- /dev/null +++ b/DeepSkyStacker/ColorBitmap.cpp @@ -0,0 +1,294 @@ +#include "stdafx.h" +#include "ColorBitmap.h" +#include "ColorHelpers.h" +#include "ZExcept.h" +#include "ColorMultiBitmap.h" +#include "MedianFilterEngine.h" +#include "BitmapCharacteristics.h" + + +template +void CColorBitmapT::CheckXY(size_t x, size_t y) const +{ + ZASSERTSTATE(x >= 0 && x < m_lWidth&& y >= 0 && y < m_lHeight); +} + +template +size_t CColorBitmapT::GetOffset(const size_t x, const size_t y) const +{ + return m_bTopDown ? static_cast(m_lWidth) * y + x : static_cast(m_lWidth) * (static_cast(m_lHeight) - 1 - y) + x; +} +template +size_t CColorBitmapT::GetOffset(int x, int y) const +{ + CheckXY(x, y); + return GetOffset(static_cast(x), static_cast(y)); +} + +template +CColorBitmapT::CColorBitmapT() : + m_lWidth{ 0 }, + m_lHeight{ 0 }, + m_bWord{ std::is_same_v }, + m_bDouble{ std::is_same_v }, + m_bDWord{ std::is_same_v }, + m_bFloat{ std::is_same_v }, + m_fMultiplier{ (std::is_same_v || std::is_same_v || std::is_same_v) ? 256.0 : (std::is_same_v ? 256.0 * 65536.0 : 1.0) } +{ + m_bTopDown = true; +} + +template +std::unique_ptr CColorBitmapT::Clone(bool bEmpty/*=false*/) const +{ + auto pResult = std::make_unique>(); + if (!bEmpty) + { + pResult->m_lHeight = m_lHeight; + pResult->m_lWidth = m_lWidth; + pResult->m_Red.m_vPixels = m_Red.m_vPixels; + pResult->m_Green.m_vPixels = m_Green.m_vPixels; + pResult->m_Blue.m_vPixels = m_Blue.m_vPixels; + } + pResult->m_bWord = m_bWord; + pResult->m_bDouble = m_bDouble; + pResult->m_bDWord = m_bDWord; + pResult->m_bFloat = m_bFloat; + + pResult->CopyFrom(*this); + + return pResult; +} + +template +bool CColorBitmapT::Init(int lWidth, int lHeight) +{ + m_lWidth = lWidth; + m_lHeight = lHeight; + + const bool bResult = m_Red.Init(lWidth, lHeight) && m_Green.Init(lWidth, lHeight) && m_Blue.Init(lWidth, lHeight); + return bResult; +} + +template +void CColorBitmapT::SetValue(size_t i, size_t j, double fRed, double fGreen, double fBlue) +{ + CheckXY(i, j); + + const size_t lOffset = GetOffset(i, j); + + m_Red.m_vPixels[lOffset] = fRed; + m_Green.m_vPixels[lOffset] = fGreen; + m_Blue.m_vPixels[lOffset] = fBlue; +} + +template +void CColorBitmapT::GetValue(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) const +{ + CheckXY(i, j); + + const size_t lOffset = GetOffset(i, j); + + fRed = m_Red.m_vPixels[lOffset]; + fGreen = m_Green.m_vPixels[lOffset]; + fBlue = m_Blue.m_vPixels[lOffset]; +} + +template +void CColorBitmapT::SetPixel(size_t i, size_t j, double fRed, double fGreen, double fBlue) +{ + CheckXY(i, j); + + const size_t lOffset = GetOffset(i, j); + m_Red.m_vPixels[lOffset] = fRed * m_fMultiplier; + m_Green.m_vPixels[lOffset] = fGreen * m_fMultiplier; + m_Blue.m_vPixels[lOffset] = fBlue * m_fMultiplier; +} + +template +void CColorBitmapT::SetPixel(size_t i, size_t j, double fGray) +{ + + CheckXY(i, j); // Throw if not + + const size_t lOffset = GetOffset(i, j); + const double value = fGray * m_fMultiplier; + m_Red.m_vPixels[lOffset] = value; + m_Green.m_vPixels[lOffset] = value; + m_Blue.m_vPixels[lOffset] = value; +} + +template +void CColorBitmapT::GetPixel(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) +{ + fRed = fGreen = fBlue = 0.0; + + CheckXY(i, j); + + const size_t lOffset = GetOffset(i, j); + + fRed = m_Red.m_vPixels[lOffset] / m_fMultiplier; + fGreen = m_Green.m_vPixels[lOffset] / m_fMultiplier; + fBlue = m_Blue.m_vPixels[lOffset] / m_fMultiplier; +} + +template +void CColorBitmapT::GetPixel(size_t i, size_t j, double& fGray) +{ + double fRed, fGreen, fBlue; + fGray = 0.0; + + GetPixel(i, j, fRed, fGreen, fBlue); + double H, S, L; + + ToHSL(fRed, fGreen, fBlue, H, S, L); + fGray = L * 255.0; +} + +template +bool CColorBitmapT::GetScanLine(size_t j, void* pScanLine) +{ + bool bResult = false; + + if (j < m_lHeight) + { + auto* const pTempScan = static_cast(pScanLine); + const size_t w = static_cast(m_lWidth); + const size_t index = static_cast(j) * w; + + memcpy(pTempScan, &(m_Red.m_vPixels[index]), sizeof(TType) * w); + memcpy(pTempScan + sizeof(TType) * w, &(m_Green.m_vPixels[index]), sizeof(TType) * w); + memcpy(pTempScan + sizeof(TType) * 2 * w, &(m_Blue.m_vPixels[index]), sizeof(TType) * w); + bResult = true; + } + + return bResult; +} + +template +bool CColorBitmapT::SetScanLine(size_t j, void* pScanLine) +{ + bool bResult = false; + + if (j < m_lHeight) + { + const auto* const pTempScan = static_cast(pScanLine); + const size_t w = static_cast(m_lWidth); + const size_t index = static_cast(j) * w; + + memcpy(&(m_Red.m_vPixels[index]), pTempScan, sizeof(TType) * w); + memcpy(&(m_Green.m_vPixels[index]), pTempScan + sizeof(TType) * w, sizeof(TType) * w); + memcpy(&(m_Blue.m_vPixels[index]), pTempScan + sizeof(TType) * 2 * w, sizeof(TType) * w); + bResult = true; + } + + return bResult; +} + +template +void CColorBitmapT::Clear() +{ + m_lHeight = 0; + m_lWidth = 0; + m_Red.m_vPixels.clear(); + m_Green.m_vPixels.clear(); + m_Blue.m_vPixels.clear(); +} + +template +std::shared_ptr CColorBitmapT::CreateEmptyMultiBitmap() const +{ + std::shared_ptr> pResult = std::make_shared>(); + pResult->SetBitmapModel(this); + return pResult; +} + +template +std::shared_ptr CColorBitmapT::GetMedianFilterEngine() const +{ + std::shared_ptr> pFilter = std::make_shared>(); + pFilter->SetInputBitmap(this); + return pFilter; +} + +template +void CColorBitmapT::RemoveHotPixels(ProgressBase* pProgress/*=nullptr*/) +{ + m_Red.RemoveHotPixels(pProgress); + m_Green.RemoveHotPixels(pProgress); + m_Blue.RemoveHotPixels(pProgress); +} + +template +void CColorBitmapT::GetCharacteristics(CBitmapCharacteristics& bc) +{ + bc.m_bFloat = m_bFloat; + bc.m_dwHeight = m_lHeight; + bc.m_dwWidth = m_lWidth; + bc.m_lNrChannels = 3; + bc.m_lBitsPerPixel = BitPerSample(); +} + +template +void CColorBitmapT::InitIterator(void*& pRed, void*& pGreen, void*& pBlue, size_t& elementSize, const size_t x, const size_t y) +{ + const size_t index = GetOffset(x, y); + pRed = static_cast(this->m_Red.m_vPixels.data() + index); + pGreen = static_cast(this->m_Green.m_vPixels.data() + index); + pBlue = static_cast(this->m_Blue.m_vPixels.data() + index); + elementSize = sizeof(TType); +} +template +void CColorBitmapT::InitIterator(const void*& pRed, const void*& pGreen, const void*& pBlue, size_t& elementSize, const size_t x, const size_t y) const +{ + const size_t index = GetOffset(x, y); + pRed = static_cast(this->m_Red.m_vPixels.data() + index); + pGreen = static_cast(this->m_Green.m_vPixels.data() + index); + pBlue = static_cast(this->m_Blue.m_vPixels.data() + index); + elementSize = sizeof(TType); +} + +template +std::tuple CColorBitmapT::ConvertValue3(const void* pRed, const void* pGreen, const void* pBlue) const +{ + const double r = static_cast(*static_cast(pRed)) / this->m_fMultiplier; + const double g = static_cast(*static_cast(pGreen)) / this->m_fMultiplier; + const double b = static_cast(*static_cast(pBlue)) / this->m_fMultiplier; + return { r, g, b }; +} + +template +double CColorBitmapT::ConvertValue1(const void* pRed, const void* pGreen, const void* pBlue) const +{ + const double r = static_cast(*static_cast(pRed)) / this->m_fMultiplier; + const double g = static_cast(*static_cast(pGreen)) / this->m_fMultiplier; + const double b = static_cast(*static_cast(pBlue)) / this->m_fMultiplier; + double H, S, L; + ToHSL(r, g, b, H, S, L); + return L * 255.0; +} + +template +void CColorBitmapT::ReceiveValue(void* pRed, void* pGreen, void* pBlue, const double red, const double green, const double blue) const +{ + *static_cast(pRed) = static_cast(red * this->m_fMultiplier); + *static_cast(pGreen) = static_cast(green * this->m_fMultiplier); + *static_cast(pBlue) = static_cast(blue * this->m_fMultiplier); +} + +template +void CColorBitmapT::ReceiveValue(void* pRed, void* pGreen, void* pBlue, const double gray) const +{ + const TType value = static_cast(gray * this->m_fMultiplier); + *static_cast(pRed) = value; + *static_cast(pGreen) = value; + *static_cast(pBlue) = value; +} + +// Define these here so that we can simple headers. We only run with these types so this isn't too bad. +template class CColorBitmapT; +template class CColorBitmapT; +template class CColorBitmapT; +template class CColorBitmapT; +template class CColorBitmapT; +template class CColorBitmapT; \ No newline at end of file diff --git a/DeepSkyStacker/ColorBitmap.h b/DeepSkyStacker/ColorBitmap.h new file mode 100644 index 000000000..29bc1a175 --- /dev/null +++ b/DeepSkyStacker/ColorBitmap.h @@ -0,0 +1,145 @@ +#pragma once +#include "GrayBitmap.h" + +class CColorBitmap +{ +public: + CColorBitmap() + {} + + virtual ~CColorBitmap() + {} + + virtual CMemoryBitmap* GetRed() = 0; + virtual CMemoryBitmap* GetGreen() = 0; + virtual CMemoryBitmap* GetBlue() = 0; +}; + +template +class CColorBitmapT : public CMemoryBitmap, public CColorBitmap +{ +public: + //friend CColorMedianFilterEngineT; + +private: + int m_lHeight; + int m_lWidth; + bool m_bWord; + bool m_bDouble; + bool m_bDWord; + bool m_bFloat; + const double m_fMultiplier; + +public: + CGrayBitmapT m_Red; + CGrayBitmapT m_Green; + CGrayBitmapT m_Blue; + +private: + void CheckXY(size_t x, size_t y) const; + + size_t GetOffset(const size_t x, const size_t y) const; + size_t GetOffset(int x, int y) const; + +public: + CColorBitmapT(); + virtual ~CColorBitmapT() = default; + + virtual std::unique_ptr Clone(bool bEmpty = false) const override; + + virtual int BitPerSample() override + { + return sizeof(TType) * 8; + } + + virtual int IsFloat() override + { + return m_bFloat; + } + + virtual int Width() const override + { + return m_lWidth; + } + + virtual int Height() const override + { + return m_lHeight; + } + + virtual bool Init(int lWidth, int lHeight) override; + + virtual bool IsMonochrome() const override + { + return false; + } + + virtual void SetValue(size_t i, size_t j, double fRed, double fGreen, double fBlue) override; + virtual void GetValue(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) const override; + virtual void SetPixel(size_t i, size_t j, double fRed, double fGreen, double fBlue) override; + virtual void SetPixel(size_t i, size_t j, double fGray) override; + virtual void GetPixel(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) override; + virtual void GetPixel(size_t i, size_t j, double& fGray) override; + virtual bool GetScanLine(size_t j, void* pScanLine) override; + virtual bool SetScanLine(size_t j, void* pScanLine) override; + void Clear(); + + virtual std::shared_ptr CreateEmptyMultiBitmap() const override; + virtual std::shared_ptr GetMedianFilterEngine() const override; + + TType* GetRedPixel(int i, int j) + { + return m_Red.m_vPixels.data() + GetOffset(i, j); + } + TType* GetGreenPixel(int i, int j) + { + return m_Green.m_vPixels.data() + GetOffset(i, j); + } + TType* GetBluePixel(int i, int j) + { + return m_Blue.m_vPixels.data() + GetOffset(i, j); + } + + virtual CMemoryBitmap* GetRed() override + { + return &m_Red; + } + + virtual CMemoryBitmap* GetGreen() override + { + return &m_Green; + } + + virtual CMemoryBitmap* GetBlue() override + { + return &m_Blue; + } + + double GetMultiplier() + { + return m_fMultiplier; + } + + virtual double GetMaximumValue() const override + { + return m_fMultiplier * 256.0; + } + + virtual void RemoveHotPixels(ProgressBase* pProgress = nullptr) override; + virtual void GetCharacteristics(CBitmapCharacteristics& bc) override; + + virtual void InitIterator(void*& pRed, void*& pGreen, void*& pBlue, size_t& elementSize, const size_t x, const size_t y) override; + virtual void InitIterator(const void*& pRed, const void*& pGreen, const void*& pBlue, size_t& elementSize, const size_t x, const size_t y) const override; + + virtual std::tuple ConvertValue3(const void* pRed, const void* pGreen, const void* pBlue) const override; + virtual double ConvertValue1(const void* pRed, const void* pGreen, const void* pBlue) const override; + + virtual void ReceiveValue(void* pRed, void* pGreen, void* pBlue, const double red, const double green, const double blue) const override; + virtual void ReceiveValue(void* pRed, void* pGreen, void* pBlue, const double gray) const override; +}; + + +typedef CColorBitmapT C24BitColorBitmap; +typedef CColorBitmapT C48BitColorBitmap; +typedef CColorBitmapT C96BitColorBitmap; +typedef CColorBitmapT C96BitFloatColorBitmap; diff --git a/DeepSkyStacker/ColorHelpers.cpp b/DeepSkyStacker/ColorHelpers.cpp new file mode 100644 index 000000000..71927e902 --- /dev/null +++ b/DeepSkyStacker/ColorHelpers.cpp @@ -0,0 +1,254 @@ +#include "stdafx.h" +#include "ColorHelpers.h" + +void CYMGToRGB(double fCyan, double fYellow, double fMagenta, double fGreen2, double& fRed, double& fGreen, double& fBlue) +{ + fRed = fGreen = fBlue = 0; + // Basic formulae + // M = R + B + // Y = R + G + // C = B + G + + + // RGB from CYM + // R = (M+Y-C)/2 + // G = (Y+C-M)/2 + // B = (M+C-Y)/2 + fRed = std::max(0.0, fMagenta + fYellow - fCyan) / 2.0; + fGreen = std::max(0.0, fYellow + fCyan - fMagenta) / 2.0; + fBlue = std::max(0.0, fMagenta + fCyan - fYellow) / 2.0; + + /* if (fGreen2) + { + fRed *= fGreen2/fGreen; + fBlue *= fGreen2/fGreen; + fGreen = fGreen2; + }; + fRed = std::min(fRed, 255); + fBlue = std::min(fBlue, 255); + fGreen = std::min(fGreen, 255);*/ + + // RGB from CYG + // G = G + // R = Y - G + // B = C - G + fGreen += fGreen2; + fRed += fYellow - fGreen2; + fBlue += fCyan - fGreen2; + + // RGB from CMG + // G = G + // B = C - G + // R = M - B = M - C + G +// fGreen += fGreen2; + fBlue += fCyan - fGreen2; + fRed += fMagenta - fCyan + fGreen2; + + // RGB from YMG + // G = G + // R = Y - G + // B = M - R = M - Y + G +// fGreen += fGreen2; + fRed += fYellow - fGreen2; + fBlue += fMagenta - fYellow + fGreen2; + + // Average the results + fRed /= 4.0; + fBlue /= 4.0; + fGreen /= 2.0; + + double R = fRed; + double B = fBlue; + double G = fGreen; + + fRed = R * 1.29948 + G * 0.0289296 - B * 0.934432; + fGreen = -0.409754 * R + 1.31042 * G - 0.523692 * B; + fBlue = 0.110277 * R - 0.339351 * G + 2.45812 * B; + + fRed = std::max(0.0, std::min(255.0, fRed)); + fGreen = std::max(0.0, std::min(255.0, fGreen)); + fBlue = std::max(0.0, std::min(255.0, fBlue)); +} + +void CYMGToRGB12(double fCyan, double fYellow, double fMagenta, double fGreen2, double& fRed, double& fGreen, double& fBlue) +{ + double Y, U, V; + double R, G, B; + + Y = (fCyan + fYellow + fMagenta + fGreen2) / 2.0; + U = -(fMagenta + fCyan - fYellow - fGreen2);//*0.492; + V = (fMagenta + fYellow - fCyan - fGreen2);//*0.877; + + R = 1.164 * Y + 1.596 * (V - 128.0); + G = 1.164 * Y - 0.813 * (V - 128.0) - 0.391 * (U - 128); + B = 1.164 * Y + 2.018 * (U - 128.0); + + + fRed = R * 1.29948 + G * 0.0289296 - B * 0.934432; + fGreen = -0.409754 * R + 1.31042 * G - 0.523692 * B; + fBlue = 0.110277 * R - 0.339351 * G + 2.45812 * B; + + // fRed = (Y+1.13983*V)*255.0; + // fGreen = (Y-0.39465*U-0.5806*V)*255.0; + // fBlue = (Y+2.03211*U)*255.0; + + fRed = std::max(0.0, std::min(255.0, fRed)); + fGreen = std::max(0.0, std::min(255.0, fGreen)); + fBlue = std::max(0.0, std::min(255.0, fBlue)); +} + +void CYMGToRGB3(double fCyan, double fYellow, double fMagenta, double fGreen2, double& fRed, double& fGreen, double& fBlue) +{ + fRed = fGreen = fBlue = 0; + // Basic formulae + // M = R + B + // Y = R + G + // C = B + G + + // RGB from CYM + // R = (M+Y-C)/2 + // G = (Y+C-M)/2 + // B = (M+C-Y)/2 + fRed = max(0.0, fMagenta + fYellow - fCyan) / 2.0; + fGreen = max(0.0, fYellow + fCyan - fMagenta) / 2.0; + fBlue = max(0.0, fMagenta + fCyan - fYellow) / 2.0; + + // RGB from CYG + // G = G + // R = Y - G + // B = C - G + fGreen += fGreen2; + fRed += max(0.0, fYellow - fGreen2); + fBlue += max(0.0, fCyan - fGreen2); + + // RGB from CMG + // G = G + // B = C - G + // R = M - B = M - C + G + fBlue += max(0.0, fCyan - fGreen2); + fRed += max(0.0, fMagenta - fCyan + fGreen2); + + // RGB from YMG + // G = G + // R = Y - G + // B = M - R = M - Y + G + fRed += max(0.0, fYellow - fGreen2); + fBlue += max(0.0, fMagenta - fYellow + fGreen2); + + // Average the results + fRed /= 4.0; + fBlue /= 4.0; + fGreen /= 2.0; + + fRed = max(0.0, fRed); + fBlue = max(0.0, fBlue); + fGreen = max(0.0, fGreen); +} + +void ToHSL(double Red, double Green, double Blue, double& H, double& S, double& L) +{ + double minval = std::min(Red, std::min(Green, Blue)); + double maxval = std::max(Red, std::max(Green, Blue)); + double mdiff = maxval - minval; + double msum = maxval + minval; + + L = msum / 510.0f; + + if (maxval == minval) + { + S = 0.0f; + H = 0.0f; + } + else + { + double rnorm = (maxval - Red) / mdiff; + double gnorm = (maxval - Green) / mdiff; + double bnorm = (maxval - Blue) / mdiff; + + S = (L <= 0.5f) ? (mdiff / msum) : (mdiff / (510.0f - msum)); + + if (Red == maxval) H = 60.0f * (6.0f + bnorm - gnorm); + if (Green == maxval) H = 60.0f * (2.0f + rnorm - bnorm); + if (Blue == maxval) H = 60.0f * (4.0f + gnorm - rnorm); + if (H > 360.0f) + H = H - 360.0f; + } +} + +void ToRGB(double H, double S, double L, double& Red, double& Green, double& Blue) +{ + if (S == 0.0) + { + Red = Green = Blue = L * 255.0; + } + else + { + double rm1, rm2; + + if (L <= 0.5f) + rm2 = (double)(L + L * S); + else + rm2 = (double)(L + S - L * S); + rm1 = (double)(2.0f * L - rm2); + + Red = ToRGB1(rm1, rm2, (double)(H + 120.0f)); + Green = ToRGB1(rm1, rm2, (double)H); + Blue = ToRGB1(rm1, rm2, (double)(H - 120.0f)); + } +} + +double ToRGB1(float rm1, float rm2, float rh) +{ + if (rh > 360.0f) + rh -= 360.0f; + else if (rh < 0.0f) + rh += 360.0f; + + if (rh < 60.0f) + rm1 = rm1 + (rm2 - rm1) * rh / 60.0f; + else if (rh < 180.0f) + rm1 = rm2; + else if (rh < 240.0f) + rm1 = rm1 + (rm2 - rm1) * (240.0f - rh) / 60.0f; + + return (rm1 * 255.0); +} + +// --- Don't this this is used --- +/* Return the HSL luminance value. */ +// double GetLuminance(const COLORREF crColor) +// { +// constexpr double scalingFactor = 1.0 / 256.0; +// +// const unsigned red = GetRValue(crColor); +// const unsigned green = GetGValue(crColor); +// const unsigned blue = GetBValue(crColor); +// +// const unsigned minval = std::min(red, std::min(green, blue)); +// const unsigned maxval = std::max(red, std::max(green, blue)); +// const unsigned msum = maxval + minval; +// +// return static_cast(msum) * (0.5 * scalingFactor); +// } + +/* Return the HSL luminance value. */ +double GetLuminance(const COLORREF16& crColor) +{ + constexpr double scalingFactor = 1.0 / 256.0; + + const unsigned minval = std::min(crColor.red, std::min(crColor.green, crColor.blue)); + const unsigned maxval = std::max(crColor.red, std::max(crColor.green, crColor.blue)); + const unsigned msum = maxval + minval; + + return static_cast(msum) * (0.5 * scalingFactor * scalingFactor); // (((double)msum / 256.0) / 510.0); +} + +double ClampPixel(const double fValue) +{ + constexpr double maxVal = 255.0 * 256.0; + if (fValue < 0.0) + return 0.0; + if (fValue > maxVal) + return maxVal; + return fValue; +} \ No newline at end of file diff --git a/DeepSkyStacker/ColorHelpers.h b/DeepSkyStacker/ColorHelpers.h new file mode 100644 index 000000000..fce2743fd --- /dev/null +++ b/DeepSkyStacker/ColorHelpers.h @@ -0,0 +1,12 @@ +#pragma once +#include "ColorRef.h" + +void CYMGToRGB(double fCyan, double fYellow, double fMagenta, double fGreen2, double& fRed, double& fGreen, double& fBlue); +void CYMGToRGB2(double fCyan, double fYellow, double fMagenta, double fGreen2, double& fRed, double& fGreen, double& fBlue); +void CYMGToRGB3(double fCyan, double fYellow, double fMagenta, double fGreen2, double& fRed, double& fGreen, double& fBlue); +void ToHSL(double Red, double Green, double Blue, double& H, double& S, double& L); +void ToRGB(double H, double S, double L, double& Red, double& Green, double& Blue); +double ToRGB1(float rm1, float rm2, float rh); +//double GetLuminance(const COLORREF crColor); // <--- Don't this this is used. +double GetLuminance(const COLORREF16& crColor); +double ClampPixel(const double fValue); \ No newline at end of file diff --git a/DeepSkyStacker/ColorMultiBitmap.cpp b/DeepSkyStacker/ColorMultiBitmap.cpp new file mode 100644 index 000000000..36e50dc27 --- /dev/null +++ b/DeepSkyStacker/ColorMultiBitmap.cpp @@ -0,0 +1,220 @@ +#include "stdafx.h" +#include "ColorMultiBitmap.h" +#include "BitmapCharacteristics.h" +#include "ColorBitmap.h" +#include "BitmapBase.h" +#include "ZExcBase.h" +#include "DSSTools.h" + +template +std::shared_ptr CColorMultiBitmapT::CreateNewMemoryBitmap() const +{ + if (static_cast(m_pBitmapModel)) + { + CBitmapCharacteristics bc; + m_pBitmapModel->GetCharacteristics(bc); + if (bc.m_lNrChannels == 3) + return m_pBitmapModel->Clone(true); + else + { + bc.m_lNrChannels = 3; + return CreateBitmap(bc); + } + } + else + return std::make_shared>(); +} + +template +std::shared_ptr CColorMultiBitmapT::CreateOutputMemoryBitmap() const +{ + return std::make_shared>(); +} + +template +bool CColorMultiBitmapT::SetScanLines(CMemoryBitmap* pBitmap, int lLine, const std::vector& vScanLines) +{ + bool bResult = false; + // Each scan line consist of lWidth TType values + TTypeOutput* pRedCurrentValue; + TTypeOutput* pGreenCurrentValue; + TTypeOutput* pBlueCurrentValue; + std::vector vRedValues; + std::vector vGreenValues; + std::vector vBlueValues; + std::vector vWorkingBuffer1; + std::vector vWorkingBuffer2; + std::vector vdWork1; // Used for AutoAdaptiveWeightedAverage + std::vector vdWork2; // Used for AutoAdaptiveWeightedAverage + double fMaximum = pBitmap->GetMaximumValue(); + const int lWidth = pBitmap->RealWidth(); + + std::vector outputScanBuffer; + try { + outputScanBuffer.resize(lWidth * 3); + } + catch (...) { + ZOutOfMemory e("Could not allocate storage for output scanline"); + ZTHROW(e); + } + + pRedCurrentValue = outputScanBuffer.data(); + pGreenCurrentValue = pRedCurrentValue + lWidth; + pBlueCurrentValue = pGreenCurrentValue + lWidth; + + vRedValues.reserve(vScanLines.size()); + vGreenValues.reserve(vScanLines.size()); + vBlueValues.reserve(vScanLines.size()); + vWorkingBuffer1.reserve(vScanLines.size()); + vWorkingBuffer2.reserve(vScanLines.size()); + vdWork1.reserve(vScanLines.size()); + vdWork2.reserve(vScanLines.size()); + + for (int i = 0; i < lWidth; i++) + { + TType* pRedValue; + TType* pGreenValue; + TType* pBlueValue; + + vRedValues.resize(0); + vGreenValues.resize(0); + vBlueValues.resize(0); + for (auto p : vScanLines) + { + pRedValue = static_cast(p) + i; + pGreenValue = pRedValue + lWidth; + pBlueValue = pGreenValue + lWidth; + + if (*pRedValue || !m_vImageOrder.empty()) // Remove 0 + vRedValues.push_back(*pRedValue); + if (*pGreenValue || !m_vImageOrder.empty()) // Remove 0 + vGreenValues.push_back(*pGreenValue); + if (*pBlueValue || !m_vImageOrder.empty()) // Remove 0 + vBlueValues.push_back(*pBlueValue); + } + + if (m_bHomogenization) + { + // if ((i==843) && (lLine==934)) + // DebugBreak(); + + if (static_cast(m_pHomBitmap)) + { + double fAverage, fSigma; + double fRed, fGreen, fBlue; + + fSigma = Sigma2(vRedValues, fAverage); + fRed = fSigma / std::max(1.0, fAverage) * 256.0; + fSigma = Sigma2(vGreenValues, fAverage); + fGreen = fSigma / std::max(1.0, fAverage) * 256.0; + fSigma = Sigma2(vBlueValues, fAverage); + fBlue = fSigma / std::max(1.0, fAverage) * 256.0; + + m_pHomBitmap->SetPixel(i, lLine, fRed, fGreen, fBlue); + } + + if (!m_vImageOrder.empty()) + { + std::vector vAuxRedValues; + std::vector vAuxGreenValues; + std::vector vAuxBlueValues; + // Change the order to respect the order of the images + std::swap(vAuxRedValues, vRedValues); + std::swap(vAuxGreenValues, vGreenValues); + std::swap(vAuxBlueValues, vBlueValues); + for (const size_t imgOrder : m_vImageOrder) + { + if (vAuxRedValues[imgOrder] || vAuxGreenValues[imgOrder] || vAuxBlueValues[imgOrder]) + { + vRedValues.push_back(vAuxRedValues[imgOrder]); + vGreenValues.push_back(vAuxGreenValues[imgOrder]); + vBlueValues.push_back(vAuxBlueValues[imgOrder]); + } + } + + Homogenize(vRedValues, fMaximum); + Homogenize(vGreenValues, fMaximum); + Homogenize(vBlueValues, fMaximum); + } + else + { + Homogenize(vRedValues, fMaximum); + Homogenize(vGreenValues, fMaximum); + Homogenize(vBlueValues, fMaximum); + } + + if (vRedValues.empty() || vGreenValues.empty() || vBlueValues.empty()) + { + vRedValues.resize(0); + vGreenValues.resize(0); + vBlueValues.resize(0); + } + } + else + { + if constexpr (sizeof(TType) == 4 && std::is_integral::value) + { + + for (auto& x : vRedValues) x >>= 16; + for (auto& x : vGreenValues) x >>= 16; + for (auto& x : vBlueValues) x >>= 16; + } + } + + // Process the value + if (m_Method == MBP_MEDIAN) + { + *pRedCurrentValue = Median(vRedValues); + *pGreenCurrentValue = Median(vGreenValues); + *pBlueCurrentValue = Median(vBlueValues); + } + else if (m_Method == MBP_AVERAGE) + { + *pRedCurrentValue = Average(vRedValues); + *pGreenCurrentValue = Average(vGreenValues); + *pBlueCurrentValue = Average(vBlueValues); + } + else if (m_Method == MBP_MAXIMUM) + { + *pRedCurrentValue = Maximum(vRedValues); + *pGreenCurrentValue = Maximum(vGreenValues); + *pBlueCurrentValue = Maximum(vBlueValues); + } + else if (m_Method == MBP_SIGMACLIP) + { + *pRedCurrentValue = KappaSigmaClip(vRedValues, m_fKappa, m_lNrIterations, vWorkingBuffer1); + *pGreenCurrentValue = KappaSigmaClip(vGreenValues, m_fKappa, m_lNrIterations, vWorkingBuffer1); + *pBlueCurrentValue = KappaSigmaClip(vBlueValues, m_fKappa, m_lNrIterations, vWorkingBuffer1); + } + else if (m_Method == MBP_MEDIANSIGMACLIP) + { + *pRedCurrentValue = MedianKappaSigmaClip(vRedValues, m_fKappa, m_lNrIterations, vWorkingBuffer1, vWorkingBuffer2); + *pGreenCurrentValue = MedianKappaSigmaClip(vGreenValues, m_fKappa, m_lNrIterations, vWorkingBuffer1, vWorkingBuffer2); + *pBlueCurrentValue = MedianKappaSigmaClip(vBlueValues, m_fKappa, m_lNrIterations, vWorkingBuffer1, vWorkingBuffer2); + } + else if (m_Method == MBP_AUTOADAPTIVE) + { + *pRedCurrentValue = AutoAdaptiveWeightedAverage(vRedValues, m_lNrIterations, vdWork1); + *pGreenCurrentValue = AutoAdaptiveWeightedAverage(vGreenValues, m_lNrIterations, vdWork1); + *pBlueCurrentValue = AutoAdaptiveWeightedAverage(vBlueValues, m_lNrIterations, vdWork1); + }; + + pRedCurrentValue++; + pGreenCurrentValue++; + pBlueCurrentValue++; + }; + + pBitmap->SetScanLine(lLine, outputScanBuffer.data()); + bResult = true; + + return bResult; +} + +template class CColorMultiBitmapT; +template class CColorMultiBitmapT; +template class CColorMultiBitmapT; +template class CColorMultiBitmapT; +template class CColorMultiBitmapT; + +template class CColorMultiBitmapT; +template class CColorMultiBitmapT; \ No newline at end of file diff --git a/DeepSkyStacker/ColorMultiBitmap.h b/DeepSkyStacker/ColorMultiBitmap.h new file mode 100644 index 000000000..2a1bc07e9 --- /dev/null +++ b/DeepSkyStacker/ColorMultiBitmap.h @@ -0,0 +1,30 @@ +#pragma once +#include "MultiBitmap.h" + +template +class CColorMultiBitmapT : public CMultiBitmap +{ +protected: + virtual std::shared_ptr CreateNewMemoryBitmap() const override; + virtual std::shared_ptr CreateOutputMemoryBitmap() const override; + virtual bool SetScanLines(CMemoryBitmap* pBitmap, int lLine, const std::vector& vScanLines) override; + +public: + CColorMultiBitmapT() + { + }; + + virtual ~CColorMultiBitmapT() + { + }; + + virtual int GetNrChannels() const override + { + return 3; + }; + + virtual int GetNrBytesPerChannel() const override + { + return sizeof(TType); + }; +}; diff --git a/DeepSkyStacker/ColorRef.h b/DeepSkyStacker/ColorRef.h new file mode 100644 index 000000000..cb533a57f --- /dev/null +++ b/DeepSkyStacker/ColorRef.h @@ -0,0 +1,48 @@ +#pragma once + +#pragma pack(push, HDCOLORREFT, 1) + +template +class COLORREFT +{ +public: + TType red; + TType green; + TType blue; + +private: + void CopyFrom(const COLORREFT& cr) + { + red = cr.red; + green = cr.green; + blue = cr.blue; + }; + +public: + COLORREFT(TType r = 0, TType g = 0, TType b = 0) + { + red = r; + green = g; + blue = b; + }; + + COLORREFT(const COLORREFT& cr) + { + CopyFrom(cr); + }; + + COLORREFT& operator = (const COLORREFT& cr) + { + CopyFrom(cr); + return *this; + }; + +}; + +typedef COLORREFT COLORREF8; +typedef COLORREFT COLORREF16; +typedef COLORREFT COLORREF32; +typedef COLORREFT COLORREF32F; + +#pragma pack(pop, HDCOLORREFT) + diff --git a/DeepSkyStacker/CometStacking.cpp b/DeepSkyStacker/CometStacking.cpp index fd619fa3a..c7f24112a 100644 --- a/DeepSkyStacker/CometStacking.cpp +++ b/DeepSkyStacker/CometStacking.cpp @@ -1,15 +1,6 @@ -#include -using std::min; -using std::max; -#include - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include - +#include "stdafx.h" #include "CometStacking.h" #include "ui/ui_CometStacking.h" - -#include "DSSCommon.h" #include "Workspace.h" CometStacking::CometStacking(QWidget *parent) : diff --git a/DeepSkyStacker/CometStacking.h b/DeepSkyStacker/CometStacking.h index 9e56e5ef6..f55cc6b8b 100644 --- a/DeepSkyStacker/CometStacking.h +++ b/DeepSkyStacker/CometStacking.h @@ -1,6 +1,4 @@ -#ifndef COMETSTACKING_H -#define COMETSTACKING_H -#include +#pragma once class QPixmap; @@ -43,5 +41,3 @@ private slots: void updateImage(); }; - -#endif // COMETSTACKING_H diff --git a/DeepSkyStacker/CosmeticEngine.cpp b/DeepSkyStacker/CosmeticEngine.cpp index dba60d172..e590c8104 100644 --- a/DeepSkyStacker/CosmeticEngine.cpp +++ b/DeepSkyStacker/CosmeticEngine.cpp @@ -1,12 +1,16 @@ #include -#include "resource.h" -#include "DSSTools.h" -#include "BitmapExt.h" -#include "DSSProgress.h" +#include #include "CosmeticEngine.h" +#include "MemoryBitmap.h" +#include "Ztrace.h" #include "Multitask.h" -#include +#include "DSSProgress.h" +#include "GrayBitmap.h" +#include "StackingTasks.h" +#include "DSSTools.h" +#include "BitmapExt.h" +using namespace DSS; class CDetectCosmeticTask { @@ -237,7 +241,7 @@ class CCleanCosmeticTask m_lHeight{ pOut->RealHeight() }, m_lColdFilterSize{ pcs.m_lColdFilter }, m_lHotFilterSize{ pcs.m_lHotFilter }, - m_CFAType{ GetCFAType(pOut.get()) }, + m_CFAType{ pOut->GetCFAType() }, m_bMonochrome{ pOut->IsMonochrome() }, m_bCFA{ pOut->IsCFA() } { diff --git a/DeepSkyStacker/CosmeticEngine.h b/DeepSkyStacker/CosmeticEngine.h index 8600c9135..3dcc8c192 100644 --- a/DeepSkyStacker/CosmeticEngine.h +++ b/DeepSkyStacker/CosmeticEngine.h @@ -1,8 +1,6 @@ #ifndef __COSMETICENGINE_H__ #define __COSMETICENGINE_H__ -#include "StackingTasks.h" - class CCosmeticStats { public : @@ -39,6 +37,11 @@ public : }; }; +class CPostCalibrationSettings; +class CMemoryBitmap; +namespace DSS { class ProgressBase; } +using namespace DSS; + std::shared_ptr ApplyCosmetic(std::shared_ptr pBitmap, const CPostCalibrationSettings& pcs, ProgressBase* const pProgress); void SimulateCosmetic(std::shared_ptr pBitmap, const CPostCalibrationSettings& pcs, CCosmeticStats& cs, ProgressBase* const pProgress); diff --git a/DeepSkyStacker/DSS-versionhelpers.h b/DeepSkyStacker/DSS-versionhelpers.h index 09adbd87f..2c00e0be0 100644 --- a/DeepSkyStacker/DSS-versionhelpers.h +++ b/DeepSkyStacker/DSS-versionhelpers.h @@ -9,6 +9,7 @@ * * ******************************************************************/ #include +#include #ifdef _MSC_VER #pragma once diff --git a/DeepSkyStacker/DSSCommon.h b/DeepSkyStacker/DSSCommon.h index 09505b467..027ee50e8 100644 --- a/DeepSkyStacker/DSSCommon.h +++ b/DeepSkyStacker/DSSCommon.h @@ -1,5 +1,4 @@ -#ifndef __DSSCOMMON_H__ -#define __DSSCOMMON_H__ +#pragma once constexpr auto PI = 3.14159265358979323846; @@ -144,10 +143,4 @@ enum class Column #define VERSION_LIBTIFF "4.0.9" #define VERSION_CFITSIO "3.43" -#define NEWENGINE - -#ifndef PCL_PROJECT -#define DSSFILEDECODING 1 -#endif - -#endif \ No newline at end of file +#define NEWENGINE \ No newline at end of file diff --git a/DeepSkyStacker/DSSProgress.cpp b/DeepSkyStacker/DSSProgress.cpp index 655208fb2..02b1099d4 100644 --- a/DeepSkyStacker/DSSProgress.cpp +++ b/DeepSkyStacker/DSSProgress.cpp @@ -1,6 +1,5 @@ #include #include "DSSProgress.h" -#include "boost/winapi/time.hpp" #include "Multitask.h" using namespace DSS; diff --git a/DeepSkyStacker/DSSProgress.h b/DeepSkyStacker/DSSProgress.h index 854ac5e7b..05059f45a 100644 --- a/DeepSkyStacker/DSSProgress.h +++ b/DeepSkyStacker/DSSProgress.h @@ -1,9 +1,4 @@ -#ifndef _DSSPROGRESS_H__ -#define _DSSPROGRESS_H__ -#include -#include - -/* ------------------------------------------------------------------- */ +#pragma once namespace DSS { @@ -85,6 +80,3 @@ namespace DSS virtual void applyProcessorsUsed(int nCount) = 0; }; } -/* ------------------------------------------------------------------- */ - -#endif // _DSSPROGRESS_H__ \ No newline at end of file diff --git a/DeepSkyStacker/DSSTools.cpp b/DeepSkyStacker/DSSTools.cpp new file mode 100644 index 000000000..39665c8cc --- /dev/null +++ b/DeepSkyStacker/DSSTools.cpp @@ -0,0 +1,2 @@ +#include "stdafx.h" +#include "DSSTools.h" diff --git a/DeepSkyStacker/DSSTools.h b/DeepSkyStacker/DSSTools.h index 6270d0b99..41712dbb3 100644 --- a/DeepSkyStacker/DSSTools.h +++ b/DeepSkyStacker/DSSTools.h @@ -1,179 +1,14 @@ -#ifndef __DSSTOOLS_H__ -#define __DSSTOOLS_H__ - -#include -#include -#include -//#include -#include -#include - +#pragma once +#include "FlatPart.h" +#include "DynamicStats.h" #include "avx_median.h" /* ------------------------------------------------------------------- */ -inline bool GetFileCreationDateTime(LPCTSTR szFileName, FILETIME & FileTime) -{ - bool bResult = false; - HANDLE hFind; - WIN32_FIND_DATA FindData; - - hFind = FindFirstFile(szFileName, &FindData); - if (hFind != INVALID_HANDLE_VALUE) - { - FileTime = FindData.ftLastWriteTime; - FindClose(hFind); - bResult = true; - }; - - return bResult; -}; /* ------------------------------------------------------------------- */ -class CLinearInterpolation -{ -private : - double xm, - a0, b0, - a1, b1; - -public : - CLinearInterpolation() noexcept - { - xm = 0; - a0 = b0 = a1 = b1 = 0; - }; - - CLinearInterpolation(const CLinearInterpolation&) = default; - - CLinearInterpolation(CLinearInterpolation&&) = default; - - CLinearInterpolation& operator = (const CLinearInterpolation&) = default; - - double Interpolate(double x) const noexcept - { - if (x(this->xm); } - float getParameterA0() const noexcept { return static_cast(this->a0); } - float getParameterA1() const noexcept { return static_cast(this->a1); } - float getParameterB0() const noexcept { return static_cast(this->b0); } - float getParameterB1() const noexcept { return static_cast(this->b1); } -}; - -/* - y = a0 x + b0 // when x < x1 - y = a1 x + b1 // when x >= x1 - - y0 = a0 x0 + b0 - y1 = a0 x1 + b0 - - a0 = (y0-y1)/(x0-x1) - b0 = y0 - a0 x0 - - y1 = a1 x1 + b1 - y2 = a1 x2 + b1 - - a1 = (y1-y2)/(x1-x2) - b1 = y1 - a1 x1 -*/ - -/* ------------------------------------------------------------------- */ - -class CRationalInterpolation -{ -private : - double a, b, c; - double fMin, fMax; - -private : - -public : - CRationalInterpolation() - { - a = b = 0; - c = 1; - fMin = 0; - fMax = 0; - }; - - CRationalInterpolation(const CRationalInterpolation&) = default; - - CRationalInterpolation& operator = (const CRationalInterpolation&) = default; - - double Interpolate(double x) const noexcept - { - if (b || c) - return std::max(std::min((x+a)/(b*x+c), fMax), fMin); - else - return std::max(std::min(x+a, fMax), fMin); - }; - - void Initialize(double x0, double x1, double x2, double y0, double y1, double y2) noexcept - { - double t1 = ((x0*y0 - x1*y1)*(y0-y2) - (x0*y0 - x2*y2)*(y0-y1)); - double t2 = ((x0-x1)*(y0-y2) - (x0-x2)*(y0-y1)); - double t3 = (y0-y1); - - if (t1) - b = t2/t1; - else - b = 0; - if (t3) - c = ((x0-x1)-b*(x0*y0 - x1*y1))/t3; - else - c = 0; - a = (b*x0 +c )*y0 - x0; - - fMin = std::min(std::min(y0, y1), y2); - fMax = std::max(std::max(y0, y1), y2); - }; - - float getParameterA() const noexcept { return static_cast(this->a); } - float getParameterB() const noexcept { return static_cast(this->b); } - float getParameterC() const noexcept { return static_cast(this->c); } - float getParameterMin() const noexcept { return static_cast(this->fMin); } - float getParameterMax() const noexcept { return static_cast(this->fMax); } -}; - -/* -(x0+a) = (b x0 +c ) y0; -(x1+a) = (b x1 +c ) y1; -(x2+a) = (b x2 +c ) y2; - -x0-x1 = b (x0 y0 - x1 y1) + c(y0-y1) -x0-x2 = b (x0 y0 - x2 y2) + c(y0-y2) - -(x0-x1)(y0-y2) - (x0-x2)(y0-y1) = b ((x0 y0 - x1 y1) (y0-y2) - (x0 y0 - x2 y2) (y0-y1)) - -b = ((x0-x1)(y0-y2) - (x0-x2)(y0-y1))/((x0 y0 - x1 y1) (y0-y2) - (x0 y0 - x2 y2) (y0-y1)); -c = ((x0-x1)-b (x0 y0 - x1 y1))/(y0-y1); -a = (b x0 +c ) y0 - x0; -*/ -/* ------------------------------------------------------------------- */ typedef std::vector POINTFVECTOR; typedef POINTFVECTOR::iterator POINTFITERATOR; @@ -192,76 +27,6 @@ inline double Distance(const QPointF& pt1, const QPointF& pt2) noexcept /* ------------------------------------------------------------------- */ -class CDynamicStats -{ -public : - int m_lNrValues; - double m_fSum; - double m_fPowSum; - double m_fMin, - m_fMax; - -public : - CDynamicStats() - { - m_lNrValues = 0; - m_fSum = 0; - m_fPowSum = 0; - m_fMin = 0; - m_fMax = 0; - }; - virtual ~CDynamicStats() {}; - - void AddValue(double fValue, int lNrValues = 1) noexcept - { - if (!m_lNrValues) - { - m_fMin = m_fMax = fValue; - } - else - { - m_fMin = std::min(m_fMin, fValue); - m_fMax = std::max(m_fMax, fValue); - }; - m_lNrValues+=lNrValues; - m_fPowSum += (fValue*fValue)*lNrValues; - m_fSum += fValue*lNrValues; - }; - - void RemoveValue(double fValue, int lNrValues = 1) noexcept - { - m_lNrValues-=lNrValues; - m_fPowSum -= (fValue*fValue)*lNrValues; - m_fSum -= fValue*lNrValues; - }; - - double Average() noexcept - { - if (m_lNrValues) - return m_fSum/(double)m_lNrValues; - else - return 0; - }; - - double Sigma() noexcept - { - if (m_lNrValues) - return sqrt(m_fPowSum/m_lNrValues - pow(m_fSum/m_lNrValues, 2)); - else - return 0; - }; - - double Min() noexcept - { - return m_fMin; - }; - - double Max() noexcept - { - return m_fMax; - }; -}; - /* ------------------------------------------------------------------- */ inline double Median(double v1, double v2, double v3) noexcept @@ -394,65 +159,9 @@ double CalculateSigmaFromAverage(const std::vector& values, const double targ /* ------------------------------------------------------------------- */ -template inline -void FillDynamicStat(const std::vector & vValues, CDynamicStats & DynStats) -{ - for (int i = 0;ifp.Score(); - /* - if (Length() > fp.Length()) - return true; - else if (Length() < fp.Length()) - return false; - else - return m_fAverage < fp.m_fAverage;*/ - }; -}; /* ------------------------------------------------------------------- */ @@ -1062,356 +771,3 @@ double AutoAdaptiveWeightedAverage(const std::vector & vValues, int lIteratio return fResult; }; - -/* ------------------------------------------------------------------- */ - -typedef enum TRANSFORMATIONTYPE -{ - TT_LINEAR = 0, - TT_BILINEAR = 1, - TT_BISQUARED = 2, - TT_BICUBIC = 3, - TT_NONE = 4, - TT_LAST = 5 -} TRANSFORMATIONTYPE; - -class CBilinearParameters -{ -public: - TRANSFORMATIONTYPE Type; - double a0, a1, a2, a3; - double a4, a5, a6, a7, a8; - double a9, a10, a11, a12, a13, a14, a15; - double b0, b1, b2, b3; - double b4, b5, b6, b7, b8; - double b9, b10, b11, b12, b13, b14, b15; - - double fXWidth, fYWidth; - -private: - bool GetNextParameter(CString& strParameters, double& fValue) const - { - bool bResult = false; - int nPos; - CString strValue; - - if (strParameters.GetLength()) - { - nPos = strParameters.Find(_T(",")); - if (nPos >= 0) - strValue = strParameters.Left(nPos); - else - strValue = strParameters; - - fValue = _ttof((LPCTSTR)strValue); // Change _ttof to _ttof for Unicode - strParameters = strParameters.Right(std::max(0, strParameters.GetLength() - strValue.GetLength() - 1)); - bResult = true; - }; - - return bResult; - }; - -public : - CBilinearParameters() - { - Clear(); - } - - CBilinearParameters(const CBilinearParameters& bp) = default; - - CBilinearParameters& operator=(const CBilinearParameters& bp) = default; - - void Clear() noexcept - { - Type = TT_BILINEAR; - a0 = a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0.0; - a9 = a10 = a11 = a12 = a13 = a14 = a15 = 0.0; - b0 = b1 = b2 = b3 = b4 = b5 = b6 = b7 = b8 = 0.0; - b9 = b10 = b11 = b12 = b13 = b14 = b15 = 0.0; - a1 = 1.0; // to have x' = x - b2 = 1.0; // to have y' = y - - fXWidth = fYWidth = 1.0; - } - - void ToText(CString& strText) const - { - if (Type == TT_NONE) - { - strText.Format(_T("None(%.20g,%.20g)"), fXWidth, fYWidth); - } - else if (Type == TT_BICUBIC) - { - CString strText1; - - strText1.Format(_T("Bicubic(%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,"), - a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15); - strText = strText1; - - strText1.Format(_T("%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,"), - b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15); - strText += strText1; - strText1.Format(_T("%.20g,%.20g)"), - fXWidth, fYWidth); - strText += strText1; - } - else if (Type == TT_BISQUARED) - { - CString strText1; - - strText1.Format(_T("Bisquared(%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,"), - a0, a1, a2, a3, a4, a5, a6, a7, a8); - strText = strText1; - - strText1.Format(_T("%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g)"), - b0, b1, b2, b3, b4, b5, b6, b7, b8, - fXWidth, fYWidth); - strText += strText1; - } - else - { - strText.Format(_T("Bilinear(%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g,%.20g)"), - a0, a1, a2, a3, - b0, b1, b2, b3, - fXWidth, fYWidth); - }; - } - - bool FromText(LPCTSTR szText) - { - bool bResult = false; - CString strText = szText; - int nPos1, - nPos2; - - nPos1 = strText.Find(_T("(")); - nPos2 = strText.Find(_T(")")); - if (nPos1>=0 && nPos2>nPos1) - { - CString strType; - CString strParameters; - - strType = strText.Left(nPos1); - strParameters = strText.Mid(nPos1+1, nPos2-nPos1-1); - if (!strType.CompareNoCase(_T("None"))) - { - Clear(); - Type = TT_NONE; - bResult = GetNextParameter(strParameters, fXWidth) && - GetNextParameter(strParameters, fYWidth); - } - else if (!strType.CompareNoCase(_T("Bilinear"))) - { - Type = TT_BILINEAR; - bResult = GetNextParameter(strParameters, a0) && - GetNextParameter(strParameters, a1) && - GetNextParameter(strParameters, a2) && - GetNextParameter(strParameters, a3) && - GetNextParameter(strParameters, b0) && - GetNextParameter(strParameters, b1) && - GetNextParameter(strParameters, b2) && - GetNextParameter(strParameters, b3) && - GetNextParameter(strParameters, fXWidth) && - GetNextParameter(strParameters, fYWidth); - } - else if (!strType.CompareNoCase(_T("Bisquared"))) - { - Type = TT_BISQUARED; - bResult = GetNextParameter(strParameters, a0) && - GetNextParameter(strParameters, a1) && - GetNextParameter(strParameters, a2) && - GetNextParameter(strParameters, a3) && - GetNextParameter(strParameters, a4) && - GetNextParameter(strParameters, a5) && - GetNextParameter(strParameters, a6) && - GetNextParameter(strParameters, a7) && - GetNextParameter(strParameters, a8) && - GetNextParameter(strParameters, b0) && - GetNextParameter(strParameters, b1) && - GetNextParameter(strParameters, b2) && - GetNextParameter(strParameters, b3) && - GetNextParameter(strParameters, b4) && - GetNextParameter(strParameters, b5) && - GetNextParameter(strParameters, b6) && - GetNextParameter(strParameters, b7) && - GetNextParameter(strParameters, b8) && - GetNextParameter(strParameters, fXWidth) && - GetNextParameter(strParameters, fYWidth); - } - else if (!strType.CompareNoCase(_T("Bicubic"))) - { - Type = TT_BICUBIC; - bResult = GetNextParameter(strParameters, a0) && - GetNextParameter(strParameters, a1) && - GetNextParameter(strParameters, a2) && - GetNextParameter(strParameters, a3) && - GetNextParameter(strParameters, a4) && - GetNextParameter(strParameters, a5) && - GetNextParameter(strParameters, a6) && - GetNextParameter(strParameters, a7) && - GetNextParameter(strParameters, a8) && - GetNextParameter(strParameters, a9) && - GetNextParameter(strParameters, a10) && - GetNextParameter(strParameters, a11) && - GetNextParameter(strParameters, a12) && - GetNextParameter(strParameters, a13) && - GetNextParameter(strParameters, a14) && - GetNextParameter(strParameters, a15) && - GetNextParameter(strParameters, b0) && - GetNextParameter(strParameters, b1) && - GetNextParameter(strParameters, b2) && - GetNextParameter(strParameters, b3) && - GetNextParameter(strParameters, b4) && - GetNextParameter(strParameters, b5) && - GetNextParameter(strParameters, b6) && - GetNextParameter(strParameters, b7) && - GetNextParameter(strParameters, b8) && - GetNextParameter(strParameters, b9) && - GetNextParameter(strParameters, b10) && - GetNextParameter(strParameters, b11) && - GetNextParameter(strParameters, b12) && - GetNextParameter(strParameters, b13) && - GetNextParameter(strParameters, b14) && - GetNextParameter(strParameters, b15) && - GetNextParameter(strParameters, fXWidth) && - GetNextParameter(strParameters, fYWidth); - }; - }; - - return bResult; - } - -#if (0) - CPointExt Transform(const CPointExt& pt) const - { - CPointExt ptResult; - - if (Type == TT_BICUBIC) - { - double X = pt.X/fXWidth; - double X2 = X * X; - double X3 = X * X * X; - double Y = pt.Y/fYWidth; - double Y2 = Y * Y; - double Y3 = Y * Y * Y; - - ptResult.X = a0 + a1 * X + a2 * Y + a3 * X * Y - + a4 * X2 + a5 * Y2 + a6 * X2 * Y + a7 * X * Y2 + a8 * X2 * Y2 - + a9 * X3 + a10 * Y3 + a11 * X3 * Y + a12 * X * Y3 + a13 * X3 * Y2 + a14 * X2 * Y3 + a15 * X3 * Y3; - ptResult.Y = b0 + b1 * X + b2 * Y + b3 * X * Y - + b4 * X2 + b5 * Y2 + b6 * X2 * Y + b7 * X * Y2 + b8 * X2 * Y2 - + b9 * X3 + b10 * Y3 + b11 * X3 * Y + b12 * X * Y3 + b13 * X3 * Y2 + b14 * X2 * Y3 + b15 * X3 * Y3; - } - else if (Type == TT_BISQUARED) - { - double X = pt.X/fXWidth; - double X2 = X * X; - double Y = pt.Y/fYWidth; - double Y2 = Y * Y; - - ptResult.X = a0 + a1 * X + a2 * Y + a3 * X * Y - + a4 * X2 + a5 * Y2 + a6 * X2 * Y + a7 * X * Y2 + a8 * X2 * Y2; - ptResult.Y = b0 + b1 * X + b2 * Y + b3 * X * Y - + b4 * X2 + b5 * Y2 + b6 * X2 * Y + b7 * X * Y2 + b8 * X2 * Y2; - } - else - { - double X = pt.X / fXWidth; - double Y = pt.Y / fYWidth; - - ptResult.X = a0 + a1 * X + a2 * Y + a3 * X * Y; - ptResult.Y = b0 + b1 * X + b2 * Y + b3 * X * Y; - }; - - ptResult.X *= fXWidth; - ptResult.Y *= fYWidth; - - return ptResult; - } -#endif - - QPointF transform(const QPointF& pt) const noexcept - { - QPointF ptResult; - qreal& x = ptResult.rx(); - qreal& y = ptResult.ry(); - - - if (Type == TT_BICUBIC) - { - qreal X = pt.x() / fXWidth; - qreal X2 = X * X; - qreal X3 = X * X * X; - qreal Y = pt.y() / fYWidth; - qreal Y2 = Y * Y; - qreal Y3 = Y * Y * Y; - - x = a0 + a1 * X + a2 * Y + a3 * X * Y - + a4 * X2 + a5 * Y2 + a6 * X2 * Y + a7 * X * Y2 + a8 * X2 * Y2 - + a9 * X3 + a10 * Y3 + a11 * X3 * Y + a12 * X * Y3 + a13 * X3 * Y2 + a14 * X2 * Y3 + a15 * X3 * Y3; - y = b0 + b1 * X + b2 * Y + b3 * X * Y - + b4 * X2 + b5 * Y2 + b6 * X2 * Y + b7 * X * Y2 + b8 * X2 * Y2 - + b9 * X3 + b10 * Y3 + b11 * X3 * Y + b12 * X * Y3 + b13 * X3 * Y2 + b14 * X2 * Y3 + b15 * X3 * Y3; - } - else if (Type == TT_BISQUARED) - { - qreal X = pt.x() / fXWidth; - qreal X2 = X * X; - qreal Y = pt.y() / fYWidth; - qreal Y2 = Y * Y; - - x = a0 + a1 * X + a2 * Y + a3 * X * Y - + a4 * X2 + a5 * Y2 + a6 * X2 * Y + a7 * X * Y2 + a8 * X2 * Y2; - y = b0 + b1 * X + b2 * Y + b3 * X * Y - + b4 * X2 + b5 * Y2 + b6 * X2 * Y + b7 * X * Y2 + b8 * X2 * Y2; - } - else - { - qreal X = pt.x() / fXWidth; - qreal Y = pt.y() / fYWidth; - - x = a0 + a1 * X + a2 * Y + a3 * X * Y; - y = b0 + b1 * X + b2 * Y + b3 * X * Y; - }; - - x *= fXWidth; - y *= fYWidth; - - return ptResult; - } - - double Angle(int lWidth) const noexcept - { - double fAngle; - QPointF pt1 (0, 0), - pt2 (lWidth, 0); - - pt1 = transform(pt1); - pt2 = transform(pt2); - - fAngle = atan2(pt2.y() - pt1.y(), pt2.x() - pt1.x()); - - return fAngle; - } - - void Offsets(double& dX, double& dY) const noexcept - { - dX = a0 * fXWidth; - dY = b0 * fYWidth; - } - - void Footprint(QPointF& pt1, QPointF& pt2, QPointF& pt3, QPointF& pt4) const noexcept - { - pt1.rx() = pt1.ry() = 0; - pt2.rx() = fXWidth; pt2.ry() = 0; - pt3.rx() = fXWidth; pt3.ry() = fYWidth; - pt4.rx() = 0; pt4.ry() = fYWidth; - - pt1 = transform(pt1); - pt2 = transform(pt2); - pt3 = transform(pt3); - pt4 = transform(pt4); - } -}; - -#endif // __DSSTOOLS_H__ diff --git a/DeepSkyStacker/DarkFrame.cpp b/DeepSkyStacker/DarkFrame.cpp index bc00b15c2..7d51c08d2 100644 --- a/DeepSkyStacker/DarkFrame.cpp +++ b/DeepSkyStacker/DarkFrame.cpp @@ -1,25 +1,21 @@ #include -#include -#include #include -#include -#include - -#include "resource.h" -#include "dssrect.h" #include "DarkFrame.h" - +#include "Ztrace.h" #include "DSSProgress.h" -#include "Histogram.h" +#include "MemoryBitmap.h" #include "Filters.h" +#include "Histogram.h" #include "BitmapIterator.h" - -#include "TIFFUtil.h" +#include "Multitask.h" +#include "CFABitmapInfo.h" +#include "StackingTasks.h" #if QT_VERSION < 0x060000 #define _USE_MATH_DEFINES #endif -#include + +using namespace DSS; /* ------------------------------------------------------------------- */ @@ -1962,3 +1958,15 @@ bool CDarkFrame::Subtract(std::shared_ptr pTarget, ProgressBase* return true; } + +void CDarkFrame::Reset(std::shared_ptr pMaster) +{ + m_bDarkOptimization = CAllStackingTasks::GetDarkOptimization(); + m_bHotPixelsDetection = CAllStackingTasks::GetHotPixelsDetection(); + m_bBadLinesDetection = CAllStackingTasks::GetBadLinesDetection(); + m_fDarkFactor = CAllStackingTasks::GetDarkFactor(); + m_bHotPixelDetected = false; + m_pMasterDark = pMaster; + m_vHotPixels.clear(); +} + diff --git a/DeepSkyStacker/DarkFrame.h b/DeepSkyStacker/DarkFrame.h index bbc621345..2beebf07f 100644 --- a/DeepSkyStacker/DarkFrame.h +++ b/DeepSkyStacker/DarkFrame.h @@ -1,11 +1,9 @@ -#ifndef __DARKFRAME_H__ -#define __DARKFRAME_H__ - -#include "BitmapExt.h" -#include "StackingTasks.h" -#include -#include +#pragma once +#include "dssrect.h" #include "Stars.h" +#include "Bayer.h" + +namespace DSS { class ProgressBase; } /* ------------------------------------------------------------------- */ @@ -133,7 +131,7 @@ typedef std::set EXCLUDEDPIXELSET; typedef EXCLUDEDPIXELSET::iterator EXCLUDEDPIXELITERATOR; /* ------------------------------------------------------------------- */ - +class CMemoryBitmap; class CDarkFrameHotParameters { public: @@ -222,30 +220,21 @@ private : CDarkFrameHotParameters m_HotParameters; CDarkAmpGlowParameters m_AmpglowParameters; - void Reset(std::shared_ptr pMaster) - { - m_bDarkOptimization = CAllStackingTasks::GetDarkOptimization(); - m_bHotPixelsDetection = CAllStackingTasks::GetHotPixelsDetection(); - m_bBadLinesDetection = CAllStackingTasks::GetBadLinesDetection(); - m_fDarkFactor = CAllStackingTasks::GetDarkFactor(); - m_bHotPixelDetected = false; - m_pMasterDark = pMaster; - m_vHotPixels.clear(); - } + void Reset(std::shared_ptr pMaster); void FillExcludedPixelList(const STARVECTOR * pStars, EXCLUDEDPIXELVECTOR & vExcludedPixels); void GetValidNeighbors(int lX, int lY, HOTPIXELVECTOR & vPixels, int lRadius, BAYERCOLOR BayerColor = BAYER_UNKNOWN); protected : - void ComputeOptimalDistributionRatio(CMemoryBitmap * pBitmap, CMemoryBitmap * pDark, double & fRatio, ProgressBase * pProgress); + void ComputeOptimalDistributionRatio(CMemoryBitmap * pBitmap, CMemoryBitmap * pDark, double & fRatio, DSS::ProgressBase * pProgress); - void ComputeDarkFactorFromMedian(CMemoryBitmap * pBitmap, double & fHotDark, double & fAmpGlow, ProgressBase * pProgress); - void ComputeDarkFactor(CMemoryBitmap * pBitmap, STARVECTOR * pStars, double & fRedFactor, double & fGreenFactor, double & fBlueFactor, ProgressBase * pProgress); + void ComputeDarkFactorFromMedian(CMemoryBitmap * pBitmap, double & fHotDark, double & fAmpGlow, DSS::ProgressBase * pProgress); + void ComputeDarkFactor(CMemoryBitmap * pBitmap, STARVECTOR * pStars, double & fRedFactor, double & fGreenFactor, double & fBlueFactor, DSS::ProgressBase * pProgress); void ComputeDarkFactorFromHotPixels(CMemoryBitmap * pBitmap, STARVECTOR * pStars, double & fRedFactor, double & fGreenFactor, double & fBlueFactor); void RemoveContiguousHotPixels(bool bCFA); - void FindHotPixels(ProgressBase * pProgress); - void FindBadVerticalLines(ProgressBase * pProgress); + void FindHotPixels(DSS::ProgressBase* pProgress); + void FindBadVerticalLines(DSS::ProgressBase* pProgress); public : CDarkFrame(std::shared_ptr pMaster = std::shared_ptr{}) @@ -262,8 +251,8 @@ public : //m_pMasterDark = pMaster; // pMaster.Addref(); m_pMasterDark.m_p->Release(); m_pMasterDark.m_p = pMaster; } - bool Subtract(std::shared_ptr pTarget, ProgressBase * pProgress = nullptr); - void InterpolateHotPixels(std::shared_ptr pBitmap, ProgressBase * pProgress = nullptr); + bool Subtract(std::shared_ptr pTarget, DSS::ProgressBase* pProgress = nullptr); + void InterpolateHotPixels(std::shared_ptr pBitmap, DSS::ProgressBase* pProgress = nullptr); bool IsOk() const { @@ -271,5 +260,3 @@ public : return static_cast(this->m_pMasterDark); } }; - -#endif // __DARKFRAME_H__ diff --git a/DeepSkyStacker/DeBloom.cpp b/DeepSkyStacker/DeBloom.cpp index 3bc3b646d..bf38f3dce 100644 --- a/DeepSkyStacker/DeBloom.cpp +++ b/DeepSkyStacker/DeBloom.cpp @@ -1,14 +1,16 @@ #include -#include "resource.h" #include "DeBloom.h" -#include "TIFFUtil.h" -#include "Filters.h" +#include "GrayBitmap.h" +#include "DSSTools.h" +#include "DSSProgress.h" #include "BackgroundCalibration.h" +#include "Ztrace.h" #if QT_VERSION < 0x060000 #define _USE_MATH_DEFINES #endif -#include + +using namespace DSS; #ifdef DSSBETA //#define DEBUGDEBLOOM diff --git a/DeepSkyStacker/DeBloom.h b/DeepSkyStacker/DeBloom.h index dcb909dd2..6382fdf05 100644 --- a/DeepSkyStacker/DeBloom.h +++ b/DeepSkyStacker/DeBloom.h @@ -1,9 +1,5 @@ -#ifndef __DEBLOOM_H__ -#define __DEBLOOM_H__ - -#include "DSSProgress.h" -#include "DSSTools.h" -#include "BitmapExt.h" +#pragma once +#include "GrayBitmap.h" /* ------------------------------------------------------------------- */ @@ -159,7 +155,8 @@ public : }; /* ------------------------------------------------------------------- */ - +namespace DSS { class ProgressBase; } +class CMemoryBitmap; class CDeBloom { private: @@ -168,7 +165,7 @@ class CDeBloom int m_lWidth; int m_lHeight; std::shared_ptr m_pMask; - ProgressBase* m_pProgress; + DSS::ProgressBase* m_pProgress; double m_fBackground; bool IsLeftEdge(CMemoryBitmap * pBitmap, int x, int y); @@ -205,8 +202,6 @@ class CDeBloom virtual ~CDeBloom() {}; - void CreateBloomMask(CMemoryBitmap* pBitmap, ProgressBase* pProgress); - void DeBloomImage(CMemoryBitmap* pBitmap, ProgressBase* pProgress); + void CreateBloomMask(CMemoryBitmap* pBitmap, DSS::ProgressBase* pProgress); + void DeBloomImage(CMemoryBitmap* pBitmap, DSS::ProgressBase* pProgress); }; - -#endif diff --git a/DeepSkyStacker/DeepSkyStacker.cpp b/DeepSkyStacker/DeepSkyStacker.cpp index 735a68b74..11270f1eb 100644 --- a/DeepSkyStacker/DeepSkyStacker.cpp +++ b/DeepSkyStacker/DeepSkyStacker.cpp @@ -35,55 +35,29 @@ ****************************************************************************/ // DeepSkyStacker.cpp : Defines the entry point for the console application. // +#include +#include -#include "stdafx.h" +#include "DeepSkyStacker.h" -#include -#include #include #include namespace bip = boost::interprocess; -#include -using namespace Gdiplus; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#include "QMfcApp" - -#include "qwinhost.h" - -#include "DeepSkyStacker.h" -//#include "DeepStack.h" -#include "picturelist.h" - -#include -#include "StackingTasks.h" #include "ui_StackingDlg.h" -#include "StackRecap.h" -#include "SetUILanguage.h" -//#include "StackWalker.h" -#include -#if !defined(_WINDOWS) -#include -#endif +#include "Ztrace.h" +#include "StackingTasks.h" +#include "StackingDlg.h" +#include "ExplorerBar.h" +#include "picturelist.h" +#include "resource.h" +#include "commonresource.h" +#include "ProcessingDlg.h" #include "ExceptionHandling.h" -#include "DSSVersion.h" +#include "SetUILanguage.h" +#include "qwinhost.h" +#include "DeepStack.h" -#pragma comment(lib, "gdiplus.lib") -#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") CString OUTPUTFILE_FILTERS; CString OUTPUTLIST_FILTERS; @@ -91,8 +65,6 @@ CString SETTINGFILE_FILTERS; CString STARMASKFILE_FILTERS; bool g_bShowRefStars = false; -#include -#include //class DSSStackWalker : public StackWalker //{ @@ -331,14 +303,14 @@ void DeepSkyStacker::onInitialise() stackedWidget->addWidget(winHost); ZTRACE_RUNTIME("Creating Processing Panel"); - auto result = processingDlg.Create(IDD_PROCESSING); + auto result = processingDlg->Create(IDD_PROCESSING); if (FALSE == result) { int lastErr = GetLastError(); ZTRACE_RUNTIME("lastErr = %d", lastErr); } - HWND hwnd{ processingDlg.GetSafeHwnd() }; + HWND hwnd{ processingDlg->GetSafeHwnd() }; Q_ASSERT(NULL != hwnd); winHost->setWindow(hwnd); @@ -410,8 +382,8 @@ void DeepSkyStacker::onInitialise() void DeepSkyStacker::closeEvent(QCloseEvent* e) { ZFUNCTRACE_RUNTIME(); - processingDlg.SaveOnClose(); - processingDlg.DestroyWindow(); + processingDlg->SaveOnClose(); + processingDlg->DestroyWindow(); stackingDlg->saveOnClose(); ZTRACE_RUNTIME("Saving Window State and Position"); @@ -459,10 +431,90 @@ DeepSkyStacker::DeepSkyStacker() : statusBarText{ new QLabel("") } { + processingDlg = std::make_unique(); + m_DeepStack = std::make_unique(); + m_Settings = std::make_unique(); ZFUNCTRACE_RUNTIME(); setAcceptDrops(true); } +void DeepSkyStacker::disableSubDialogs() +{ + stackingDlg->setEnabled(false); + processingDlg->EnableWindow(false); + //m_dlgLibrary.EnableWindow(false); + explorerBar->setEnabled(false); +} + +void DeepSkyStacker::enableSubDialogs() +{ + stackingDlg->setEnabled(true); + processingDlg->EnableWindow(true); + //m_dlgLibrary.EnableWindow(true); + explorerBar->setEnabled(true); +} + +CDSSSettings& DeepSkyStacker::settings() +{ + if (!m_Settings->IsLoaded()) + m_Settings->Load(); + + return *m_Settings.get(); +} + +DSS::StackingDlg& DeepSkyStacker::getStackingDlg() +{ + return *stackingDlg; +} + +CProcessingDlg& DeepSkyStacker::getProcessingDlg() +{ + return *processingDlg.get(); +} + +CDeepStack& DeepSkyStacker::deepStack() +{ + return *m_DeepStack.get(); +} + +QString DeepSkyStacker::statusMessage() +{ + return statusBarText->text(); +} + +void DeepSkyStacker::setInstance(DeepSkyStacker* instance) +{ + ZASSERT(nullptr == theMainWindow); + theMainWindow = instance; +} + +void DeepSkyStacker::setTab(std::uint32_t dwTabID) +{ + if (dwTabID == IDD_REGISTERING) + dwTabID = IDD_STACKING; + //#ifdef DSSBETA + // if (dwTabID == IDD_STACKING && (GetAsyncKeyState(VK_CONTROL) & 0x8000)) + // dwTabID = IDD_LIBRARY; + //#endif + currTab = dwTabID; + updateTab(); +} + +ExplorerBar& DeepSkyStacker::GetExplorerBar() +{ + return *explorerBar; +} + +void DeepSkyStacker::setWindowFilePath(const QString& name) +{ + if (currentPathName == name) return; + currentPathName = name; + if (!name.isEmpty()) + setWindowTitle(QString("%1 - %2").arg(baseTitle).arg(name)); + else + setWindowTitle(baseTitle); +} + void DeepSkyStacker::updateTab() { switch (currTab) @@ -476,7 +528,7 @@ void DeepSkyStacker::updateTab() case IDD_PROCESSING: stackedWidget->setCurrentIndex(1); stackingDlg->showImageList(false); - processingDlg.ShowWindow(SW_SHOW); + processingDlg->ShowWindow(SW_SHOW); break; }; explorerBar->update(); diff --git a/DeepSkyStacker/DeepSkyStacker.h b/DeepSkyStacker/DeepSkyStacker.h index f41b9bf33..a64d48735 100644 --- a/DeepSkyStacker/DeepSkyStacker.h +++ b/DeepSkyStacker/DeepSkyStacker.h @@ -1,4 +1,3 @@ - #pragma once /**************************************************************************** ** @@ -35,24 +34,18 @@ ** ** ****************************************************************************/ -#include -#include -#include -#include - -#include "ExplorerBar.h" -class QSplitter; -class QStackedWidget; -#include "StackingDlg.h" -class QWinHost; - namespace DSS { class PictureList; + class StackingDlg; } - -#include "ProcessingDlg.h" -#include "dss_settings.h" +class ExplorerBar; +class QStackedWidget; +class QStackedWidget; +class QWinHost; +class CProcessingDlg; +class CDSSSettings; +class CDeepStack; class DeepSkyStacker : public QMainWindow @@ -73,17 +66,14 @@ protected slots: QStackedWidget* stackedWidget; DSS::StackingDlg* stackingDlg; QWinHost* winHost; - - CProcessingDlg processingDlg; - - CDeepStack m_DeepStack; - CDSSSettings m_Settings; - std::uint32_t currTab; - QStringList args; - QString baseTitle; + std::unique_ptr processingDlg; + std::unique_ptr m_DeepStack; + std::unique_ptr m_Settings; + std::uint32_t currTab; + QStringList args; + QString baseTitle; QString currentPathName; - //ITaskbarList3* m_taskbarList; - bool m_progress; + bool m_progress; QLabel* statusBarText; void createStatusBar(); @@ -100,105 +90,25 @@ protected slots: void onInitialise(); public: - inline static DeepSkyStacker* instance() - { - return theMainWindow; - } - - inline static void setInstance(DeepSkyStacker* instance) - { - ZASSERT(nullptr == theMainWindow); - theMainWindow = instance; - } + static void setInstance(DeepSkyStacker* instance); DeepSkyStacker(); - - ~DeepSkyStacker() - { - } - - inline QString statusMessage() - { - return statusBarText->text(); - } - - CDeepStack& deepStack() - { - return m_DeepStack; - }; - - qreal pixelRatio() - { - return devicePixelRatioF(); - } - - void setTab(std::uint32_t dwTabID) - { - if (dwTabID == IDD_REGISTERING) - dwTabID = IDD_STACKING; - //#ifdef DSSBETA - // if (dwTabID == IDD_STACKING && (GetAsyncKeyState(VK_CONTROL) & 0x8000)) - // dwTabID = IDD_LIBRARY; - //#endif - currTab = dwTabID; - updateTab(); - }; - - std::uint32_t tab() - { - return currTab; - }; - - inline void disableSubDialogs() - { - stackingDlg->setEnabled(false); - processingDlg.EnableWindow(false); - //m_dlgLibrary.EnableWindow(false); - explorerBar->setEnabled(false); - }; - - inline void enableSubDialogs() - { - stackingDlg->setEnabled(true); - processingDlg.EnableWindow(true); - //m_dlgLibrary.EnableWindow(true); - explorerBar->setEnabled(true); - }; - - CDSSSettings& settings() - { - if (!m_Settings.IsLoaded()) - m_Settings.Load(); - - return m_Settings; - }; - - DSS::StackingDlg& getStackingDlg() - { - return *stackingDlg; - }; - - CProcessingDlg& getProcessingDlg() - { - return processingDlg; - }; - - - ExplorerBar& GetExplorerBar() - { - return *explorerBar; - }; - - inline void setWindowFilePath(const QString& name) - { - if (currentPathName == name) return; - currentPathName = name; - if (!name.isEmpty()) - setWindowTitle(QString("%1 - %2").arg(baseTitle).arg(name)); - else - setWindowTitle(baseTitle); - } - + ~DeepSkyStacker() = default; + + inline qreal pixelRatio() { return devicePixelRatioF(); } + inline std::uint32_t tab() { return currTab; } + inline static DeepSkyStacker* instance() { return theMainWindow; } + + QString statusMessage(); + CDeepStack& deepStack(); + void setTab(std::uint32_t dwTabID); + void disableSubDialogs(); + void enableSubDialogs(); + CDSSSettings& settings(); + DSS::StackingDlg& getStackingDlg(); + CProcessingDlg& getProcessingDlg(); + ExplorerBar& GetExplorerBar(); + void setWindowFilePath(const QString& name); }; @@ -208,16 +118,8 @@ public : CWnd * m_pMainDlg; public : - DeepSkyStackerApp() : - m_pMainDlg{ nullptr } - { - - }; - - virtual ~DeepSkyStackerApp() - { - - }; + DeepSkyStackerApp() : m_pMainDlg{ nullptr } {} + virtual ~DeepSkyStackerApp() = default; virtual BOOL InitInstance( ) override; virtual int ExitInstance() override; diff --git a/DeepSkyStacker/DeepSkyStacker.rc b/DeepSkyStacker/DeepSkyStacker.rc index 705167725..bf969f6af 100644 --- a/DeepSkyStacker/DeepSkyStacker.rc +++ b/DeepSkyStacker/DeepSkyStacker.rc @@ -126,7 +126,7 @@ IDB_COMETFREEZE BITMAP "res\\Comet_Freeze.bmp" IDB_COMETNORMAL BITMAP "res\\Comet_Normal.bmp" -IDB_4CORNERS BITMAP "res\\4Corners.bmp" +//IDB_4CORNERS BITMAP "res\\4Corners.bmp" IDB_INTERSECTIONMODE BITMAP "res\\intersectionmode.bmp" @@ -234,19 +234,19 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,168,-22,50,14 END -IDD_PROGRESS DIALOGEX 0, 0, 337, 118 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION -CAPTION "Processing ..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CTEXT "",IDC_PROCESS_TEXT1,7,7,323,24 - CTEXT "",IDC_PROCESS_TEXT2,7,34,323,24 - CONTROL "Progress1",IDC_PROGRESS1,"msctls_progress32",WS_BORDER|PBS_SMOOTH,26,66,286,9 - CONTROL "Progress1",IDC_PROGRESS2,"msctls_progress32",WS_BORDER|PBS_SMOOTH,26,79,286,9 - PUSHBUTTON "Stop",IDC_STOP,281,96,50,14 - LTEXT "",IDC_TIMEREMAINING,14,96,137,8 - LTEXT "",IDC_NRPROCESSORS,154,96,124,8 -END +// IDD_PROGRESS DIALOGEX 0, 0, 337, 118 +// STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION +// CAPTION "Processing ..." +// FONT 8, "MS Shell Dlg", 0, 0, 0x0 +// BEGIN +// CTEXT "",IDC_PROCESS_TEXT1,7,7,323,24 +// CTEXT "",IDC_PROCESS_TEXT2,7,34,323,24 +// CONTROL "Progress1",IDC_PROGRESS1,"msctls_progress32",WS_BORDER|PBS_SMOOTH,26,66,286,9 +// CONTROL "Progress1",IDC_PROGRESS2,"msctls_progress32",WS_BORDER|PBS_SMOOTH,26,79,286,9 +// PUSHBUTTON "Stop",IDC_STOP,281,96,50,14 +// LTEXT "",IDC_TIMEREMAINING,14,96,137,8 +// LTEXT "",IDC_NRPROCESSORS,154,96,124,8 +// END IDD_LIBRARY DIALOGEX 0, 0, 438, 433 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_CLIPCHILDREN @@ -298,10 +298,10 @@ BEGIN BEGIN END - IDD_PROGRESS, DIALOG - BEGIN - BOTTOMMARGIN, 117 - END +// IDD_PROGRESS, DIALOG +// BEGIN +// BOTTOMMARGIN, 117 +// END IDD_LIBRARY, DIALOG BEGIN @@ -321,10 +321,10 @@ BEGIN 0 END -IDD_PROGRESS AFX_DIALOG_LAYOUT -BEGIN - 0 -END +// IDD_PROGRESS AFX_DIALOG_LAYOUT +// BEGIN +// 0 +// END #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/DeepSkyStacker/DeepSkyStacker.vcxproj b/DeepSkyStacker/DeepSkyStacker.vcxproj index a552e45a1..47a98d982 100644 --- a/DeepSkyStacker/DeepSkyStacker.vcxproj +++ b/DeepSkyStacker/DeepSkyStacker.vcxproj @@ -106,7 +106,7 @@ - $(Qt_LIBS_);htmlhelp.lib;zlibstat.lib;libpng16.lib;%(AdditionalDependencies) + gdi32.lib;gdiplus.lib;$(Qt_LIBS_);htmlhelp.lib;zlibstat.lib;libpng16.lib;%(AdditionalDependencies) $(OutDir)$(TargetName)$(TargetExt) false Windows @@ -174,7 +174,7 @@ $(QtToolsPath)\windeployqt $(TargetPath) 0x040c - $(Qt_LIBS_);htmlhelp.lib;cfitsio.lib;zlibstat.lib;libpng16.lib;%(AdditionalDependencies) + gdi32.lib;gdiplus.lib;$(Qt_LIBS_);htmlhelp.lib;cfitsio.lib;zlibstat.lib;libpng16.lib;%(AdditionalDependencies) $(OutDir)$(TargetName)$(TargetExt) Windows MachineX64 @@ -247,13 +247,13 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) - NotUsing - NotUsing + Use + Use - NotUsing - NotUsing + Use + Use @@ -286,18 +286,24 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) - NotUsing - NotUsing + Use + Use + + + + + + - NotUsing - NotUsing + Use + Use @@ -307,11 +313,15 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) + - NotUsing - NotUsing + Use + Use + + + NotUsing NotUsing @@ -321,20 +331,22 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) NotUsing NotUsing + - NotUsing - NotUsing + Use + Use + - NotUsing - NotUsing + Use + Use @@ -351,16 +363,16 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) - NotUsing - NotUsing + Use + Use input %(Filename).moc input %(Filename).moc - NotUsing - NotUsing + Use + Use @@ -371,13 +383,12 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) - NotUsing - NotUsing + Use + Use - - NotUsing - NotUsing + Use + Use @@ -394,22 +405,22 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) NotUsing - NotUsing - NotUsing + Use + Use - NotUsing - NotUsing + Use + Use - NotUsing - NotUsing + Use + Use - NotUsing - NotUsing + Use + Use @@ -428,21 +439,21 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) - NotUsing - NotUsing + Use + Use - NotUsing - NotUsing + Use + Use - NotUsing - NotUsing + Use + Use - + Create Create @@ -510,14 +521,27 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) + + + + + + + + + + + + + @@ -526,6 +550,7 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) + @@ -538,16 +563,22 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) + + + + + + @@ -557,17 +588,19 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) + + + - @@ -579,6 +612,7 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) + @@ -609,7 +643,7 @@ $(QtToolsPath)\windeployqt --pdb $(TargetPath) - + diff --git a/DeepSkyStacker/DeepSkyStacker.vcxproj.filters b/DeepSkyStacker/DeepSkyStacker.vcxproj.filters index 8a2cdef9e..f97afea19 100644 --- a/DeepSkyStacker/DeepSkyStacker.vcxproj.filters +++ b/DeepSkyStacker/DeepSkyStacker.vcxproj.filters @@ -51,13 +51,10 @@ - - Source Files - Source Files - + Source Files @@ -288,9 +285,6 @@ Tools - - Source Files - Tools @@ -354,9 +348,6 @@ Kernel - - Kernel - Kernel @@ -405,6 +396,48 @@ Kernel + + Source Files + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + @@ -472,7 +505,7 @@ Header Files - + Header Files @@ -688,9 +721,6 @@ Header Files - - Header Files - Header Files @@ -787,6 +817,78 @@ Kernel + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + diff --git a/DeepSkyStacker/DeepStack.cpp b/DeepSkyStacker/DeepStack.cpp index 5352bf488..5778abca5 100644 --- a/DeepSkyStacker/DeepStack.cpp +++ b/DeepSkyStacker/DeepStack.cpp @@ -1,14 +1,11 @@ #include #include "DeepStack.h" -#include -#include -#include -#include "MatchingStars.h" +#include "Histogram.h" +#include "Ztrace.h" +#include "Multitask.h" +#include "DSSProgress.h" -#define _USE_MATH_DEFINES -#include - -/* ------------------------------------------------------------------- */ +using namespace DSS; void CDeepStack::ComputeOriginalHistogram(CRGBHistogram & Histo) { diff --git a/DeepSkyStacker/DeepStack.h b/DeepSkyStacker/DeepStack.h index 309b7b2f3..9bd78af1d 100644 --- a/DeepSkyStacker/DeepStack.h +++ b/DeepSkyStacker/DeepStack.h @@ -1,28 +1,16 @@ -#ifndef _DEEPSTACK_H__ -#define _DEEPSTACK_H__ - -#include -#include -#include -#include "BitmapExt.h" -#include "StackingTasks.h" -#include "BezierAdjust.h" -#include "Histogram.h" +#pragma once #include "StackedBitmap.h" -#include "DSSProgress.h" -#include "RegisterEngine.h" - -#undef PI - +#include "BitmapExt.h" +namespace DSS { class ProgressBase; } class CDeepStack { private : - CStackedBitmap m_StackedBitmap; - CRGBHistogram m_OriginalHisto; - C32BitsBitmap m_Bitmap; - bool m_bNewStackedBitmap; - ProgressBase * m_pProgress; + CStackedBitmap m_StackedBitmap; + CRGBHistogram m_OriginalHisto; + C32BitsBitmap m_Bitmap; + bool m_bNewStackedBitmap; + DSS::ProgressBase* m_pProgress; public : CDeepStack() @@ -55,7 +43,7 @@ private : void AdjustHistogram(CRGBHistogram & srcHisto, CRGBHistogram & tgtHisto, const CRGBHistogramAdjust & HistogramAdjust); public : - void SetProgress(ProgressBase * pProgress) + void SetProgress(DSS::ProgressBase * pProgress) { m_pProgress = pProgress; }; @@ -114,5 +102,3 @@ public : return GetWidth() && GetHeight(); }; }; - -#endif // _DEEPSTACK_H__ diff --git a/DeepSkyStacker/Delaunay.cpp b/DeepSkyStacker/Delaunay.cpp index f4935ab98..877ac1f64 100644 --- a/DeepSkyStacker/Delaunay.cpp +++ b/DeepSkyStacker/Delaunay.cpp @@ -26,7 +26,7 @@ // mailto:sjaak@sjaakpriester.nl -#include "StdAfx.h" +#include "stdafx.h" #include "Delaunay.h" const float sqrt3 = 1.732050808F; diff --git a/DeepSkyStacker/DropFilesDlg.cpp b/DeepSkyStacker/DropFilesDlg.cpp index afc248dc1..d6ca72cd4 100644 --- a/DeepSkyStacker/DropFilesDlg.cpp +++ b/DeepSkyStacker/DropFilesDlg.cpp @@ -36,15 +36,11 @@ // DropFilesDlg.cpp : implementation file // #include "stdafx.h" -#include -#include - -//#include "stdafx.h" -#include "DeepSkyStacker.h" #include "DropFilesDlg.h" #include "ui/ui_DropFilesDlg.h" - -//#include "BitmapExt.h" +#include "BitmapInfo.h" +#include "BitmapExt.h" +#include "DeepSkyStacker.h" DropFilesDlg::DropFilesDlg(QWidget* parent) : QDialog(parent), diff --git a/DeepSkyStacker/DropFilesDlg.h b/DeepSkyStacker/DropFilesDlg.h index 87a21ba0e..f602249e1 100644 --- a/DeepSkyStacker/DropFilesDlg.h +++ b/DeepSkyStacker/DropFilesDlg.h @@ -34,9 +34,6 @@ ** ** ****************************************************************************/ -#include - -#include #include "DSSCommon.h" namespace Ui { diff --git a/DeepSkyStacker/DynamicStats.h b/DeepSkyStacker/DynamicStats.h new file mode 100644 index 000000000..89ae4a8d3 --- /dev/null +++ b/DeepSkyStacker/DynamicStats.h @@ -0,0 +1,78 @@ +#pragma once + +class CDynamicStats +{ +public: + int m_lNrValues; + double m_fSum; + double m_fPowSum; + double m_fMin, + m_fMax; + +public: + CDynamicStats() + { + m_lNrValues = 0; + m_fSum = 0; + m_fPowSum = 0; + m_fMin = 0; + m_fMax = 0; + }; + virtual ~CDynamicStats() {}; + + void AddValue(double fValue, int lNrValues = 1) noexcept + { + if (!m_lNrValues) + { + m_fMin = m_fMax = fValue; + } + else + { + m_fMin = std::min(m_fMin, fValue); + m_fMax = std::max(m_fMax, fValue); + }; + m_lNrValues += lNrValues; + m_fPowSum += (fValue * fValue) * lNrValues; + m_fSum += fValue * lNrValues; + }; + + void RemoveValue(double fValue, int lNrValues = 1) noexcept + { + m_lNrValues -= lNrValues; + m_fPowSum -= (fValue * fValue) * lNrValues; + m_fSum -= fValue * lNrValues; + }; + + double Average() noexcept + { + if (m_lNrValues) + return m_fSum / (double)m_lNrValues; + else + return 0; + }; + + double Sigma() noexcept + { + if (m_lNrValues) + return sqrt(m_fPowSum / m_lNrValues - pow(m_fSum / m_lNrValues, 2)); + else + return 0; + }; + + double Min() noexcept + { + return m_fMin; + }; + + double Max() noexcept + { + return m_fMax; + }; +}; + +template inline +void FillDynamicStat(const std::vector& vValues, CDynamicStats& DynStats) +{ + for (int i = 0; i < vValues.size(); i++) + DynStats.AddValue(vValues[i]); +}; \ No newline at end of file diff --git a/DeepSkyStacker/EntropyInfo.cpp b/DeepSkyStacker/EntropyInfo.cpp index 050aaa0f2..c233598cc 100644 --- a/DeepSkyStacker/EntropyInfo.cpp +++ b/DeepSkyStacker/EntropyInfo.cpp @@ -2,6 +2,11 @@ #include "EntropyInfo.h" #include "DSSProgress.h" #include "avx_entropy.h" +#include "Ztrace.h" +#include "MemoryBitmap.h" +#include "DSSTools.h" + +using namespace DSS; /* ------------------------------------------------------------------- */ void CEntropyInfo::InitSquareEntropies() @@ -109,4 +114,77 @@ void CEntropyInfo::ComputeEntropies(int lMinX, int lMinY, int lMaxX, int lMaxY, fBlueEntropy += -qBlue * log(qBlue)/log(2.0); }; }; -}; +} + +void CEntropyInfo::Init(std::shared_ptr pBitmap, int lWindowSize /* = 10 */, DSS::ProgressBase* pProgress /* = nullptr */) +{ + m_pBitmap = pBitmap; + m_lWindowSize = lWindowSize; + m_pProgress = pProgress; + InitSquareEntropies(); +} + +void CEntropyInfo::GetPixel(int x, int y, double& fRedEntropy, double& fGreenEntropy, double& fBlueEntropy, COLORREF16& crResult) +{ + int lSquareX, lSquareY; + + m_pBitmap->GetPixel16(x, y, crResult); + + lSquareX = x / (m_lWindowSize * 2 + 1); + lSquareY = y / (m_lWindowSize * 2 + 1); + + QPointF ptCenter; + CEntropySquare Squares[3]; + size_t sizeSquares = 0; + + GetSquareCenter(lSquareX, lSquareY, ptCenter); + AddSquare(Squares[sizeSquares++], lSquareX, lSquareY); + if (ptCenter.x() > x) + { + if (lSquareX > 0) + AddSquare(Squares[sizeSquares++], lSquareX - 1, lSquareY); + } + else if (ptCenter.x() < x) + { + if (lSquareX < m_lNrSquaresX - 1) + AddSquare(Squares[sizeSquares++], lSquareX + 1, lSquareY); + }; + + if (ptCenter.y() > y) + { + if (lSquareY > 0) + AddSquare(Squares[sizeSquares++], lSquareX, lSquareY - 1); + } + else if (ptCenter.y() < y) + { + if (lSquareY < m_lNrSquaresY - 1) + AddSquare(Squares[sizeSquares++], lSquareX, lSquareY + 1); + }; + + // Compute the gradient entropy from the nearby squares + fRedEntropy = 0.0; + fGreenEntropy = 0.0; + fBlueEntropy = 0.0; + QPointF ptPixel(x, y); + double fTotalWeight = 0.0; + + for (size_t i = 0; i < sizeSquares; i++) + { + double fDistance; + double fWeight = 1.0; + + fDistance = Distance(ptPixel, Squares[i].m_ptCenter); + if (fDistance > 0) + fWeight = 1.0 / fDistance; + + fRedEntropy += fWeight * Squares[i].m_fRedEntropy; + fGreenEntropy += fWeight * Squares[i].m_fGreenEntropy; + fBlueEntropy += fWeight * Squares[i].m_fBlueEntropy; + + fTotalWeight += fWeight; + } + + fRedEntropy /= fTotalWeight; + fGreenEntropy /= fTotalWeight; + fBlueEntropy /= fTotalWeight; +} \ No newline at end of file diff --git a/DeepSkyStacker/EntropyInfo.h b/DeepSkyStacker/EntropyInfo.h index 0d7c38d0d..9ca85a1a5 100644 --- a/DeepSkyStacker/EntropyInfo.h +++ b/DeepSkyStacker/EntropyInfo.h @@ -1,10 +1,8 @@ #ifndef __ENTROPYINFO_H__ #define __ENTROPYINFO_H__ +#include "ColorRef.h" -#include -#include "DSSTools.h" -#include "BitmapBase.h" -#include "zexcept.h" +namespace DSS { class ProgressBase; } /* ------------------------------------------------------------------- */ @@ -57,6 +55,7 @@ public : }; }; +class CMemoryBitmap; class CEntropyInfo { private: @@ -68,7 +67,7 @@ class CEntropyInfo std::vector m_vRedEntropies; std::vector m_vGreenEntropies; std::vector m_vBlueEntropies; - ProgressBase* m_pProgress; + DSS::ProgressBase* m_pProgress; private: void InitSquareEntropies(); @@ -106,78 +105,8 @@ class CEntropyInfo const int nrSquaresY() const { return m_lNrSquaresY; } const int windowSize() const { return m_lWindowSize; } - void Init(std::shared_ptr pBitmap, int lWindowSize = 10, ProgressBase* pProgress = nullptr) - { - m_pBitmap = pBitmap; - m_lWindowSize = lWindowSize; - m_pProgress = pProgress; - InitSquareEntropies(); - } - - void GetPixel(int x, int y, double& fRedEntropy, double& fGreenEntropy, double& fBlueEntropy, COLORREF16& crResult) - { - int lSquareX, lSquareY; - - m_pBitmap->GetPixel16(x, y, crResult); - - lSquareX = x / (m_lWindowSize * 2 + 1); - lSquareY = y / (m_lWindowSize * 2 + 1); - - QPointF ptCenter; - CEntropySquare Squares[3]; - size_t sizeSquares = 0; - - GetSquareCenter(lSquareX, lSquareY, ptCenter); - AddSquare(Squares[sizeSquares++], lSquareX, lSquareY); - if (ptCenter.x() > x) - { - if (lSquareX > 0) - AddSquare(Squares[sizeSquares++], lSquareX-1, lSquareY); - } - else if (ptCenter.x() < x) - { - if (lSquareX < m_lNrSquaresX - 1) - AddSquare(Squares[sizeSquares++], lSquareX+1, lSquareY); - }; - - if (ptCenter.y() > y) - { - if (lSquareY > 0) - AddSquare(Squares[sizeSquares++], lSquareX, lSquareY-1); - } - else if (ptCenter.y() < y) - { - if (lSquareY < m_lNrSquaresY - 1) - AddSquare(Squares[sizeSquares++], lSquareX, lSquareY+1); - }; - - // Compute the gradient entropy from the nearby squares - fRedEntropy = 0.0; - fGreenEntropy = 0.0; - fBlueEntropy = 0.0; - QPointF ptPixel(x, y); - double fTotalWeight = 0.0; - - for (size_t i = 0; i < sizeSquares; i++) - { - double fDistance; - double fWeight = 1.0; - - fDistance = Distance(ptPixel, Squares[i].m_ptCenter); - if (fDistance > 0) - fWeight = 1.0/fDistance; - - fRedEntropy += fWeight * Squares[i].m_fRedEntropy; - fGreenEntropy += fWeight * Squares[i].m_fGreenEntropy; - fBlueEntropy += fWeight * Squares[i].m_fBlueEntropy; - - fTotalWeight += fWeight; - } - - fRedEntropy /= fTotalWeight; - fGreenEntropy /= fTotalWeight; - fBlueEntropy /= fTotalWeight; - } + void Init(std::shared_ptr pBitmap, int lWindowSize = 10, DSS::ProgressBase* pProgress = nullptr); + void GetPixel(int x, int y, double& fRedEntropy, double& fGreenEntropy, double& fBlueEntropy, COLORREF16& crResult); }; #endif diff --git a/DeepSkyStacker/ExceptionHandling.cpp b/DeepSkyStacker/ExceptionHandling.cpp index ae69278b2..962b08e3f 100644 --- a/DeepSkyStacker/ExceptionHandling.cpp +++ b/DeepSkyStacker/ExceptionHandling.cpp @@ -1,12 +1,12 @@ #include "stdafx.h" + #if defined(_WINDOWS) -#include -#include #include #include #include "StackWalker.h" +#include "Ztrace.h" extern std::unique_ptr backPocket; diff --git a/DeepSkyStacker/ExplorerBar.cpp b/DeepSkyStacker/ExplorerBar.cpp index 28fab4203..02473b62b 100644 --- a/DeepSkyStacker/ExplorerBar.cpp +++ b/DeepSkyStacker/ExplorerBar.cpp @@ -1,38 +1,20 @@ -#include -using std::min; -using std::max; - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include -#include -#include -#include - -#include -#include -#include -#include +#include "stdafx.h" +#include "ExplorerBar.h" +#include "ui/ui_ExplorerBar.h" #include #include - -extern bool g_bShowRefStars; - -#include "DSSCommon.h" -#include "commonresource.h" -#include "About.h" -#include "DSSVersion.h" #include "DeepSkyStacker.h" - -//#include "FrameList.h" -#include "RawDDPSettings.h" -#include "RecommendedSettings.h" +#include "ProcessingDlg.h" +#include "Workspace.h" #include "RegisterSettings.h" #include "StackSettings.h" -#include "Workspace.h" +#include "RawDDPSettings.h" +#include "RecommendedSettings.h" +#include "About.h" + +extern bool g_bShowRefStars; -#include "ExplorerBar.h" -#include "ui/ui_ExplorerBar.h" #define dssApp DeepSkyStacker::instance() diff --git a/DeepSkyStacker/ExplorerBar.h b/DeepSkyStacker/ExplorerBar.h index 579380426..586b98589 100644 --- a/DeepSkyStacker/ExplorerBar.h +++ b/DeepSkyStacker/ExplorerBar.h @@ -1,9 +1,6 @@ #ifndef EXPLORERBAR_H #define EXPLORERBAR_H - -#include #include "mrupath.h" -//#include "ClickLabel.h" namespace Ui { class ExplorerBar; diff --git a/DeepSkyStacker/ExtraInfo.h b/DeepSkyStacker/ExtraInfo.h new file mode 100644 index 000000000..628387035 --- /dev/null +++ b/DeepSkyStacker/ExtraInfo.h @@ -0,0 +1,55 @@ +#pragma once + +typedef enum tagEXTRAINFOTYPE +{ + EIT_UNKNOWN = 0, + EIT_STRING = 1, + EIT_LONG = 2, + EIT_DOUBLE = 3 +} EXTRAINFOTYPE; + +class CExtraInfo +{ +public: + EXTRAINFOTYPE m_Type; + QString m_strName; + QString m_strValue; + QString m_strComment; + int m_lValue; + double m_fValue; + bool m_bPropagate; + +private: + void CopyFrom(const CExtraInfo& ei) + { + m_Type = ei.m_Type; + m_strName = ei.m_strName; + m_strValue = ei.m_strValue; + m_lValue = ei.m_lValue; + m_fValue = ei.m_fValue; + m_strComment = ei.m_strComment; + m_bPropagate = ei.m_bPropagate; + }; + +public: + CExtraInfo() + { + m_bPropagate = false; + m_Type = EIT_UNKNOWN; + m_lValue = 0; + m_fValue = 0; + }; + CExtraInfo(const CExtraInfo& ei) + { + CopyFrom(ei); + }; + ~CExtraInfo() {}; + + CExtraInfo& operator = (const CExtraInfo& ei) + { + CopyFrom(ei); + return (*this); + }; +}; + +typedef std::vector EXTRAINFOVECTOR; \ No newline at end of file diff --git a/DeepSkyStacker/FITSUtil.cpp b/DeepSkyStacker/FITSUtil.cpp index 2b42c78ca..467a2f54e 100644 --- a/DeepSkyStacker/FITSUtil.cpp +++ b/DeepSkyStacker/FITSUtil.cpp @@ -1,20 +1,28 @@ #include - -#include -#include #include -#include -#include -#include - #include -#include #include +// Ouch :( +#include + #include "resource.h" #include "Workspace.h" - #include "FITSUtil.h" +#include "..\CFitsio\fitsio.h" +#include "Ztrace.h" +#include "DSSProgress.h" +#include "ZExcBase.h" +#include "Multitask.h" +#include "GrayBitmap.h" +#include "ColorBitmap.h" +#include "RAWUtils.h" +#include "BitmapInfo.h" +#include "ColorHelpers.h" + +using namespace DSS; + + /* ------------------------------------------------------------------- */ @@ -261,9 +269,9 @@ void CFITSReader::ReadAllKeys() if (strPropagated.Find(strKeyName) != -1) bPropagate = true; m_ExtraInfo.AddInfo( - (LPCTSTR)CA2CT(szKeyName), - (LPCTSTR)CA2CT(szValue), - (LPCTSTR)CA2CT(szComment), bPropagate); + szKeyName, + szValue, + szComment, bPropagate); }; }; }; @@ -1131,11 +1139,11 @@ bool GetFITSInfo(LPCTSTR szFileName, CBitmapInfo& BitmapInfo) if (bContinue && fits.Open()) { if (fits.m_strMake.GetLength() != 0) - BitmapInfo.m_strFileType.Format(_T("FITS (%s)"), fits.m_strMake.GetString()); + BitmapInfo.m_strFileType = QString("FITS (%1)").arg(QString::fromWCharArray(fits.m_strMake.GetString())); else - BitmapInfo.m_strFileType = _T("FITS"); + BitmapInfo.m_strFileType = "FITS"; - BitmapInfo.m_strFileName = szFileName; + BitmapInfo.m_strFileName = QString::fromWCharArray(szFileName); BitmapInfo.m_lWidth = fits.Width(); BitmapInfo.m_lHeight = fits.Height(); BitmapInfo.m_lBitPerChannel = fits.BitPerChannels(); @@ -1219,7 +1227,7 @@ void CFITSWriter::WriteAllKeys() // Check if DATE-OBS is already in the list of Extra Info for (const CExtraInfo& extraInfo : m_ExtraInfo.m_vExtras) { - if (extraInfo.m_strName.CompareNoCase(_T("DATE-OBS"))) + if (extraInfo.m_strName.compare("DATE-OBS", Qt::CaseInsensitive) == 0) { bFound = true; break; @@ -1235,7 +1243,7 @@ void CFITSWriter::WriteAllKeys() m_DateTime.wYear, m_DateTime.wMonth, m_DateTime.wDay, m_DateTime.wHour, m_DateTime.wMinute, m_DateTime.wSecond); - m_ExtraInfo.AddInfo(_T("DATE-OBS"), strDateTime); + m_ExtraInfo.AddInfo("DATE-OBS", QString::fromWCharArray(strDateTime.GetString()), ""); }; if (m_fits && m_ExtraInfo.m_vExtras.size()) @@ -1245,11 +1253,12 @@ void CFITSWriter::WriteAllKeys() for (int i = 0;iIsMonochrome() ? 1 : 3; m_bFloat = m_pMemoryBitmap->IsFloat(); m_CFAType = CFATYPE_NONE; - if (::IsCFA(m_pMemoryBitmap)) - m_CFAType = ::GetCFAType(m_pMemoryBitmap); + if (m_pMemoryBitmap && m_pMemoryBitmap->IsCFA()) + m_CFAType = m_pMemoryBitmap->GetCFAType(); if (m_Format == TF_UNKNOWN) m_Format = GetBestFITSFormat(m_pMemoryBitmap); diff --git a/DeepSkyStacker/FITSUtil.h b/DeepSkyStacker/FITSUtil.h index 728f15383..ffa161993 100644 --- a/DeepSkyStacker/FITSUtil.h +++ b/DeepSkyStacker/FITSUtil.h @@ -2,11 +2,14 @@ #define __FITSUTIL_H__ /* ------------------------------------------------------------------- */ -#include "BitmapExt.h" -#include "DSSProgress.h" -#include "DSSTools.h" -#include "..\CFitsio\fitsio.h" #include +#include "cfa.h" +#include "DSSCommon.h" +#include "BitmapExtraInfo.h" +#include "fitsio.h" + +// Want this out! +#include namespace fs = std::filesystem; @@ -109,7 +112,8 @@ class CFITSHeader }; /* ------------------------------------------------------------------- */ - +namespace DSS { class ProgressBase; } +using namespace DSS; class CFITSReader : public CFITSHeader { public: @@ -212,6 +216,8 @@ private : }; /* ------------------------------------------------------------------- */ +class CBitmapInfo; +class CMemoryBitmap; CFATYPE GetFITSCFATYPE(); bool GetFITSInfo(LPCTSTR szFileName, CBitmapInfo& BitmapInfo); diff --git a/DeepSkyStacker/File.cpp b/DeepSkyStacker/File.cpp new file mode 100644 index 000000000..769a2e7ef --- /dev/null +++ b/DeepSkyStacker/File.cpp @@ -0,0 +1,20 @@ +#include "stdafx.h" +#include +#include "file.h" + +bool GetFileCreationDateTime(LPCTSTR szFileName, FILETIME& FileTime) +{ + bool bResult = false; + HANDLE hFind; + WIN32_FIND_DATA FindData; + + hFind = FindFirstFile(szFileName, &FindData); + if (hFind != INVALID_HANDLE_VALUE) + { + FileTime = FindData.ftLastWriteTime; + FindClose(hFind); + bResult = true; + }; + + return bResult; +} \ No newline at end of file diff --git a/DeepSkyStacker/File.h b/DeepSkyStacker/File.h new file mode 100644 index 000000000..51f130457 --- /dev/null +++ b/DeepSkyStacker/File.h @@ -0,0 +1,3 @@ +#pragma once + +bool GetFileCreationDateTime(LPCTSTR szFileName, FILETIME& FileTime); \ No newline at end of file diff --git a/DeepSkyStacker/FileProperty.h b/DeepSkyStacker/FileProperty.h index b60d288fb..22ac55641 100644 --- a/DeepSkyStacker/FileProperty.h +++ b/DeepSkyStacker/FileProperty.h @@ -1,7 +1,6 @@ #pragma once - +#include "commonresource.h" // CFileProperty dialog -#include namespace DSS { diff --git a/DeepSkyStacker/Filters.cpp b/DeepSkyStacker/Filters.cpp index fc39c9acb..7df14cbfd 100644 --- a/DeepSkyStacker/Filters.cpp +++ b/DeepSkyStacker/Filters.cpp @@ -1,6 +1,10 @@ #include -#include "resource.h" #include "Filters.h" +#include "Ztrace.h" +#include "MemoryBitmap.h" +#include "DSSProgress.h" + +using namespace DSS; /* ------------------------------------------------------------------- */ @@ -439,3 +443,15 @@ std::shared_ptr CDirectionalImageFilter::ApplyFilter(CMemoryBitma return pOutBitmap; } + +void CMedianImageFilter::SetBitmap(CMemoryBitmap* pBitmap) +{ + m_pInBitmap = pBitmap; + if (pBitmap != nullptr) + { + m_bMonochrome = pBitmap->IsMonochrome(); + m_bCFA = pBitmap->IsCFA(); + m_lWidth = pBitmap->Width(); + m_lHeight = pBitmap->Height(); + } +} \ No newline at end of file diff --git a/DeepSkyStacker/Filters.h b/DeepSkyStacker/Filters.h index 2692ba676..cadb3d297 100644 --- a/DeepSkyStacker/Filters.h +++ b/DeepSkyStacker/Filters.h @@ -6,13 +6,15 @@ #include "DSSTools.h" #include "DarkFrame.h" +namespace DSS { class ProgressBase; } + /* ------------------------------------------------------------------- */ class CImageFilter { public : virtual ~CImageFilter() = default; - virtual std::shared_ptr ApplyFilter(CMemoryBitmap* pInBitmap, ProgressBase* pProgress = nullptr) = 0; + virtual std::shared_ptr ApplyFilter(CMemoryBitmap* pInBitmap, DSS::ProgressBase* pProgress = nullptr) = 0; }; /* ------------------------------------------------------------------- */ @@ -83,19 +85,9 @@ private : return m_bCFA; } - void SetBitmap(CMemoryBitmap* pBitmap) - { - m_pInBitmap = pBitmap; - if (pBitmap != nullptr) - { - m_bMonochrome = pBitmap->IsMonochrome(); - m_bCFA = pBitmap->IsCFA(); - m_lWidth = pBitmap->Width(); - m_lHeight = pBitmap->Height(); - } - } + void SetBitmap(CMemoryBitmap* pBitmap); - virtual std::shared_ptr ApplyFilter(CMemoryBitmap* pInBitmap, ProgressBase* pProgress = nullptr) override; + virtual std::shared_ptr ApplyFilter(CMemoryBitmap* pInBitmap, DSS::ProgressBase* pProgress = nullptr) override; }; /* ------------------------------------------------------------------- */ @@ -115,7 +107,7 @@ private : private : void AnalyzeImage(CMemoryBitmap * pInBitmap, bool bComputeThresholds); - void ApplyFilterInternal(const CMemoryBitmap* pInBitmap, CMemoryBitmap* pOutBitmap, ProgressBase* pProgress = nullptr); + void ApplyFilterInternal(const CMemoryBitmap* pInBitmap, CMemoryBitmap* pOutBitmap, DSS::ProgressBase* pProgress = nullptr); public : CExtendedMedianImageFilter() @@ -151,7 +143,7 @@ public : m_bUseRejectThreshold = false; }; - virtual std::shared_ptr ApplyFilter(CMemoryBitmap* pInBitmap, ProgressBase* pProgress = nullptr) override; + virtual std::shared_ptr ApplyFilter(CMemoryBitmap* pInBitmap, DSS::ProgressBase* pProgress = nullptr) override; }; /* ------------------------------------------------------------------- */ @@ -177,7 +169,7 @@ public : m_lSize = lSize; } - virtual std::shared_ptr ApplyFilter(CMemoryBitmap* pInBitmap, ProgressBase* pProgress = nullptr) override; + virtual std::shared_ptr ApplyFilter(CMemoryBitmap* pInBitmap, DSS::ProgressBase* pProgress = nullptr) override; }; #endif diff --git a/DeepSkyStacker/FlatFrame.cpp b/DeepSkyStacker/FlatFrame.cpp index 87a7d4e6c..13c20e254 100644 --- a/DeepSkyStacker/FlatFrame.cpp +++ b/DeepSkyStacker/FlatFrame.cpp @@ -1,12 +1,34 @@ #include -#include "resource.h" +#include +#include + #include "FlatFrame.h" -#include "DSSTools.h" -#include "DSSProgress.h" #include "Multitask.h" +#include "DSSProgress.h" +#include "MemoryBitmap.h" +#include "CFABitmapInfo.h" +#include "Ztrace.h" +#include "resource.h" -#include +using namespace DSS; +bool CFlatFrame::IsOk() const +{ + return static_cast(m_pFlatFrame) && m_pFlatFrame->IsOk(); +} + +bool CFlatFrame::IsCFA() const +{ + if(m_pFlatFrame.get()) + return m_pFlatFrame->IsCFA(); + return false; +} + +void CFlatFrame::Clear() +{ + m_bComputed = false; + m_pFlatFrame.reset(); +} bool CFlatFrame::ApplyFlat(std::shared_ptr pTarget, ProgressBase * pProgress) { diff --git a/DeepSkyStacker/FlatFrame.h b/DeepSkyStacker/FlatFrame.h index 271940737..56d23c7d2 100644 --- a/DeepSkyStacker/FlatFrame.h +++ b/DeepSkyStacker/FlatFrame.h @@ -1,7 +1,6 @@ #ifndef __FLATFRAME_H__ #define __FLATFRAME_H__ - -#include "BitmapExt.h" +#include "Bayer.h" /* ------------------------------------------------------------------- */ @@ -110,7 +109,8 @@ public : }; /* ------------------------------------------------------------------- */ - +class CMemoryBitmap; +namespace DSS { class ProgressBase; } class CFlatFrame { public : @@ -122,27 +122,13 @@ public : CFlatFrame() : m_bComputed{ false } {} - virtual ~CFlatFrame() - {} - - bool IsOk() const - { - return static_cast(m_pFlatFrame) && m_pFlatFrame->IsOk(); - } - - bool IsCFA() const - { - return ::IsCFA(m_pFlatFrame.get()); - } - - void Clear() - { - m_bComputed = false; - m_pFlatFrame.reset(); - } + virtual ~CFlatFrame() = default; - void ComputeFlatNormalization(ProgressBase* pProgress = nullptr); - bool ApplyFlat(std::shared_ptr pTarget, ProgressBase * pProgress = nullptr); + bool IsOk() const; + bool IsCFA() const; + void Clear(); + void ComputeFlatNormalization(DSS::ProgressBase* pProgress = nullptr); + bool ApplyFlat(std::shared_ptr pTarget, DSS::ProgressBase * pProgress = nullptr); }; /* ------------------------------------------------------------------- */ diff --git a/DeepSkyStacker/FlatPart.h b/DeepSkyStacker/FlatPart.h new file mode 100644 index 000000000..dc027d1c7 --- /dev/null +++ b/DeepSkyStacker/FlatPart.h @@ -0,0 +1,52 @@ +#pragma once + +class CFlatPart +{ +public: + int m_lStart, + m_lEnd; + double m_fAverage; + double m_fAverageVariation; + double m_fAbsAverageVariation; + +private: + +public: + CFlatPart() noexcept + { + m_lStart = -1; + m_lEnd = -1; + m_fAverage = 0; + m_fAverageVariation = 0; + m_fAbsAverageVariation = 0; + }; + ~CFlatPart() {}; + CFlatPart(const CFlatPart&) = default; + + CFlatPart& operator = (const CFlatPart&) = default; + + int Length() const noexcept + { + return m_lEnd - m_lStart + 1; + }; + + double Score() const noexcept + { + if (m_fAbsAverageVariation) + return (double)Length() / m_fAbsAverageVariation;//m_fAverageVariation; + else + return 0; + }; + + bool operator < (const CFlatPart& fp) const noexcept + { + return Score() > fp.Score(); + /* + if (Length() > fp.Length()) + return true; + else if (Length() < fp.Length()) + return false; + else + return m_fAverage < fp.m_fAverage;*/ + }; +}; \ No newline at end of file diff --git a/DeepSkyStacker/FrameInfo.cpp b/DeepSkyStacker/FrameInfo.cpp index de06cf23b..67c5d8f3d 100644 --- a/DeepSkyStacker/FrameInfo.cpp +++ b/DeepSkyStacker/FrameInfo.cpp @@ -1,15 +1,12 @@ #include - -#include "resource.h" -#include "BitmapExt.h" -#include "DSSTools.h" -#include "DSSProgress.h" #include "FrameInfo.h" +#include "BitmapInfo.h" +#include "BitmapExt.h" /* ------------------------------------------------------------------- */ -bool CFrameInfo::InitFromFile(const fs::path& file, PICTURETYPE Type) +bool CFrameInfo::InitFromFile(const fs::path& file, PICTURETYPE Type) { bool bResult = false; @@ -49,10 +46,12 @@ bool CFrameInfo::InitFromFile(const fs::path& file, PICTURETYPE Type) m_CFAType = bmpInfo.m_CFAType; m_bFITS16bit = bmpInfo.m_bFITS16bit; m_DateTime = bmpInfo.m_DateTime; - m_strDateTime = bmpInfo.m_strDateTime; + m_strDateTime = bmpInfo.m_strDateTime.toStdWString().c_str(); m_ExtraInfo = bmpInfo.m_ExtraInfo; - bmpInfo.GetDescription(m_strInfos); + QString strInfo; + bmpInfo.GetDescription(strInfo); + m_strInfos = strInfo.toStdWString().c_str(); m_lISOSpeed = bmpInfo.m_lISOSpeed; m_lGain = bmpInfo.m_lGain; @@ -66,6 +65,129 @@ bool CFrameInfo::InitFromFile(const fs::path& file, PICTURETYPE Type) }; return bResult; -}; +} -/* ------------------------------------------------------------------- */ +void CFrameInfo::CopyFrom(const CFrameInfo& cfi) +{ + m_lWidth = cfi.m_lWidth; + m_lHeight = cfi.m_lHeight; + filePath = cfi.filePath; + m_lISOSpeed = cfi.m_lISOSpeed; + m_lGain = cfi.m_lGain; + m_fExposure = cfi.m_fExposure; + m_fAperture = cfi.m_fAperture; + m_PictureType = cfi.m_PictureType; + m_CFAType = cfi.m_CFAType; + m_lBitPerChannels = cfi.m_lBitPerChannels; + m_lNrChannels = cfi.m_lNrChannels; + m_FileTime = cfi.m_FileTime; + m_strDateTime = cfi.m_strDateTime; + m_DateTime = cfi.m_DateTime; + m_bMaster = cfi.m_bMaster; + m_strInfos = cfi.m_strInfos; + m_bFITS16bit = cfi.m_bFITS16bit; + m_bSuperPixel = cfi.m_bSuperPixel; + m_ExtraInfo = cfi.m_ExtraInfo; + m_filterName = cfi.m_filterName; +} + +void CFrameInfo::Reset() +{ + m_lISOSpeed = 0; + m_lGain = -1; + m_fExposure = 0.0; + m_fAperture = 0.0; + m_PictureType = PICTURETYPE_LIGHTFRAME; + m_CFAType = CFATYPE_NONE; + m_lNrChannels = 3; + m_lBitPerChannels = 16; + m_bMaster = false; + m_bFITS16bit = false; + m_bSuperPixel = false; + m_DateTime = { 0 }; + m_FileTime = { 0 }; + m_ExtraInfo.Clear(); + m_lWidth = 0; + m_lHeight = 0; +} + +bool CFrameInfo::IsCompatible(int lWidth, int lHeight, int lBitPerChannels, int lNrChannels, CFATYPE CFAType) const +{ + bool result = true; + + if (m_lWidth != lWidth) + { + incompatibilityReason = QCoreApplication::translate("DSS::StackingDlg", "Width mismatch"); + return false; + } + if (m_lHeight != lHeight) + { + incompatibilityReason = QCoreApplication::translate("DSS::StackingDlg", "Height mismatch"); + return false; + } + if (m_lBitPerChannels != lBitPerChannels) + { + incompatibilityReason = QCoreApplication::translate("DSS::StackingDlg", "Colour depth mismatch"); + return false; + } + + if (result) + { + result = (m_lNrChannels == lNrChannels) && (m_CFAType == CFAType); + if (!result) + { + // Check that if CFA if Off then the number of channels may be + // 3 instead of 1 if BayerDrizzle and SuperPixels are off + if (!IsRawBayer() && !IsSuperPixels() && !IsFITSRawBayer() && !IsFITSSuperPixels()) + { + if (m_CFAType != CFAType) + { + if ((m_CFAType != CFATYPE_NONE) && (m_lNrChannels == 1)) + result = (CFAType != CFATYPE_NONE) && (lNrChannels == 3); + else if ((CFAType == CFATYPE_NONE) && (lNrChannels == 1)) + result = (m_CFAType == CFATYPE_NONE) && (m_lNrChannels == 3); + }; + if (false == result) + incompatibilityReason = QCoreApplication::translate("DSS::StackingDlg", "Number of channels mismatch"); + }; + }; + }; + + return result; +} + +CFATYPE CFrameInfo::GetCFAType() const +{ + if (m_bFITS16bit) + { + // + // On the old days this was always determined by the values read from the + // workspace by GetFITSCFATYPE(). Now however GetFITSInfo() may auto-detect + // the CFA pattern and pre-populate CFAType, which we should now use. If it's + // not set then do it the old way. + // + if (m_CFAType != CFATYPE_NONE) + return m_CFAType; + else + return m_CFAType = GetFITSCFATYPE(); + } + else + return m_CFAType; +} + +bool CFrameInfo::IsSuperPixel() const +{ + if (m_bFITS16bit) + m_bSuperPixel = IsFITSSuperPixels() && (GetCFAType() != CFATYPE_NONE); + + return m_bSuperPixel; +} + +void CFrameInfo::RefreshSuperPixel() +{ + m_bSuperPixel = false; + if (m_bFITS16bit) + m_bSuperPixel = IsFITSSuperPixels() && (GetCFAType() != CFATYPE_NONE); + else if (m_CFAType != CFATYPE_NONE) + m_bSuperPixel = ::IsSuperPixels(); +} \ No newline at end of file diff --git a/DeepSkyStacker/FrameInfo.h b/DeepSkyStacker/FrameInfo.h index 96f9f6289..749a060d8 100644 --- a/DeepSkyStacker/FrameInfo.h +++ b/DeepSkyStacker/FrameInfo.h @@ -1,10 +1,12 @@ #ifndef __FRAMEINFO_H__ #define __FRAMEINFO_H__ +#include "cfa.h" #include -#include "MatchingStars.h" +#include "DSSCommon.h" +#include "BitmapExtraInfo.h" #include "SkyBackground.h" - -//#include "RAWUtils.h" +#include "BilinearParameters.h" +#include "MatchingStars.h" // From FITSUtils.h/.cpp CFATYPE GetFITSCFATYPE(); @@ -45,49 +47,8 @@ private : mutable bool m_bSuperPixel; protected : - void CopyFrom(const CFrameInfo & cfi) - { - m_lWidth = cfi.m_lWidth; - m_lHeight = cfi.m_lHeight; - filePath = cfi.filePath; - m_lISOSpeed = cfi.m_lISOSpeed; - m_lGain = cfi.m_lGain; - m_fExposure = cfi.m_fExposure; - m_fAperture = cfi.m_fAperture; - m_PictureType = cfi.m_PictureType; - m_CFAType = cfi.m_CFAType; - m_lBitPerChannels = cfi.m_lBitPerChannels; - m_lNrChannels = cfi.m_lNrChannels; - m_FileTime = cfi.m_FileTime; - m_strDateTime = cfi.m_strDateTime; - m_DateTime = cfi.m_DateTime; - m_bMaster = cfi.m_bMaster; - m_strInfos = cfi.m_strInfos; - m_bFITS16bit = cfi.m_bFITS16bit; - m_bSuperPixel = cfi.m_bSuperPixel; - m_ExtraInfo = cfi.m_ExtraInfo; - m_filterName = cfi.m_filterName; - }; - - void Reset() - { - m_lISOSpeed = 0; - m_lGain = -1; - m_fExposure = 0.0; - m_fAperture = 0.0; - m_PictureType = PICTURETYPE_LIGHTFRAME; - m_CFAType = CFATYPE_NONE; - m_lNrChannels = 3; - m_lBitPerChannels = 16; - m_bMaster = false; - m_bFITS16bit = false; - m_bSuperPixel = false; - m_DateTime = { 0 }; - m_FileTime = { 0 }; - m_ExtraInfo.Clear(); - m_lWidth = 0; - m_lHeight = 0; - }; + void CopyFrom(const CFrameInfo& cfi); + void Reset(); public : CFrameInfo() @@ -145,93 +106,18 @@ public : return m_lHeight/(m_bSuperPixel ? 2 : 1); }; - bool IsCompatible(int lWidth, int lHeight, int lBitPerChannels, int lNrChannels, CFATYPE CFAType) const - { - bool result = true; - - if (m_lWidth != lWidth) - { - incompatibilityReason = QCoreApplication::translate("DSS::StackingDlg", "Width mismatch"); - return false; - } - if (m_lHeight != lHeight) - { - incompatibilityReason = QCoreApplication::translate("DSS::StackingDlg", "Height mismatch"); - return false; - } - if (m_lBitPerChannels != lBitPerChannels) - { - incompatibilityReason = QCoreApplication::translate("DSS::StackingDlg", "Colour depth mismatch"); - return false; - } - - if (result) - { - result = (m_lNrChannels == lNrChannels) && (m_CFAType == CFAType); - if (!result) - { - // Check that if CFA if Off then the number of channels may be - // 3 instead of 1 if BayerDrizzle and SuperPixels are off - if (!IsRawBayer() && !IsSuperPixels() && !IsFITSRawBayer() && !IsFITSSuperPixels()) - { - if (m_CFAType != CFAType) - { - if ((m_CFAType != CFATYPE_NONE) && (m_lNrChannels==1)) - result = (CFAType != CFATYPE_NONE) && (lNrChannels == 3); - else if ((CFAType == CFATYPE_NONE) && (lNrChannels == 1)) - result = (m_CFAType == CFATYPE_NONE) && (m_lNrChannels == 3); - }; - if (false == result) - incompatibilityReason = QCoreApplication::translate("DSS::StackingDlg", "Number of channels mismatch"); - }; - }; - }; - - return result; - }; + bool IsCompatible(int lWidth, int lHeight, int lBitPerChannels, int lNrChannels, CFATYPE CFAType) const; - bool IsCompatible(const CFrameInfo & cfi) const + bool IsCompatible(const CFrameInfo & cfi) const { return IsCompatible(cfi.m_lWidth, cfi.m_lHeight, cfi.m_lBitPerChannels, cfi.m_lNrChannels, cfi.m_CFAType); }; bool InitFromFile(const fs::path& file, PICTURETYPE Type); - CFATYPE GetCFAType() const - { - if (m_bFITS16bit) - { - // - // On the old days this was always determined by the values read from the - // workspace by GetFITSCFATYPE(). Now however GetFITSInfo() may auto-detect - // the CFA pattern and pre-populate CFAType, which we should now use. If it's - // not set then do it the old way. - // - if (m_CFAType != CFATYPE_NONE) - return m_CFAType; - else - return m_CFAType = GetFITSCFATYPE(); - } - else - return m_CFAType; - }; - - bool IsSuperPixel() const - { - if (m_bFITS16bit) - m_bSuperPixel = IsFITSSuperPixels() && (GetCFAType() != CFATYPE_NONE); - - return m_bSuperPixel; - }; - - void RefreshSuperPixel() - { - m_bSuperPixel = false; - if (m_bFITS16bit) - m_bSuperPixel = IsFITSSuperPixels() && (GetCFAType() != CFATYPE_NONE); - else if (m_CFAType != CFATYPE_NONE) - m_bSuperPixel = ::IsSuperPixels(); - }; + CFATYPE GetCFAType() const; + bool IsSuperPixel() const; + void RefreshSuperPixel(); }; using FRAMEINFOVECTOR = std::vector; diff --git a/DeepSkyStacker/FrameInfoSupport.h b/DeepSkyStacker/FrameInfoSupport.h index 8521407c3..1b1e399a6 100644 --- a/DeepSkyStacker/FrameInfoSupport.h +++ b/DeepSkyStacker/FrameInfoSupport.h @@ -1,5 +1,5 @@ #pragma once - +#include "commonresource.h" inline void ExposureToString(double fExposure, CString& strText) { // DELETE THIS ONE DAY diff --git a/DeepSkyStacker/FrameList.cpp b/DeepSkyStacker/FrameList.cpp index 60a4b5203..0e93b37d1 100644 --- a/DeepSkyStacker/FrameList.cpp +++ b/DeepSkyStacker/FrameList.cpp @@ -1,20 +1,11 @@ #include - -#include -#include -#if defined (_CONSOLE) -#include -#else -#include -#endif -#include "resource.h" #include "FrameList.h" #include "ImageListModel.h" -#include "RegisterEngine.h" -#include "Workspace.h" -#include -#include #include "ZExcept.h" +#include "StackingTasks.h" +#include "Workspace.h" +#include "Ztrace.h" +#include "RegisterEngine.h" namespace { @@ -69,639 +60,652 @@ namespace { /* ------------------------------------------------------------------- */ -namespace DSS +using namespace DSS; + +ListBitMap* FrameList::getListBitMap(int row) +{ + // + // return address of the relevant ListBitMap in the current + // group + // + return &imageGroups[index].pictures->mydata[row]; +} +void FrameList::clear() { - size_t FrameList::checkedImageCount(const PICTURETYPE type, const int16_t id) const + for (auto& group : imageGroups) { - size_t result = 0; + group.pictures->clear(); + } + imageGroups.resize(1); + Group::reset(); +} +size_t FrameList::groupCount() const +{ + return imageGroups.size(); +} +size_t FrameList::groupSize(uint16_t id) const +{ + ZASSERTSTATE(id < imageGroups.size()); + return imageGroups[id].size(); +} +bool FrameList::isLightFrame(QString name) const +{ + return imageGroups[index].pictures->isLightFrame(name); +}; - // Iterate over all groups. - for (auto i = 0; i != imageGroups.size(); ++i) - { - // If the group number passed in was -1 then want to count the number of - // checked images of the relevant type in ALL groups. Otherwise only - // count checked images for the passed group number. - if (-1 == id || id == i) - { - for (auto it = imageGroups[i].pictures->cbegin(); - it != imageGroups[i].pictures->cend(); ++it) - { - if (it->m_PictureType == type && it->m_bChecked == Qt::Checked) ++result; - } - } - } +bool FrameList::isChecked(QString name) const +{ + return imageGroups[index].pictures->isChecked(name); +} - return result; - } +bool FrameList::getTransformation(QString name, CBilinearParameters& transformation, VOTINGPAIRVECTOR& vVotedPairs) const +{ + return imageGroups[index].pictures->getTransformation(name, transformation, vVotedPairs); +} +FrameList& FrameList::beginInsertRows(int count) +{ + auto first{ imageGroups[index].pictures->rowCount() }; // Insert after end + auto last{ first + count - 1 }; + imageGroups[index].pictures->beginInsertRows(QModelIndex(), first, last); + return (*this); +} +bool FrameList::addFile(fs::path file, PICTURETYPE PictureType /* = PICTURETYPE_LIGHTFRAME */, bool bCheck /* = false */, int nItem /* = -1 */) +{ + imageGroups[index].addFile(file, PictureType, bCheck); + return true; +} +FrameList& FrameList::endInsertRows() +{ + imageGroups[index].pictures->endInsertRows(); + return *this; +} +size_t FrameList::checkedImageCount(const PICTURETYPE type, const int16_t id) const +{ + size_t result = 0; - size_t FrameList::countUnregisteredCheckedLightFrames(int id) const + // Iterate over all groups. + for (auto i = 0; i != imageGroups.size(); ++i) { - size_t result = 0; - - // Iterate over all groups - for (const auto& group : imageGroups) + // If the group number passed in was -1 then want to count the number of + // checked images of the relevant type in ALL groups. Otherwise only + // count checked images for the passed group number. + if (-1 == id || id == i) { - // If the group number passed in was -1 then want to count the number of - // checked images of the relevant type in ALL groups. Otherwise only - // count checked images for the passed group number. - if (-1 == id || id == group.index()) + for (auto it = imageGroups[i].pictures->cbegin(); + it != imageGroups[i].pictures->cend(); ++it) { - for (auto it = group.pictures->cbegin(); - it != group.pictures->cend(); ++it) - { - if (it->IsLightFrame() && - it->m_bChecked == Qt::Checked && - !it->m_bRegistered) ++result; - }; + if (it->m_PictureType == type && it->m_bChecked == Qt::Checked) ++result; } } - return result; - }; + } + return result; +} +size_t FrameList::countUnregisteredCheckedLightFrames(int id) const +{ + size_t result = 0; - void FrameList::clearOffsets() + // Iterate over all groups + for (const auto& group : imageGroups) { - for (auto& group : imageGroups) + // If the group number passed in was -1 then want to count the number of + // checked images of the relevant type in ALL groups. Otherwise only + // count checked images for the passed group number. + if (-1 == id || id == group.index()) { - int row = 0; int groupIndex = group.index(); - for (auto it = group.pictures->begin(); - it != group.pictures->end(); ++it) + for (auto it = group.pictures->cbegin(); + it != group.pictures->cend(); ++it) { - if (it->IsLightFrame()) - it->m_bDeltaComputed = false; - if (index == groupIndex) - { - // - // Tell the table view which columns have been impacted - // - imageGroups[index].pictures->emitChanged(row, row, - static_cast(Column::dX), - static_cast(Column::Angle)); - } - ++row; - } + if (it->IsLightFrame() && + it->m_bChecked == Qt::Checked && + !it->m_bRegistered) ++result; + }; } - // - // Tell the table view which columns have been impacted - // - imageGroups[index].pictures->emitChanged(0, imageGroups[index].pictures->rowCount(), - static_cast(Column::dX), - static_cast(Column::Angle)); - }; + } + return result; +}; + - void FrameList::clearOffset(fs::path file) - { - int group = Group::whichGroupContains(file); - ZASSERTSTATE(-1 != group); - int row = 0; - for (auto it = imageGroups[group].pictures->begin(); it != imageGroups[group].pictures->end(); ++it) +void FrameList::clearOffsets() +{ + for (auto& group : imageGroups) + { + int row = 0; int groupIndex = group.index(); + for (auto it = group.pictures->begin(); + it != group.pictures->end(); ++it) { - if (file == it->filePath) - { + if (it->IsLightFrame()) it->m_bDeltaComputed = false; + if (index == groupIndex) + { // - // Ask the Table Model to tell the table view which rows/columns have changed + // Tell the table view which columns have been impacted // - if (index == group) - imageGroups[group].pictures->emitChanged(row, row, - static_cast(Column::dX), - static_cast(Column::Angle)); - return; + imageGroups[index].pictures->emitChanged(row, row, + static_cast(Column::dX), + static_cast(Column::Angle)); } ++row; } - }; + } + // + // Tell the table view which columns have been impacted + // + imageGroups[index].pictures->emitChanged(0, imageGroups[index].pictures->rowCount(), + static_cast(Column::dX), + static_cast(Column::Angle)); +}; + +void FrameList::clearOffset(fs::path file) +{ + int group = Group::whichGroupContains(file); - void FrameList::updateOffset(fs::path file, double xOffset, double yOffset, double angle, const CBilinearParameters& transform, const VOTINGPAIRVECTOR vVotedPairs) + ZASSERTSTATE(-1 != group); + int row = 0; + for (auto it = imageGroups[group].pictures->begin(); it != imageGroups[group].pictures->end(); ++it) { - int group = Group::whichGroupContains(file); - - ZASSERTSTATE(-1 != group); - int row = 0; - for (auto it = imageGroups[group].pictures->begin(); it != imageGroups[group].pictures->end(); ++it) + if (file == it->filePath) { - if (file == it->filePath) - { - it->m_bDeltaComputed = true; - imageGroups[group].pictures->setData(row, Column::dX, xOffset); - imageGroups[group].pictures->setData(row, Column::dY, yOffset); - imageGroups[group].pictures->setData(row, Column::Angle, angle); - it->m_Transformation = transform; - it->m_vVotedPairs = vVotedPairs; + it->m_bDeltaComputed = false; + // + // Ask the Table Model to tell the table view which rows/columns have changed + // + if (index == group) + imageGroups[group].pictures->emitChanged(row, row, + static_cast(Column::dX), + static_cast(Column::Angle)); + return; + } + ++row; + } +}; - return; - } - ++row; +void FrameList::updateOffset(fs::path file, double xOffset, double yOffset, double angle, const CBilinearParameters& transform, const VOTINGPAIRVECTOR vVotedPairs) +{ + int group = Group::whichGroupContains(file); + + ZASSERTSTATE(-1 != group); + int row = 0; + for (auto it = imageGroups[group].pictures->begin(); it != imageGroups[group].pictures->end(); ++it) + { + if (file == it->filePath) + { + it->m_bDeltaComputed = true; + imageGroups[group].pictures->setData(row, Column::dX, xOffset); + imageGroups[group].pictures->setData(row, Column::dY, yOffset); + imageGroups[group].pictures->setData(row, Column::Angle, angle); + it->m_Transformation = transform; + it->m_vVotedPairs = vVotedPairs; + + return; } - }; + ++row; + } +}; - QString FrameList::getReferenceFrame() +QString FrameList::getReferenceFrame() +{ + for (const auto& group : imageGroups) { - for (const auto& group : imageGroups) + for (auto it = group.pictures->cbegin(); it != group.pictures->cend(); ++it) { - for (auto it = group.pictures->cbegin(); it != group.pictures->cend(); ++it) + if (it->IsLightFrame() && + it->m_bChecked == Qt::Checked && + it->m_bUseAsStarting + ) { - if (it->IsLightFrame() && - it->m_bChecked == Qt::Checked && - it->m_bUseAsStarting - ) - { - return QString::fromStdU16String(it->filePath.generic_u16string()); - } + return QString::fromStdU16String(it->filePath.generic_u16string()); } } - return QString(); } + return QString(); +} - bool FrameList::getReferenceFrame(CString& string) +bool FrameList::getReferenceFrame(CString& string) +{ + bool result = false; + for (const auto& group : imageGroups) { - bool result = false; - for (const auto& group : imageGroups) + for (auto it = group.pictures->cbegin(); it != group.pictures->cend(); ++it) { - for (auto it = group.pictures->cbegin(); it != group.pictures->cend(); ++it) + if (it->IsLightFrame() && + it->m_bChecked == Qt::Checked && + it->m_bUseAsStarting + ) { - if (it->IsLightFrame() && - it->m_bChecked == Qt::Checked && - it->m_bUseAsStarting - ) - { - string = it->filePath.generic_wstring().c_str(); - } + string = it->filePath.generic_wstring().c_str(); } } - return result; } + return result; +} - QString FrameList::getFirstCheckedLightFrame() +QString FrameList::getFirstCheckedLightFrame() +{ + for (const auto& group : imageGroups) { - for (const auto& group : imageGroups) + for (auto it = group.pictures->cbegin(); it != group.pictures->cend(); ++it) { - for (auto it = group.pictures->cbegin(); it != group.pictures->cend(); ++it) + if (it->IsLightFrame() && it->m_bChecked == Qt::Checked) { - if (it->IsLightFrame() && it->m_bChecked == Qt::Checked) - { - return QString::fromStdU16String(it->filePath.generic_u16string()); - }; + return QString::fromStdU16String(it->filePath.generic_u16string()); }; - } + }; + } - return QString(); - }; + return QString(); +}; - void FrameList::fillTasks(CAllStackingTasks& tasks) - { - size_t comets = 0; - bool bReferenceFrameHasComet = false; - bool bReferenceFrameSet = false; - double fMaxScore = -1.0; +void FrameList::fillTasks(CAllStackingTasks& tasks) +{ + size_t comets = 0; + bool bReferenceFrameHasComet = false; + bool bReferenceFrameSet = false; + double fMaxScore = -1.0; - // Iterate over all groups. - for (uint16_t group = 0; group != imageGroups.size(); ++group) + // Iterate over all groups. + for (uint16_t group = 0; group != imageGroups.size(); ++group) + { + // and then over each image in the group + for (auto it = imageGroups[group].pictures->cbegin(); + it != imageGroups[group].pictures->cend(); ++it) { - // and then over each image in the group - for (auto it = imageGroups[group].pictures->cbegin(); - it != imageGroups[group].pictures->cend(); ++it) + if (it->m_bChecked == Qt::Checked) { - if (it->m_bChecked == Qt::Checked) + if (it->m_bUseAsStarting) { - if (it->m_bUseAsStarting) - { - bReferenceFrameSet = true; - bReferenceFrameHasComet = it->m_bComet; - } - if (!bReferenceFrameSet && (it->m_fOverallQuality > fMaxScore)) - { - fMaxScore = it->m_fOverallQuality; - bReferenceFrameHasComet = it->m_bComet; - } - tasks.AddFileToTask(*it, group); - if (it->m_bComet) - comets++; + bReferenceFrameSet = true; + bReferenceFrameHasComet = it->m_bComet; } + if (!bReferenceFrameSet && (it->m_fOverallQuality > fMaxScore)) + { + fMaxScore = it->m_fOverallQuality; + bReferenceFrameHasComet = it->m_bComet; + } + tasks.AddFileToTask(*it, group); + if (it->m_bComet) + comets++; } } + } - if (comets > 1 && bReferenceFrameHasComet) - tasks.SetCometAvailable(true); - tasks.ResolveTasks(); - }; + if (comets > 1 && bReferenceFrameHasComet) + tasks.SetCometAvailable(true); + tasks.ResolveTasks(); +}; - /* ------------------------------------------------------------------- */ +/* ------------------------------------------------------------------- */ - FrameList& FrameList::saveListToFile(fs::path file) - { - if (std::FILE* hFile = +FrameList& FrameList::saveListToFile(fs::path file) +{ + if (std::FILE* hFile = #if defined(_WINDOWS) - _wfopen(file.c_str(), L"wt") + _wfopen(file.c_str(), L"wt") #else - std::fopen(file.c_ctr(), "wt") + std::fopen(file.c_ctr(), "wt") #endif - ) - { - fs::path directory; + ) + { + fs::path directory; - if (file.has_parent_path()) - directory = file.parent_path(); - else - directory = file.root_path(); + if (file.has_parent_path()) + directory = file.parent_path(); + else + directory = file.root_path(); - fprintf(hFile, "DSS file list\n"); - fprintf(hFile, "CHECKED\tTYPE\tFILE\n"); + fprintf(hFile, "DSS file list\n"); + fprintf(hFile, "CHECKED\tTYPE\tFILE\n"); - uint16_t groupId = 0; + uint16_t groupId = 0; - for (auto &g : imageGroups) + for (auto &g : imageGroups) + { + // and then over each image in the group + for (auto it = g.pictures->cbegin(); + it != g.pictures->cend(); ++it) { - // and then over each image in the group - for (auto it = g.pictures->cbegin(); - it != g.pictures->cend(); ++it) - { - long checked{ 0 }; - QString type; + long checked{ 0 }; + QString type; - if (groupId != it->m_groupId) - { - groupId = it->m_groupId; - fprintf(hFile, "#GROUPID#%hu\t%s\n", groupId, g.name().toUtf8().constData()); - }; - checked = it->m_bChecked == Qt::Checked ? 1L : 0L; - if (it->IsLightFrame()) - { - if (it->m_bUseAsStarting) - type = "reflight"; - else - type = "light"; - } - else if (it->IsDarkFrame()) - type = "dark"; - else if (it->IsDarkFlatFrame()) - type = "darkflat"; - else if (it->IsOffsetFrame()) - type = "offset"; - else if (it->IsFlatFrame()) - type = "flat"; - - // - // Convert the path to the file to one that is relative to - // the directory containing the file list file of that's possible. - // If not just leave it as the absolute path. - // - fs::path path{ it->filePath.lexically_proximate(directory) }; - fprintf(hFile, "%ld\t%s\t%s\n", checked, - type.toUtf8().constData(), - path.generic_string().c_str()); + if (groupId != it->m_groupId) + { + groupId = it->m_groupId; + fprintf(hFile, "#GROUPID#%hu\t%s\n", groupId, g.name().toUtf8().constData()); + }; + checked = it->m_bChecked == Qt::Checked ? 1L : 0L; + if (it->IsLightFrame()) + { + if (it->m_bUseAsStarting) + type = "reflight"; + else + type = "light"; } - g.setDirty(false); - }; + else if (it->IsDarkFrame()) + type = "dark"; + else if (it->IsDarkFlatFrame()) + type = "darkflat"; + else if (it->IsOffsetFrame()) + type = "offset"; + else if (it->IsFlatFrame()) + type = "flat"; + + // + // Convert the path to the file to one that is relative to + // the directory containing the file list file of that's possible. + // If not just leave it as the absolute path. + // + fs::path path{ it->filePath.lexically_proximate(directory) }; + fprintf(hFile, "%ld\t%s\t%s\n", checked, + type.toUtf8().constData(), + path.generic_string().c_str()); + } + g.setDirty(false); + }; - Workspace workspace; + Workspace workspace; - workspace.SaveToFile(hFile); - workspace.resetDirty(); + workspace.SaveToFile(hFile); + workspace.resetDirty(); - fclose(hFile); - } - return *this; + fclose(hFile); } + return *this; +} - /* ------------------------------------------------------------------- */ +/* ------------------------------------------------------------------- */ - FrameList& FrameList::loadFilesFromList(fs::path fileList) - { - uint16_t groupId = 0; - std::error_code ec; +FrameList& FrameList::loadFilesFromList(fs::path fileList) +{ + uint16_t groupId = 0; + std::error_code ec; - // - // Remember current directory and extract directory containing filelist - // - fs::path directory; + // + // Remember current directory and extract directory containing filelist + // + fs::path directory; - if (fileList.has_parent_path()) - directory = fileList.parent_path(); - else - directory = fileList.root_path(); + if (fileList.has_parent_path()) + directory = fileList.parent_path(); + else + directory = fileList.root_path(); - fs::path oldCWD{ fs::current_path(ec) }; // Save CWD + fs::path oldCWD{ fs::current_path(ec) }; // Save CWD - if (ec) - { - ZTRACE_RUNTIME("fs::current_path() failed with error code %ld, %s", - ec.value(), ec.message().c_str()); - } + if (ec) + { + ZTRACE_RUNTIME("fs::current_path() failed with error code %ld, %s", + ec.value(), ec.message().c_str()); + } - if (std::FILE* hFile = + if (std::FILE* hFile = #if defined(_WINDOWS) - _wfopen(fileList.c_str(), L"rt") + _wfopen(fileList.c_str(), L"rt") #else - std::fopen(fileList.c_ctr(), "rt") + std::fopen(fileList.c_ctr(), "rt") #endif - ) + ) + { + CHAR szBuffer[2000]; + QString strValue; + bool bContinue = false; + + fs::current_path(directory, ec); // Set CWD to fileList dir + if (!ec) + bContinue = true; + else { - CHAR szBuffer[2000]; - QString strValue; - bool bContinue = false; + ZTRACE_RUNTIME("fs::current_path(%s) failed with error code %ld, %s", + directory.generic_string().c_str(), ec.value(), ec.message().c_str()); + bContinue = false; + } - fs::current_path(directory, ec); // Set CWD to fileList dir - if (!ec) + // Read scan line + if (fgets(szBuffer, sizeof(szBuffer), hFile)) + { + strValue = QString::fromUtf8(szBuffer); + if (!strValue.compare("DSS file list\n", Qt::CaseInsensitive)) bContinue = true; - else - { - ZTRACE_RUNTIME("fs::current_path(%s) failed with error code %ld, %s", - directory.generic_string().c_str(), ec.value(), ec.message().c_str()); - bContinue = false; - } + } - // Read scan line + if (bContinue) + { + bContinue = false; if (fgets(szBuffer, sizeof(szBuffer), hFile)) { strValue = QString::fromUtf8(szBuffer); - if (!strValue.compare("DSS file list\n", Qt::CaseInsensitive)) + if (!strValue.compare("CHECKED\tTYPE\tFILE\n", Qt::CaseInsensitive)) bContinue = true; } + }; - if (bContinue) - { - bContinue = false; - if (fgets(szBuffer, sizeof(szBuffer), hFile)) - { - strValue = QString::fromUtf8(szBuffer); - if (!strValue.compare("CHECKED\tTYPE\tFILE\n", Qt::CaseInsensitive)) - bContinue = true; - } - }; + if (bContinue) + { + // Read the file info + Workspace workspace; + CHAR szLine[10000]; - if (bContinue) + while (fgets(szLine, sizeof(szLine), hFile)) { - // Read the file info - Workspace workspace; - CHAR szLine[10000]; + std::int32_t checkState(Qt::Unchecked); + QString strType; + QString strFile; + QString strGroupName; + QString strLine{ QString::fromUtf8(szLine).trimmed() }; - while (fgets(szLine, sizeof(szLine), hFile)) - { - std::int32_t checkState(Qt::Unchecked); - QString strType; - QString strFile; - QString strGroupName; - QString strLine{ QString::fromUtf8(szLine).trimmed() }; + bool bUseAsStarting = false; - bool bUseAsStarting = false; + if (workspace.ReadFromString(strLine)) + { + } + else if (isChangeGroupLine(strLine, groupId, strGroupName)) + { + // + // Zero index groupId must be same as count of groups when adding + // a group + // + if (groupId == imageGroups.size()) + static_cast(addGroup()); + ZASSERTSTATE(groupId < (1 + imageGroups.size())); - if (workspace.ReadFromString(strLine)) + setGroup(groupId); // Select the group in question + if (!strGroupName.isEmpty()) + imageGroups[groupId].setName(strGroupName); + } + else if (parseLine(strLine, checkState, strType, strFile)) + { + PICTURETYPE Type = PICTURETYPE_UNKNOWN; + + if ("light" == strType) + Type = PICTURETYPE_LIGHTFRAME; + else if ("dark" == strType) + Type = PICTURETYPE_DARKFRAME; + else if ("darkflat" == strType) + Type = PICTURETYPE_DARKFLATFRAME; + else if ("flat" == strType) + Type = PICTURETYPE_FLATFRAME; + else if ("offset" == strType) + Type = PICTURETYPE_OFFSETFRAME; + else if ("reflight" == strType) { - } - else if (isChangeGroupLine(strLine, groupId, strGroupName)) + Type = PICTURETYPE_REFLIGHTFRAME; + bUseAsStarting = true; + }; + + if (Type != PICTURETYPE_UNKNOWN) { // - // Zero index groupId must be same as count of groups when adding - // a group + // Convert relative path to absolute path. // - if (groupId == imageGroups.size()) - static_cast(addGroup()); - ZASSERTSTATE(groupId < (1 + imageGroups.size())); + fs::path filePath{ strFile.toStdU16String() }; - setGroup(groupId); // Select the group in question - if (!strGroupName.isEmpty()) - imageGroups[groupId].setName(strGroupName); - } - else if (parseLine(strLine, checkState, strType, strFile)) - { - PICTURETYPE Type = PICTURETYPE_UNKNOWN; - - if ("light" == strType) - Type = PICTURETYPE_LIGHTFRAME; - else if ("dark" == strType) - Type = PICTURETYPE_DARKFRAME; - else if ("darkflat" == strType) - Type = PICTURETYPE_DARKFLATFRAME; - else if ("flat" == strType) - Type = PICTURETYPE_FLATFRAME; - else if ("offset" == strType) - Type = PICTURETYPE_OFFSETFRAME; - else if ("reflight" == strType) + // If it's not already an absolute path + if (!filePath.is_absolute()) + { + filePath = fs::absolute(filePath, ec); + } + + if (ec) { - Type = PICTURETYPE_REFLIGHTFRAME; - bUseAsStarting = true; - }; + ZTRACE_RUNTIME("fs::absolute(%s) failed with error code %ld, %s", + filePath.generic_u8string().c_str(), ec.value(), ec.message().c_str()); + } - if (Type != PICTURETYPE_UNKNOWN) + // Check that the file exists and that it hasn't already been loaded + if (is_regular_file(filePath)) { // - // Convert relative path to absolute path. + // Check all groups to see if this file has already been loaded // - fs::path filePath{ strFile.toStdU16String() }; - - // If it's not already an absolute path - if (!filePath.is_absolute()) - { - filePath = fs::absolute(filePath, ec); - } - - if (ec) - { - ZTRACE_RUNTIME("fs::absolute(%s) failed with error code %ld, %s", - filePath.generic_u8string().c_str(), ec.value(), ec.message().c_str()); - } - - // Check that the file exists and that it hasn't already been loaded - if (is_regular_file(filePath)) + if (auto groupId = Group::whichGroupContains(filePath); groupId != -1) { // - // Check all groups to see if this file has already been loaded + // If the file has already been loaded complain // - if (auto groupId = Group::whichGroupContains(filePath); groupId != -1) - { - // - // If the file has already been loaded complain - // - QString errorMessage( - QCoreApplication::translate("DSS::StackingDlg", "File %1 has already been loaded in group %2 (%3)") - .arg(filePath.generic_string().c_str()) - .arg(groupId) - .arg(groupName(groupId))); + QString errorMessage( + QCoreApplication::translate("DSS::StackingDlg", "File %1 has already been loaded in group %2 (%3)") + .arg(filePath.generic_string().c_str()) + .arg(groupId) + .arg(groupName(groupId))); #if defined(_CONSOLE) - std::cerr << errorMessage.toStdString(); + std::cerr << errorMessage.toStdString(); #else - int ret = QMessageBox::warning(nullptr, "DeepSkyStacker", - errorMessage, - QMessageBox::Ok); + int ret = QMessageBox::warning(nullptr, "DeepSkyStacker", + errorMessage, + QMessageBox::Ok); #endif - return *this; - } - else - { - beginInsertRows(1); - addFile(filePath, Type, (checkState == 1)); - endInsertRows(); - } + return *this; + } + else + { + beginInsertRows(1); + addFile(filePath, Type, (checkState == 1)); + endInsertRows(); } } + } - }; }; - - workspace.resetDirty(); }; - fclose(hFile); - } + workspace.resetDirty(); + }; - fs::current_path(oldCWD); - setDirty(false); - return *this; + fclose(hFile); } - void FrameList::blankCheckedItemScores() + fs::current_path(oldCWD); + setDirty(false); + return *this; +} + +void FrameList::blankCheckedItemScores() +{ + // Iterate over all groups. + for (uint16_t group = 0; group != imageGroups.size(); ++group) { - // Iterate over all groups. - for (uint16_t group = 0; group != imageGroups.size(); ++group) + // and then over each image in the group + for (auto it = imageGroups[group].pictures->begin(); + it != imageGroups[group].pictures->end(); ++it) { - // and then over each image in the group - for (auto it = imageGroups[group].pictures->begin(); - it != imageGroups[group].pictures->end(); ++it) + if (it->m_bChecked == Qt::Checked && it->IsLightFrame()) { - if (it->m_bChecked == Qt::Checked && it->IsLightFrame()) - { - it->m_bRegistered = false; - } + it->m_bRegistered = false; } } + } - }; +}; - bool FrameList::areCheckedImagesCompatible(QString& reason) +bool FrameList::areCheckedImagesCompatible(QString& reason) +{ + bool bResult = true; + bool bFirst = true; + const ListBitMap* lb; + int lNrDarks = 0; + int lNrDarkFlats = 0; + int lNrFlats = 0; + int lNrOffsets = 0; + bool bMasterDark = false; + bool bMasterFlat = false; + bool bMasterDarkFlat = false; + bool bMasterOffset = false; + + // Iterate over all groups. + for (uint16_t group = 0; group != imageGroups.size() && true == bResult; ++group) { - bool bResult = true; - bool bFirst = true; - const ListBitMap* lb; - int lNrDarks = 0; - int lNrDarkFlats = 0; - int lNrFlats = 0; - int lNrOffsets = 0; - bool bMasterDark = false; - bool bMasterFlat = false; - bool bMasterDarkFlat = false; - bool bMasterOffset = false; - - // Iterate over all groups. - for (uint16_t group = 0; group != imageGroups.size() && true == bResult; ++group) + // and then over each image in the group + for (auto it = imageGroups[group].pictures->cbegin(); + it != imageGroups[group].pictures->cend(); ++it) { - // and then over each image in the group - for (auto it = imageGroups[group].pictures->cbegin(); - it != imageGroups[group].pictures->cend(); ++it) + if (it->m_bChecked == Qt::Checked) { - if (it->m_bChecked == Qt::Checked) + if (bFirst) { - if (bFirst) - { - lb = &(*it); - bFirst = false; - } - else + lb = &(*it); + bFirst = false; + } + else + { + bResult = lb->IsCompatible(*it); + if (false == bResult) { - bResult = lb->IsCompatible(*it); - if (false == bResult) - { - reason = lb->incompatibilityReason; - break; - } + reason = lb->incompatibilityReason; + break; } } } } + } #if (0) - if (bResult) + if (bResult) + { + if (bMasterDark && lNrDarks > 1) { - if (bMasterDark && lNrDarks > 1) - { - reason = QCoreApplication::translate("DSS::StackingDlg", "A Master Dark must be the only Dark frame"); - bResult = false; - } - if (bMasterDarkFlat && lNrDarkFlats > 1) - { - reason = QCoreApplication::translate("DSS::StackingDlg", "A Master Dark Flat must be the only Dark Flat frame"); - bResult = false; - } - if (bMasterFlat && lNrFlats > 1) - { - reason = QCoreApplication::translate("DSS::StackingDlg", "A Master Flat must be the only Flat frame"); - bResult = false; - } - if (bMasterOffset && lNrOffsets > 1) - { - reason = QCoreApplication::translate("DSS::StackingDlg", "A Master Offset must be the only Offset frame"); - bResult = false; - } - }; -#endif - - return bResult; + reason = QCoreApplication::translate("DSS::StackingDlg", "A Master Dark must be the only Dark frame"); + bResult = false; + } + if (bMasterDarkFlat && lNrDarkFlats > 1) + { + reason = QCoreApplication::translate("DSS::StackingDlg", "A Master Dark Flat must be the only Dark Flat frame"); + bResult = false; + } + if (bMasterFlat && lNrFlats > 1) + { + reason = QCoreApplication::translate("DSS::StackingDlg", "A Master Flat must be the only Flat frame"); + bResult = false; + } + if (bMasterOffset && lNrOffsets > 1) + { + reason = QCoreApplication::translate("DSS::StackingDlg", "A Master Offset must be the only Offset frame"); + bResult = false; + } }; +#endif - /* ------------------------------------------------------------------- */ - + return bResult; +}; - void FrameList::updateCheckedItemScores() - { - int row = 0; - - // Iterate over all groups. - for (uint16_t group = 0; group != imageGroups.size(); ++group) - { - // and then over each image in the group - for (auto it = imageGroups[group].pictures->begin(); - it != imageGroups[group].pictures->end(); ++it) - { - if (it->m_bChecked == Qt::Checked && - it->IsLightFrame()) - { - CLightFrameInfo bmpInfo; +/* ------------------------------------------------------------------- */ - bmpInfo.SetBitmap(it->filePath, false, false); - // - // Update list information, but beware that you must use setData() for any of the columns - // that are defined in the Column enumeration as they are used for the - // QTableView. If this isn't done, the image list view won't get updated. - // - // The "Sky Background" (Column::BackgroundCol) is a special case it's a class, not a primitive, so the model - // class has a specific member function to set that. - // - // Other member of ListBitMap (e.g.) m_bRegistered and m_bComet can be updated directly. - // - if (bmpInfo.m_bInfoOk) - { - it->m_bRegistered = true; - imageGroups[group].pictures->setData(row, Column::Score, bmpInfo.m_fOverallQuality); - imageGroups[group].pictures->setData(row, Column::FWHM, bmpInfo.m_fFWHM); - it->m_bComet = bmpInfo.m_bComet; // MUST Set this Before updating Column::Stars - imageGroups[group].pictures->setData(row, Column::Stars, (int)bmpInfo.m_vStars.size()); - imageGroups[group].pictures->setData(row, Column::Background, (uint32_t)bmpInfo.m_vStars.size()); - imageGroups[group].pictures->setSkyBackground(row, bmpInfo.m_SkyBackground); - - } - else - { - it->m_bRegistered = false; - } - } - ++row; - } - } - } +void FrameList::updateCheckedItemScores() +{ + int row = 0; - void FrameList::updateItemScores(const QString& fileName) + // Iterate over all groups. + for (uint16_t group = 0; group != imageGroups.size(); ++group) { - int row = 0; - - for (auto it = imageGroups[index].pictures->begin(); - it != imageGroups[index].pictures->end(); ++it) + // and then over each image in the group + for (auto it = imageGroups[group].pictures->begin(); + it != imageGroups[group].pictures->end(); ++it) { - if (it->filePath == fs::path(fileName.toStdString()) && it->IsLightFrame()) + if (it->m_bChecked == Qt::Checked && + it->IsLightFrame()) { CLightFrameInfo bmpInfo; @@ -720,12 +724,12 @@ namespace DSS if (bmpInfo.m_bInfoOk) { it->m_bRegistered = true; - imageGroups[index].pictures->setData(row, Column::Score, bmpInfo.m_fOverallQuality); - imageGroups[index].pictures->setData(row, Column::FWHM, bmpInfo.m_fFWHM); + imageGroups[group].pictures->setData(row, Column::Score, bmpInfo.m_fOverallQuality); + imageGroups[group].pictures->setData(row, Column::FWHM, bmpInfo.m_fFWHM); it->m_bComet = bmpInfo.m_bComet; // MUST Set this Before updating Column::Stars - imageGroups[index].pictures->setData(row, Column::Stars, (int)bmpInfo.m_vStars.size()); - imageGroups[index].pictures->setData(row, Column::Background, (uint32_t)bmpInfo.m_vStars.size()); - imageGroups[index].pictures->setSkyBackground(row, bmpInfo.m_SkyBackground); + imageGroups[group].pictures->setData(row, Column::Stars, (int)bmpInfo.m_vStars.size()); + imageGroups[group].pictures->setData(row, Column::Background, (uint32_t)bmpInfo.m_vStars.size()); + imageGroups[group].pictures->setSkyBackground(row, bmpInfo.m_SkyBackground); } else @@ -736,240 +740,281 @@ namespace DSS ++row; } } +} + +void FrameList::updateItemScores(const QString& fileName) +{ + int row = 0; - void FrameList::checkAll(bool check) + for (auto it = imageGroups[index].pictures->begin(); + it != imageGroups[index].pictures->end(); ++it) { - for (int id = 0; id != imageGroups.size(); ++id) + if (it->filePath == fs::path(fileName.toStdString()) && it->IsLightFrame()) { - auto& group = imageGroups[id]; - for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) + CLightFrameInfo bmpInfo; + + bmpInfo.SetBitmap(it->filePath, false, false); + + // + // Update list information, but beware that you must use setData() for any of the columns + // that are defined in the Column enumeration as they are used for the + // QTableView. If this isn't done, the image list view won't get updated. + // + // The "Sky Background" (Column::BackgroundCol) is a special case it's a class, not a primitive, so the model + // class has a specific member function to set that. + // + // Other member of ListBitMap (e.g.) m_bRegistered and m_bComet can be updated directly. + // + if (bmpInfo.m_bInfoOk) + { + it->m_bRegistered = true; + imageGroups[index].pictures->setData(row, Column::Score, bmpInfo.m_fOverallQuality); + imageGroups[index].pictures->setData(row, Column::FWHM, bmpInfo.m_fFWHM); + it->m_bComet = bmpInfo.m_bComet; // MUST Set this Before updating Column::Stars + imageGroups[index].pictures->setData(row, Column::Stars, (int)bmpInfo.m_vStars.size()); + imageGroups[index].pictures->setData(row, Column::Background, (uint32_t)bmpInfo.m_vStars.size()); + imageGroups[index].pictures->setSkyBackground(row, bmpInfo.m_SkyBackground); + + } + else + { + it->m_bRegistered = false; + } + } + ++row; + } +} + +void FrameList::checkAll(bool check) +{ + for (int id = 0; id != imageGroups.size(); ++id) + { + auto& group = imageGroups[id]; + for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) + { + auto& file = group.pictures->mydata[index]; + if (check) file.m_bChecked = Qt::Checked; + else file.m_bChecked = Qt::Unchecked; + } + QModelIndex start{ group.pictures->createIndex(0, 0) }; + QModelIndex end{ group.pictures->createIndex(group.pictures->rowCount(), 0) }; + QVector role{ Qt::CheckStateRole }; + group.pictures->dataChanged(start, end, role); + group.setDirty(); + } +} + +void FrameList::checkAllDarks(bool check) +{ + for (int id = 0; id != imageGroups.size(); ++id) + { + auto& group = imageGroups[id]; + for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) + { + auto& file = group.pictures->mydata[index]; + if (file.IsDarkFrame()) { - auto& file = group.pictures->mydata[index]; if (check) file.m_bChecked = Qt::Checked; else file.m_bChecked = Qt::Unchecked; } - QModelIndex start{ group.pictures->createIndex(0, 0) }; - QModelIndex end{ group.pictures->createIndex(group.pictures->rowCount(), 0) }; + QModelIndex start{ group.pictures->createIndex(index, 0) }; + QModelIndex end{ group.pictures->createIndex(index, 0) }; QVector role{ Qt::CheckStateRole }; group.pictures->dataChanged(start, end, role); - group.setDirty(); } + + group.setDirty(); } +} +/* ------------------------------------------------------------------- */ - void FrameList::checkAllDarks(bool check) +void FrameList::checkAllFlats(bool check) +{ + for (int id = 0; id != imageGroups.size(); ++id) { - for (int id = 0; id != imageGroups.size(); ++id) + auto& group = imageGroups[id]; + for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) { - auto& group = imageGroups[id]; - for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) + auto& file = group.pictures->mydata[index]; + if (file.IsFlatFrame()) { - auto& file = group.pictures->mydata[index]; - if (file.IsDarkFrame()) - { - if (check) file.m_bChecked = Qt::Checked; - else file.m_bChecked = Qt::Unchecked; - } - QModelIndex start{ group.pictures->createIndex(index, 0) }; - QModelIndex end{ group.pictures->createIndex(index, 0) }; - QVector role{ Qt::CheckStateRole }; - group.pictures->dataChanged(start, end, role); + if (check) file.m_bChecked = Qt::Checked; + else file.m_bChecked = Qt::Unchecked; } - - group.setDirty(); + QModelIndex start{ group.pictures->createIndex(index, 0) }; + QModelIndex end{ group.pictures->createIndex(index, 0) }; + QVector role{ Qt::CheckStateRole }; + group.pictures->dataChanged(start, end, role); } + + group.setDirty(); } - /* ------------------------------------------------------------------- */ +} + +/* ------------------------------------------------------------------- */ - void FrameList::checkAllFlats(bool check) +void FrameList::checkAllOffsets(bool check) +{ + for (int id = 0; id != imageGroups.size(); ++id) { - for (int id = 0; id != imageGroups.size(); ++id) + auto& group = imageGroups[id]; + for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) { - auto& group = imageGroups[id]; - for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) + auto& file = group.pictures->mydata[index]; + if (file.IsOffsetFrame()) { - auto& file = group.pictures->mydata[index]; - if (file.IsFlatFrame()) - { - if (check) file.m_bChecked = Qt::Checked; - else file.m_bChecked = Qt::Unchecked; - } - QModelIndex start{ group.pictures->createIndex(index, 0) }; - QModelIndex end{ group.pictures->createIndex(index, 0) }; - QVector role{ Qt::CheckStateRole }; - group.pictures->dataChanged(start, end, role); + if (check) file.m_bChecked = Qt::Checked; + else file.m_bChecked = Qt::Unchecked; } - - group.setDirty(); + QModelIndex start{ group.pictures->createIndex(index, 0) }; + QModelIndex end{ group.pictures->createIndex(index, 0) }; + QVector role{ Qt::CheckStateRole }; + group.pictures->dataChanged(start, end, role); } + + group.setDirty(); } +} - /* ------------------------------------------------------------------- */ +/* ------------------------------------------------------------------- */ - void FrameList::checkAllOffsets(bool check) +void FrameList::checkAllLights(bool check) +{ + for (int id = 0; id != imageGroups.size(); ++id) { - for (int id = 0; id != imageGroups.size(); ++id) + auto& group = imageGroups[id]; + for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) { - auto& group = imageGroups[id]; - for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) + auto& file = group.pictures->mydata[index]; + if (file.IsLightFrame()) { - auto& file = group.pictures->mydata[index]; - if (file.IsOffsetFrame()) - { - if (check) file.m_bChecked = Qt::Checked; - else file.m_bChecked = Qt::Unchecked; - } + if (check) file.m_bChecked = Qt::Checked; + else file.m_bChecked = Qt::Unchecked; QModelIndex start{ group.pictures->createIndex(index, 0) }; QModelIndex end{ group.pictures->createIndex(index, 0) }; QVector role{ Qt::CheckStateRole }; group.pictures->dataChanged(start, end, role); } - - group.setDirty(); } + group.setDirty(); } +} - /* ------------------------------------------------------------------- */ - - void FrameList::checkAllLights(bool check) +void FrameList::checkImage(const QString & image, bool check) +{ + for (int id = 0; id != imageGroups.size(); ++id) { - for (int id = 0; id != imageGroups.size(); ++id) + auto& group = imageGroups[id]; + for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) { - auto& group = imageGroups[id]; - for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) + auto& file = group.pictures->mydata[index]; + if (image == file.m_strFile && file.IsLightFrame()) { - auto& file = group.pictures->mydata[index]; - if (file.IsLightFrame()) - { - if (check) file.m_bChecked = Qt::Checked; - else file.m_bChecked = Qt::Unchecked; - QModelIndex start{ group.pictures->createIndex(index, 0) }; - QModelIndex end{ group.pictures->createIndex(index, 0) }; - QVector role{ Qt::CheckStateRole }; - group.pictures->dataChanged(start, end, role); - } + if (check) file.m_bChecked = Qt::Checked; + else file.m_bChecked = Qt::Unchecked; + group.setDirty(); + QModelIndex start{ group.pictures->createIndex(index, 0) }; + QModelIndex end{ group.pictures->createIndex(index, 0) }; + QVector role{ Qt::CheckStateRole }; + group.pictures->dataChanged(start, end, role); + return; } - group.setDirty(); } } +}; +/* ------------------------------------------------------------------- */ - void FrameList::checkImage(const QString & image, bool check) + +void FrameList::checkAbove(double threshold) +{ + for (int id = 0; id != imageGroups.size(); ++id) { - for (int id = 0; id != imageGroups.size(); ++id) + auto& group = imageGroups[id]; + for (int index = 0; index != group.pictures->mydata.size(); ++index) { - auto& group = imageGroups[id]; - for (int32_t index = 0; index < group.pictures->mydata.size(); ++index) + auto& file = group.pictures->mydata[index]; + if (file.IsLightFrame()) { - auto& file = group.pictures->mydata[index]; - if (image == file.m_strFile && file.IsLightFrame()) - { - if (check) file.m_bChecked = Qt::Checked; - else file.m_bChecked = Qt::Unchecked; - group.setDirty(); - QModelIndex start{ group.pictures->createIndex(index, 0) }; - QModelIndex end{ group.pictures->createIndex(index, 0) }; - QVector role{ Qt::CheckStateRole }; - group.pictures->dataChanged(start, end, role); - return; - } + file.m_bChecked = + (file.m_fOverallQuality >= threshold) ? Qt::Checked : Qt::Unchecked; + QModelIndex start{ group.pictures->createIndex(index, 0) }; + QModelIndex end{ group.pictures->createIndex(index, 0) }; + QVector role{ Qt::CheckStateRole }; + group.pictures->dataChanged(start, end, role); } } + group.setDirty(); }; - /* ------------------------------------------------------------------- */ +}; - void FrameList::checkAbove(double threshold) - { - for (int id = 0; id != imageGroups.size(); ++id) - { - auto& group = imageGroups[id]; - for (int index = 0; index != group.pictures->mydata.size(); ++index) - { - auto& file = group.pictures->mydata[index]; - if (file.IsLightFrame()) - { - file.m_bChecked = - (file.m_fOverallQuality >= threshold) ? Qt::Checked : Qt::Unchecked; - QModelIndex start{ group.pictures->createIndex(index, 0) }; - QModelIndex end{ group.pictures->createIndex(index, 0) }; - QVector role{ Qt::CheckStateRole }; - group.pictures->dataChanged(start, end, role); - } - } - group.setDirty(); - }; - - }; - - /* ------------------------------------------------------------------- */ +/* ------------------------------------------------------------------- */ - void FrameList::changePictureType(int nItem, PICTURETYPE PictureType) - { - qDebug() << "In " << +void FrameList::changePictureType(int nItem, PICTURETYPE PictureType) +{ + qDebug() << "In " << #ifdef __FUNCSIG__ - __FUNCSIG__; + __FUNCSIG__; #elif defined(__PRETTY_FUNCTION__) - __PRETTY_FUNCTION__; + __PRETTY_FUNCTION__; #else - __FUNCTION__; + __FUNCTION__; #endif - //LONG lIndice; TODO - //CString strFileName; + //LONG lIndice; TODO + //CString strFileName; - //strFileName = m_vFiles[mItem].m_strFileName; - //virtual bool addFile(fs::path file, PICTURETYPE PictureType = PICTURETYPE_LIGHTFRAME, bool bCheck = false, int nItem = -1) - //addFile(strFileName, m_dwCurrentGroupID, m_dwCurrentJobID, PictureType, FALSE, nItem); - }; + //strFileName = m_vFiles[mItem].m_strFileName; + //virtual bool addFile(fs::path file, PICTURETYPE PictureType = PICTURETYPE_LIGHTFRAME, bool bCheck = false, int nItem = -1) + //addFile(strFileName, m_dwCurrentGroupID, m_dwCurrentJobID, PictureType, FALSE, nItem); +}; - /* ------------------------------------------------------------------- */ +/* ------------------------------------------------------------------- */ - void FrameList::checkBest(double fPercent) - { - std::vector lightFrames; +void FrameList::checkBest(double fPercent) +{ + std::vector lightFrames; - for (auto & group : imageGroups) + for (auto & group : imageGroups) + { + for (size_t i = 0; i != group.pictures->mydata.size(); ++i) { - for (size_t i = 0; i != group.pictures->mydata.size(); ++i) - { - const auto& file = group.pictures->mydata[i]; - if (file.IsLightFrame()) - lightFrames.emplace_back(group.index(), - static_cast(i), - file.m_fOverallQuality); - } - group.setDirty(); + const auto& file = group.pictures->mydata[i]; + if (file.IsLightFrame()) + lightFrames.emplace_back(group.index(), + static_cast(i), + file.m_fOverallQuality); } + group.setDirty(); + } - const int last = static_cast(fPercent * lightFrames.size() / 100.0); - // - // Sort in *descending* order (see operator < in class definition) - std::sort(lightFrames.begin(), lightFrames.end()); - - for (size_t i = 0; i < lightFrames.size(); i++) - { - auto id = lightFrames[i].group; - auto index = lightFrames[i].index; - - imageGroups[id].pictures->mydata[index].m_bChecked = - (i <= last) ? Qt::Checked : Qt::Unchecked; - QModelIndex start { imageGroups[id].pictures->createIndex(index, 0) }; - QModelIndex end { imageGroups[id].pictures->createIndex(index, 0) }; - QVector role{ Qt::CheckStateRole }; - imageGroups[id].pictures->dataChanged(start, end, role); - } - }; + const int last = static_cast(fPercent * lightFrames.size() / 100.0); + // + // Sort in *descending* order (see operator < in class definition) + std::sort(lightFrames.begin(), lightFrames.end()); - // Change the name of the specified group - void FrameList::setGroupName(std::uint16_t id, const QString& name) + for (size_t i = 0; i < lightFrames.size(); i++) { - ZASSERTSTATE(id > -1 && id < imageGroups.size()); - if (-1 == id) id = index; // set to current group - - imageGroups[id].setName(name); + auto id = lightFrames[i].group; + auto index = lightFrames[i].index; + + imageGroups[id].pictures->mydata[index].m_bChecked = + (i <= last) ? Qt::Checked : Qt::Unchecked; + QModelIndex start { imageGroups[id].pictures->createIndex(index, 0) }; + QModelIndex end { imageGroups[id].pictures->createIndex(index, 0) }; + QVector role{ Qt::CheckStateRole }; + imageGroups[id].pictures->dataChanged(start, end, role); } +}; - /* ------------------------------------------------------------------- */ +// Change the name of the specified group +void FrameList::setGroupName(std::uint16_t id, const QString& name) +{ + ZASSERTSTATE(id > -1 && id < imageGroups.size()); + if (-1 == id) id = index; // set to current group + imageGroups[id].setName(name); } +/* ------------------------------------------------------------------- */ diff --git a/DeepSkyStacker/FrameList.h b/DeepSkyStacker/FrameList.h index 33e91813c..97c19579e 100644 --- a/DeepSkyStacker/FrameList.h +++ b/DeepSkyStacker/FrameList.h @@ -1,17 +1,9 @@ #pragma once - -#include -#include -#include "DSSProgress.h" -#include "BitmapExt.h" -#include "FrameInfo.h" -#include "DSSTools.h" -#include "MatchingStars.h" - -#include "StackingTasks.h" -#include "RegisterEngine.h" #include "group.h" +#include "MatchingStars.h" +class CAllStackingTasks; +class CBilinearParameters; namespace DSS { class FrameList @@ -58,27 +50,12 @@ namespace DSS void checkImage(const QString& image, bool check); - ListBitMap* getListBitMap(int row) - { - // - // return address of the relevant ListBitMap in the current - // group - // - return &imageGroups[index].pictures->mydata[row]; - } + ListBitMap* getListBitMap(int row); // // Remove everything from all groups, and clear the mapping from path to group number // - void clear() - { - for (auto& group : imageGroups) - { - group.pictures->clear(); - } - imageGroups.resize(1); - Group::reset(); - } + void clear(); std::uint16_t groupId() const noexcept { @@ -101,16 +78,9 @@ namespace DSS return static_cast(imageGroups.size() - 1); } - inline size_t groupSize(uint16_t id) const - { - ZASSERTSTATE(id < imageGroups.size()); - return imageGroups[id].size(); - } + size_t groupSize(uint16_t id) const; - inline size_t groupCount() const - { - return imageGroups.size(); - } + size_t groupCount() const; QString getFirstCheckedLightFrame(); @@ -124,43 +94,16 @@ namespace DSS void fillTasks(CAllStackingTasks& tasks); - inline bool isLightFrame(QString name) const - { - return imageGroups[index].pictures->isLightFrame(name); - }; - - inline bool isChecked(QString name) const - { - return imageGroups[index].pictures->isChecked(name); - } - - inline bool getTransformation(QString name, CBilinearParameters& transformation, VOTINGPAIRVECTOR& vVotedPairs) const - { - return imageGroups[index].pictures->getTransformation(name, transformation, vVotedPairs); - } + bool isLightFrame(QString name) const; + bool isChecked(QString name) const; + bool getTransformation(QString name, CBilinearParameters& transformation, VOTINGPAIRVECTOR& vVotedPairs) const; FrameList& saveListToFile(fs::path file); FrameList& loadFilesFromList(fs::path fileList); - inline FrameList& beginInsertRows(int count) - { - auto first{ imageGroups[index].pictures->rowCount() }; // Insert after end - auto last{ first + count - 1 }; - imageGroups[index].pictures->beginInsertRows(QModelIndex(), first, last); - return (*this); - } - - inline FrameList& endInsertRows() - { - imageGroups[index].pictures->endInsertRows(); - return *this; - } - - virtual bool addFile(fs::path file, PICTURETYPE PictureType = PICTURETYPE_LIGHTFRAME, bool bCheck = false, int nItem = -1) - { - imageGroups[index].addFile(file, PictureType, bCheck); - return true; - } + inline FrameList& beginInsertRows(int count); + inline FrameList& endInsertRows(); + virtual bool addFile(fs::path file, PICTURETYPE PictureType = PICTURETYPE_LIGHTFRAME, bool bCheck = false, int nItem = -1); void blankCheckedItemScores(); diff --git a/DeepSkyStacker/GrayBitmap.cpp b/DeepSkyStacker/GrayBitmap.cpp new file mode 100644 index 000000000..0503a7247 --- /dev/null +++ b/DeepSkyStacker/GrayBitmap.cpp @@ -0,0 +1,573 @@ +#include +#include "GrayBitmap.h" +#include "DSSProgress.h" +#include "ColorHelpers.h" +#include "BitmapCharacteristics.h" +#include "Multitask.h" +#include "GreyMultiBitmap.h" +#include "MedianFilterEngine.h" +#include "ZExcept.h" + +using namespace DSS; + +template +CGrayBitmapT::CGrayBitmapT() : + m_lWidth{ 0 }, + m_lHeight{ 0 }, + m_bWord{ std::is_same_v }, + m_bDouble{ std::is_same_v }, + m_bDWord{ std::is_same_v }, + m_bFloat{ std::is_same_v }, + m_fMultiplier{ 1.0 } +{ + if (m_bWord || m_bDouble || m_bFloat) + m_fMultiplier = 256.0; + else if (m_bDWord) + m_fMultiplier = 256.0 * 65536.0; +} + +template +std::unique_ptr CGrayBitmapT::Clone(bool bEmpty/*=false*/) const +{ + auto pResult = std::make_unique>(); + if (!bEmpty) + { + pResult->m_vPixels = m_vPixels; + pResult->m_lWidth = m_lWidth; + pResult->m_lHeight = m_lHeight; + } + pResult->m_bWord = m_bWord; + pResult->m_bDouble = m_bDouble; + pResult->m_bDWord = m_bDWord; + pResult->m_bFloat = m_bFloat; + pResult->m_CFATransform = m_CFATransform; + pResult->m_CFAType = m_CFAType; + pResult->m_bCYMG = m_bCYMG; + pResult->CopyFrom(*this); + + return pResult; +} + +template +BAYERCOLOR CGrayBitmapT::GetBayerColor(int x, int y) +{ + return ::GetBayerColor(x, y, m_CFAType, m_xBayerOffset, m_yBayerOffset); +} + +template +bool CGrayBitmapT::InitInternals() +{ + const size_t nrPixels = static_cast(m_lWidth) * static_cast(m_lHeight); + m_vPixels.clear(); + m_vPixels.resize(nrPixels); + + return true; // Otherwise m_vPixels.resize() would have thrown bad_alloc. +} + +template +inline void CGrayBitmapT::CheckXY(size_t x, size_t y) const +{ + ZASSERTSTATE(IsXYOk(x, y)); +} + +template +T CGrayBitmapT::GetPrimary(int x, int y, const COLORREF16& crColor) +{ + switch (::GetBayerColor(x, y, m_CFAType, m_xBayerOffset, m_yBayerOffset)) + { + case BAYER_RED: + return crColor.red; + break; + case BAYER_GREEN: + return crColor.green; + break; + case BAYER_BLUE: + return crColor.blue; + break; + } + + return 0; +} + +template +double CGrayBitmapT::GetPrimary(size_t x, size_t y, double fRed, double fGreen, double fBlue) +{ + switch (::GetBayerColor(x, y, m_CFAType, m_xBayerOffset, m_yBayerOffset)) + { + case BAYER_RED: + return fRed; + break; + case BAYER_GREEN: + return fGreen; + break; + case BAYER_BLUE: + return fBlue; + break; + } + + return 0; +} + +template +double CGrayBitmapT::InterpolateGreen(size_t x, size_t y, T* pValue/*=nullptr*/) +{ + double fResult = 0.0; + int lNrValues = 0; + + if (!pValue) + pValue = &m_vPixels[GetOffset(x, y)]; + + if (x > 0) + { + fResult += *(pValue - 1); + lNrValues++; + } + if (x < m_lWidth - 1) + { + fResult += *(pValue + 1); + lNrValues++; + } + if (y > 0) + { + fResult += *(pValue - m_lWidth); + lNrValues++; + } + if (y < m_lHeight - 1) + { + fResult += *(pValue + m_lWidth); + lNrValues++; + } + + return fResult / lNrValues; +} + +template +double CGrayBitmapT::InterpolateBlue(size_t x, size_t y, T* pValue/*=nullptr*/) +{ + double fResult = 0.0; + int lNrValues = 0; + + if (!pValue) + pValue = &m_vPixels[GetOffset(x, y)]; + + if (IsBayerBlueLine(y, m_CFAType, m_yBayerOffset)) + { + // Pixel between 2 blue pixel (horizontaly) + if (x > 0) + { + fResult += *(pValue - 1); + lNrValues++; + } + if (x < m_lWidth - 1) + { + fResult += *(pValue + 1); + lNrValues++; + } + } + else if (IsBayerBlueColumn(x, m_CFAType, m_xBayerOffset)) + { + // Pixel between 2 blue pixels (verticaly) + if (y > 0) + { + fResult += *(pValue - m_lWidth); + lNrValues++; + } + if (y < m_lHeight - 1) + { + fResult += *(pValue + m_lWidth); + lNrValues++; + } + } + else + { + // Use 4 pixels to interpolate + if (x > 0 && y > 0) + { + fResult += *(pValue - 1 - m_lWidth); + lNrValues++; + } + if ((x > 0) && (y < m_lHeight - 1)) + { + fResult += *(pValue - 1 + m_lWidth); + lNrValues++; + } + if ((x < m_lWidth - 1) && (y < m_lHeight - 1)) + { + fResult += *(pValue + 1 + m_lWidth); + lNrValues++; + } + if ((x < m_lWidth - 1) && (y > 0)) + { + fResult += *(pValue + 1 - m_lWidth); + lNrValues++; + } + } + + return fResult / lNrValues; +} + +template +double CGrayBitmapT::InterpolateRed(size_t x, size_t y, T* pValue/*=nullptr*/) +{ + double fResult = 0.0; + int lNrValues = 0; + + if (!pValue) + pValue = &m_vPixels[GetOffset(x, y)]; + + if (IsBayerRedLine(y, m_CFAType, m_yBayerOffset)) + { + // Pixel between 2 blue pixel (horizontaly) + if (x > 0) + { + fResult += *(pValue - 1); + lNrValues++; + } + if (x < m_lWidth - 1) + { + fResult += *(pValue + 1); + lNrValues++; + } + } + else if (IsBayerRedColumn(x, m_CFAType, m_xBayerOffset)) + { + // Pixel between 2 blue pixels (verticaly) + if (y > 0) + { + fResult += *(pValue - m_lWidth); + lNrValues++; + } + if (y < m_lHeight - 1) + { + fResult += *(pValue + m_lWidth); + lNrValues++; + } + } + else + { + // Use 4 pixels to interpolate + if (x > 0 && y > 0) + { + fResult += *(pValue - 1 - m_lWidth); + lNrValues++; + } + if ((x > 0) && (y < m_lHeight - 1)) + { + fResult += *(pValue - 1 + m_lWidth); + lNrValues++; + } + if ((x < m_lWidth - 1) && (y < m_lHeight - 1)) + { + fResult += *(pValue + 1 + m_lWidth); + lNrValues++; + } + if ((x < m_lWidth - 1) && (y > 0)) + { + fResult += *(pValue + 1 - m_lWidth); + lNrValues++; + } + } + + return fResult / lNrValues; +} + +template +void CGrayBitmapT::InterpolateAll(double* pfValues, size_t x, size_t y) +{ + size_t lIndice; + size_t lNrValues[4] = { 0 }; + + pfValues[0] = pfValues[1] = pfValues[2] = pfValues[3] = 0; + + for (size_t i = std::max(static_cast(0), x - 1); i <= std::min(static_cast(m_lWidth - 1), x + 1); i++) + for (size_t j = std::max(static_cast(0), y - 1); j <= std::min(static_cast(m_lHeight - 1), y + 1); j++) + { + lIndice = CMYGZeroIndex(::GetBayerColor(i, j, m_CFAType, m_xBayerOffset, m_yBayerOffset)); + pfValues[lIndice] += m_vPixels[GetOffset(i, j)]; + lNrValues[lIndice] ++; + } + + pfValues[0] /= std::max(static_cast(1), lNrValues[0]); + pfValues[1] /= std::max(static_cast(1), lNrValues[1]); + pfValues[2] /= std::max(static_cast(1), lNrValues[2]); + pfValues[3] /= std::max(static_cast(1), lNrValues[3]); + + /* + // It's used only for CYMG - so cut it down to the basic + + if (x==m_lWidth-1) + x = m_lWidth-2; + if (y==m_lHeight-1) + y = m_lHeight-2; + + pfValues[0] = pfValues[1] = pfValues[2] = pfValues[3] = 0; + + for (int i = x;i<=x+1;i++) + for (int j = y;j<=y+1;j++) + pfValues[CMYGZeroIndex(::GetBayerColor(i, j, m_CFAType))] = m_vPixels[GetOffset(i, j)]; + */ +} + +template +void CGrayBitmapT::SetPixel(size_t i, size_t j, double fRed, double fGreen, double fBlue) +{ + if (m_CFATransform == CFAT_SUPERPIXEL) + { + SetPixel(i * 2, j * 2, fRed); + SetPixel(i * 2, j * 2 + 1, fGreen); + SetPixel(i * 2 + 1, j * 2, fGreen); + SetPixel(i * 2 + 1, j * 2 + 1, fBlue); + } + else if (m_CFATransform == CFAT_NONE) + SetPixel(i, j, fRed); + else + SetPixel(i, j, GetPrimary(i, j, fRed, fGreen, fBlue)); +} + +template +void CGrayBitmapT::SetPixel(size_t i, size_t j, double fGray) +{ + SetValue(i, j, fGray * m_fMultiplier); +} + +template +void CGrayBitmapT::GetPixel(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) +{ + CheckXY(i, j); + fRed = fGreen = fBlue = 0.0; + + if (m_CFATransform == CFAT_SUPERPIXEL) + { + assert(m_bWord); + if (IsXYOk((i - 1) * 2, (j - 1) * 2) && IsXYOk((i + 1) * 2 + 1, (j + 1) * 2 + 1)) + { + T* pValue = &(m_vPixels[GetOffset(i * 2, j * 2)]); + + switch (m_CFAType) + { + case CFATYPE_GRBG: + fRed = (*(pValue + 1)) / m_fMultiplier; + fGreen = ((*pValue) + (*(pValue + 1 + m_lWidth))) / 2.0 / m_fMultiplier; + fBlue = (*(pValue + m_lWidth)) / m_fMultiplier; + break; + case CFATYPE_GBRG: + fRed = (*(pValue + m_lWidth)) / m_fMultiplier; + fGreen = ((*pValue) + (*(pValue + 1 + m_lWidth))) / 2.0 / m_fMultiplier; + fBlue = (*(pValue + 1)) / m_fMultiplier; + break; + case CFATYPE_BGGR: + fRed = (*(pValue + 1 + m_lWidth)) / m_fMultiplier; + fGreen = ((*(pValue + m_lWidth)) + (*(pValue + 1))) / 2.0 / m_fMultiplier; + fBlue = (*pValue) / m_fMultiplier; + break; + case CFATYPE_RGGB: + fRed = (*pValue) / m_fMultiplier; + fGreen = ((*(pValue + m_lWidth)) + (*(pValue + 1))) / 2.0 / m_fMultiplier; + fBlue = (*(pValue + 1 + m_lWidth)) / m_fMultiplier; + break; + } + } + } + else if (m_CFATransform == CFAT_RAWBAYER) + { + assert(m_bWord); + T* pValue = &(m_vPixels[GetOffset(i, j)]); + + switch (::GetBayerColor(i, j, m_CFAType, m_xBayerOffset, m_yBayerOffset)) + { + case BAYER_RED: + fRed = (*pValue) / m_fMultiplier; + break; + case BAYER_GREEN: + fGreen = (*pValue) / m_fMultiplier; + break; + case BAYER_BLUE: + fBlue = (*pValue) / m_fMultiplier; + break; + } + } + else if ((m_CFATransform == CFAT_BILINEAR) || (m_CFATransform == CFAT_AHD)) + { + assert(m_bWord); + if (m_bCYMG) + { + double fValue[4]; // Myself + InterpolateAll(fValue, i, j); + + CYMGToRGB(fValue[CMYGZeroIndex(BAYER_CYAN)] / m_fMultiplier, + fValue[CMYGZeroIndex(BAYER_YELLOW)] / m_fMultiplier, + fValue[CMYGZeroIndex(BAYER_MAGENTA)] / m_fMultiplier, + fValue[CMYGZeroIndex(BAYER_GREEN2)] / m_fMultiplier, + fRed, fGreen, fBlue + ); + } + else + { + T* pValue = &(m_vPixels[GetOffset(i, j)]); + switch (::GetBayerColor(i, j, m_CFAType, m_xBayerOffset, m_yBayerOffset)) + { + case BAYER_RED: + fRed = (*pValue) / m_fMultiplier; + fGreen = InterpolateGreen(i, j, pValue) / m_fMultiplier; + fBlue = InterpolateBlue(i, j, pValue) / m_fMultiplier; + break; + case BAYER_GREEN: + fRed = InterpolateRed(i, j, pValue) / m_fMultiplier; + fGreen = (*pValue) / m_fMultiplier; + fBlue = InterpolateBlue(i, j, pValue) / m_fMultiplier; + break; + case BAYER_BLUE: + fRed = InterpolateRed(i, j, pValue) / m_fMultiplier; + fGreen = InterpolateGreen(i, j, pValue) / m_fMultiplier; + fBlue = (*pValue) / m_fMultiplier; + break; + } + } + + } + else if (m_CFATransform == CFAT_GRADIENT) + { + } + else + { + fRed = fBlue = fGreen = m_vPixels[GetOffset(i, j)] / m_fMultiplier; + } +} + +template +void CGrayBitmapT::GetPixel(size_t i, size_t j, double& fGray) +{ + GetValue(i, j, fGray); + fGray /= m_fMultiplier; +} + +template +bool CGrayBitmapT::GetScanLine(size_t j, void* pScanLine) +{ + bool bResult = false; + + if (j < m_lHeight) + { + memcpy(pScanLine, &(m_vPixels[j * m_lWidth]), sizeof(T) * m_lWidth); + bResult = true; + } + + return bResult; +} + +template +bool CGrayBitmapT::SetScanLine(size_t j, void* pScanLine) +{ + bool bResult = false; + + if (j < m_lHeight) + { + memcpy(&(m_vPixels[j * m_lWidth]), pScanLine, sizeof(T) * m_lWidth); + bResult = true; + } + + return bResult; +} + +template +std::shared_ptr CGrayBitmapT::CreateEmptyMultiBitmap() const +{ + std::shared_ptr> pResult = std::make_shared>(); + pResult->SetBitmapModel(this); + return pResult; +} + +template +std::shared_ptr CGrayBitmapT::GetMedianFilterEngine() const +{ + std::shared_ptr> pFilter = std::make_shared>(); + pFilter->SetInputBitmap(this); + return pFilter; +} + +template +void CGrayBitmapT::InitIterator(void*& pRed, void*& pGreen, void*& pBlue, size_t& elementSize, const size_t x, const size_t y) +{ + pRed = static_cast(this->m_vPixels.data() + GetOffset(x, y)); + pGreen = pRed; + pBlue = pRed; + elementSize = sizeof(T); +} + +template +void CGrayBitmapT::InitIterator(const void*& pRed, const void*& pGreen, const void*& pBlue, size_t& elementSize, const size_t x, const size_t y) const +{ + pRed = static_cast(this->m_vPixels.data() + GetOffset(x, y)); + pGreen = pRed; + pBlue = pRed; + elementSize = sizeof(T); +} + +template +void CGrayBitmapT::GetCharacteristics(CBitmapCharacteristics& bc) +{ + bc.m_bFloat = m_bFloat; + bc.m_dwHeight = m_lHeight; + bc.m_dwWidth = m_lWidth; + bc.m_lNrChannels = 1; + bc.m_lBitsPerPixel = BitPerSample(); +} + +template +void CGrayBitmapT::RemoveHotPixels(ProgressBase* pProgress) +{ + const int nrProcessors = CMultitask::GetNrProcessors(); + + if (pProgress != nullptr) + { + const QString strText(QCoreApplication::translate("BitmapBase", "Detecting hot pixels", "IDS_REMOVINGHOTPIXELS")); + pProgress->Start2(strText, m_lHeight); + } + + const int height = this->Height(); + const int width = this->Width(); + std::vector hotOffsets; + std::vector localHotOffsets; + +#pragma omp parallel default(none) shared(hotOffsets) firstprivate(localHotOffsets) if(nrProcessors > 1) + { +#pragma omp for schedule(dynamic, 50) nowait + for (int row = 2; row < height - 2; ++row) + { + for (int column = 2; column < width - 2; ++column) + { + const size_t testOffset = this->GetOffset(column, row); + const T testValue = this->m_vPixels[testOffset]; + constexpr double hotFactor = 4; + + if (testValue > hotFactor * m_vPixels[GetOffset(column - 1, row)] + && testValue > hotFactor * m_vPixels[GetOffset(column + 1, row)] + && testValue > hotFactor * m_vPixels[GetOffset(column, row + 1)] + && testValue > hotFactor * m_vPixels[GetOffset(column, row - 1)]) + { + localHotOffsets.push_back(testOffset); + ++column; + } + } + } +#pragma omp critical(OmpLockHotpixelRemove) + { + hotOffsets.insert(hotOffsets.end(), localHotOffsets.cbegin(), localHotOffsets.cend()); + } + } + + for (const auto hotOffset : hotOffsets) + this->m_vPixels[hotOffset] = 0; + + if (pProgress != nullptr) + pProgress->End2(); +} + +// Define these here so that we can simple headers. We only run with these types so this isn't too bad. +template class CGrayBitmapT; +template class CGrayBitmapT; +template class CGrayBitmapT; +template class CGrayBitmapT; +template class CGrayBitmapT; +template class CGrayBitmapT; + diff --git a/DeepSkyStacker/GrayBitmap.h b/DeepSkyStacker/GrayBitmap.h new file mode 100644 index 000000000..3896c56ff --- /dev/null +++ b/DeepSkyStacker/GrayBitmap.h @@ -0,0 +1,199 @@ +#pragma once +#include "MemoryBitmap.h" +#include "CFABitmapInfo.h" + +namespace DSS { class ProgressDlg; } +using namespace DSS; + +template +class CGrayBitmapT : public CMemoryBitmap, public CCFABitmapInfo +{ +public: + //friend CColorBitmapT; + //friend CGrayMedianFilterEngineT; + + std::vector m_vPixels; + +private: + int m_lWidth; + int m_lHeight; + bool m_bWord; + bool m_bDouble; + bool m_bDWord; + bool m_bFloat; + double m_fMultiplier; + +private: + bool InitInternals(); + + void CheckXY(size_t x, size_t y) const; + + inline bool IsXYOk(size_t x, size_t y) const + { + return (x >= 0 && x < m_lWidth&& y >= 0 && y < m_lHeight); + } + + size_t GetOffset(const size_t x, const size_t y) const + { + return static_cast(m_lWidth) * y + x; + } + size_t GetOffset(int x, int y) const + { + CheckXY(x, y); + return GetOffset(static_cast(x), static_cast(y)); + } + + virtual bool IsMonochrome() const override + { + return true; + } + + TType GetPrimary(int x, int y, const COLORREF16& crColor); + double GetPrimary(size_t x, size_t y, double fRed, double fGreen, double fBlue); + double InterpolateGreen(size_t x, size_t y, TType* pValue = nullptr); + double InterpolateBlue(size_t x, size_t y, TType* pValue = nullptr); + double InterpolateRed(size_t x, size_t y, TType* pValue = nullptr); + void InterpolateAll(double* pfValues, size_t x, size_t y); + +protected: + virtual void SetCFA(bool bCFA) override + { + m_bCFA = bCFA; + }; + +public: + CGrayBitmapT(); + virtual ~CGrayBitmapT() = default; + + void SetMultiplier(double fMultiplier) + { + m_fMultiplier = fMultiplier; + }; + + virtual bool Init(int lWidth, int lHeight) override + { + m_lWidth = lWidth; + m_lHeight = lHeight; + return InitInternals(); + }; + + virtual std::unique_ptr Clone(bool bEmpty = false) const override; + virtual BAYERCOLOR GetBayerColor(int x, int y) override; + + virtual CFATYPE GetCFAType() const override + { + return CCFABitmapInfo::GetCFAType(); + } + + virtual int BitPerSample() override + { + return sizeof(TType) * 8; + } + + virtual int IsFloat() override + { + return m_bFloat; + } + + virtual int Width() const override + { + if (m_CFATransform == CFAT_SUPERPIXEL) + return m_lWidth / 2; + else + return m_lWidth; + } + + virtual int Height() const override + { + if (m_CFATransform == CFAT_SUPERPIXEL) + return m_lHeight / 2; + else + return m_lHeight; + } + + virtual int RealHeight() const override + { + return m_lHeight; + } + + virtual int RealWidth() const override + { + return m_lWidth; + } + + virtual void SetValue(size_t i, size_t j, double fGray) override + { + CheckXY(i, j); + m_vPixels[GetOffset(i, j)] = fGray; + } + + virtual void GetValue(size_t i, size_t j, double& fGray) const override + { + //if (CFAT_SUPERPIXEL == m_CFATransform) Bug fix 15th August 2020 + //{ + // i *= 2; j *= 2; + //} + CheckXY(i, j); + fGray = m_vPixels[GetOffset(i, j)]; + } + + virtual void SetPixel(size_t i, size_t j, double fRed, double fGreen, double fBlue) override; + inline virtual void SetPixel(size_t i, size_t j, double fGray) override; + virtual void GetPixel(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) override; + virtual void inline GetPixel(size_t i, size_t j, double& fGray) override; + virtual bool GetScanLine(size_t j, void* pScanLine) override; + virtual bool SetScanLine(size_t j, void* pScanLine) override; + virtual std::shared_ptr CreateEmptyMultiBitmap() const override; + + virtual void RemoveHotPixels(ProgressBase* pProgress = nullptr) override; + + TType* GetGrayPixel(int i, int j) + { + return m_vPixels.data() + GetOffset(i, j); + } + const TType* GetGrayPixel(const int i, const int j) const + { + return m_vPixels.data() + GetOffset(i, j); + } + + double GetMultiplier() const + { + return m_fMultiplier; + } + + virtual std::shared_ptr GetMedianFilterEngine() const override; + + virtual double GetMaximumValue() const override + { + return m_fMultiplier * 256.0; + } + + virtual void GetCharacteristics(CBitmapCharacteristics& bc) override; + + virtual void InitIterator(void*& pRed, void*& pGreen, void*& pBlue, size_t& elementSize, const size_t x, const size_t y) override; + virtual void InitIterator(const void*& pRed, const void*& pGreen, const void*& pBlue, size_t& elementSize, const size_t x, const size_t y) const override; + + virtual std::tuple ConvertValue3(const void* pRed, const void*, const void*) const override + { + const double value = static_cast(*static_cast(pRed)) / this->m_fMultiplier; + return { value, value, value }; + } + virtual double ConvertValue1(const void* pRed, const void*, const void*) const override + { + return static_cast(*static_cast(pRed)) / this->m_fMultiplier; + } + + virtual void ReceiveValue(void*, void*, void*, const double, const double, const double) const override + {} + virtual void ReceiveValue(void* pRed, void*, void*, const double gray) const override + { + *static_cast(pRed) = static_cast(gray * this->m_fMultiplier); + } +}; + + +typedef CGrayBitmapT CGrayBitmap; +typedef CGrayBitmapT C8BitGrayBitmap; +typedef CGrayBitmapT C16BitGrayBitmap; +typedef CGrayBitmapT C32BitGrayBitmap; +typedef CGrayBitmapT C32BitFloatGrayBitmap; diff --git a/DeepSkyStacker/GreyMultiBitmap.cpp b/DeepSkyStacker/GreyMultiBitmap.cpp new file mode 100644 index 000000000..44e55d4c9 --- /dev/null +++ b/DeepSkyStacker/GreyMultiBitmap.cpp @@ -0,0 +1,158 @@ +#include "stdafx.h" +#include "GreyMultiBitmap.h" +#include "GrayBitmap.h" +#include "BitmapCharacteristics.h" +#include "BitmapBase.h" +#include "ZExcBase.h" +#include "DSSTools.h" + +template +std::shared_ptr CGrayMultiBitmapT::CreateNewMemoryBitmap() const +{ + std::shared_ptr pBitmap; + if (static_cast(m_pBitmapModel)) + { + CBitmapCharacteristics bc; + m_pBitmapModel->GetCharacteristics(bc); + if (bc.m_lNrChannels == 1) + return m_pBitmapModel->Clone(true); + else + { + bc.m_lNrChannels = 1; + return CreateBitmap(bc); + } + } + auto pNewBitmap = std::make_shared>(); + return pNewBitmap; + return std::make_shared>(); +} + +template +std::shared_ptr CGrayMultiBitmapT::CreateOutputMemoryBitmap() const +{ + std::shared_ptr pBitmap = std::make_shared>(); + + if (static_cast(pBitmap) && static_cast(m_pBitmapModel)) + { + CCFABitmapInfo* pSrc; + CCFABitmapInfo* pDst; + + pBitmap->SetCFA(m_pBitmapModel->IsCFA()); + pSrc = dynamic_cast(m_pBitmapModel.get()); + pDst = dynamic_cast(pBitmap.get()); + + if (pSrc != nullptr && pDst != nullptr) + pDst->InitFrom(pSrc); + } + + return pBitmap; +} + +template +bool CGrayMultiBitmapT::SetScanLines(CMemoryBitmap* pBitmap, int lLine, const std::vector& vScanLines) +{ + bool bResult = false; + // Each scan line consist of lWidth TType values + std::vector vValues; + std::vector vAuxValues; + std::vector vWorkingBuffer1; + std::vector vWorkingBuffer2; + std::vector vdWork1; // Used for AutoAdaptiveWeightedAverage + std::vector vdWork2; // Used for AutoAdaptiveWeightedAverage + + const double fMaximum = pBitmap->GetMaximumValue(); + const int lWidth = pBitmap->RealWidth(); + + std::vector outputScanBuffer; + try { + outputScanBuffer.resize(lWidth); + } + catch (...) { + ZOutOfMemory e("Could not allocate storage for output scanline"); + ZTHROW(e); + } + TTypeOutput* pCurrentValue = outputScanBuffer.data(); + + vValues.reserve(vScanLines.size()); + vWorkingBuffer1.reserve(vScanLines.size()); + vWorkingBuffer2.reserve(vScanLines.size()); + vdWork1.reserve(vScanLines.size()); + vdWork2.reserve(vScanLines.size()); + + for (int i = 0; i < lWidth; i++) + { + TType* pValue; + double fWeight = 1.0; + + vValues.resize(0); + for (size_t j = 0; j < vScanLines.size(); j++) + { + pValue = (TType*)vScanLines[j]; + pValue += i; + + if (*pValue || m_vImageOrder.size()) // Remove 0 + vValues.push_back(*pValue); + }; + + // Process the value + if (m_bHomogenization) + { + if (static_cast(m_pHomBitmap)) + { + double fAverage; + const double fSigma = Sigma2(vValues, fAverage); + m_pHomBitmap->SetPixel(i, lLine, fSigma / std::max(1.0, fAverage) * 256.0); + } + + if (!m_vImageOrder.empty()) + { + // Change the order to respect the order of the images + vAuxValues = vValues; + vValues.resize(0); + for (size_t k = 0; k < m_vImageOrder.size(); k++) + if (const auto auxVal = vAuxValues[m_vImageOrder[k]]) + vValues.push_back(auxVal); + + Homogenize(vValues, fMaximum); + } + else + { + Homogenize(vValues, fMaximum); + }; + }; + + if (m_Method == MBP_MEDIAN) + *pCurrentValue = Median(vValues); + else if (m_Method == MBP_AVERAGE) + *pCurrentValue = Average(vValues); + else if (m_Method == MBP_MAXIMUM) + *pCurrentValue = Maximum(vValues); + else if (m_Method == MBP_SIGMACLIP) + { + *pCurrentValue = KappaSigmaClip(vValues, m_fKappa, m_lNrIterations, vWorkingBuffer1); + } + else if (m_Method == MBP_MEDIANSIGMACLIP) + *pCurrentValue = MedianKappaSigmaClip(vValues, m_fKappa, m_lNrIterations, vWorkingBuffer1, vWorkingBuffer2); + else if (m_Method == MBP_AUTOADAPTIVE) + *pCurrentValue = AutoAdaptiveWeightedAverage(vValues, m_lNrIterations, vdWork1); + + //if (m_bHomogenization) + // *pCurrentValue = fHomogenization*(double)(*pCurrentValue); + pCurrentValue++; + }; + + pBitmap->SetScanLine(lLine, outputScanBuffer.data()); + bResult = true; + + return bResult; +} + +// Define these here so that we can simple headers. We only run with these types so this isn't too bad. +template class CGrayMultiBitmapT; +template class CGrayMultiBitmapT; +template class CGrayMultiBitmapT; +template class CGrayMultiBitmapT; +template class CGrayMultiBitmapT; + +template class CGrayMultiBitmapT; +template class CGrayMultiBitmapT; \ No newline at end of file diff --git a/DeepSkyStacker/GreyMultiBitmap.h b/DeepSkyStacker/GreyMultiBitmap.h new file mode 100644 index 000000000..82b732f66 --- /dev/null +++ b/DeepSkyStacker/GreyMultiBitmap.h @@ -0,0 +1,30 @@ +#pragma once +#include "MultiBitmap.h" +#include "BitmapCharacteristics.h" + +template +class CGrayMultiBitmapT : public CMultiBitmap +{ +protected: + virtual std::shared_ptr CreateNewMemoryBitmap() const override; + virtual std::shared_ptr CreateOutputMemoryBitmap() const override; + virtual bool SetScanLines(CMemoryBitmap* pBitmap, int lLine, const std::vector& vScanLines) override; + +public: + CGrayMultiBitmapT() + {} + + virtual ~CGrayMultiBitmapT() + {} + + virtual int GetNrChannels() const override + { + return 1; + }; + + virtual int GetNrBytesPerChannel() const override + { + return sizeof(TType); + }; +}; + diff --git a/DeepSkyStacker/Histogram.h b/DeepSkyStacker/Histogram.h index 6901b5187..3455b6095 100644 --- a/DeepSkyStacker/Histogram.h +++ b/DeepSkyStacker/Histogram.h @@ -1,7 +1,8 @@ #ifndef _HISTOGRAM_H__ #define _HISTOGRAM_H__ -#include +#include "ZExcBase.h" +#include "resource.h" /* ------------------------------------------------------------------- */ @@ -628,10 +629,10 @@ public : if (m_lNrValues) { - int lCount = 0; + unsigned int lCount = 0; int i = 0; - while ((lCount + m_vValues[i]) <= m_lNrValues/2) + while ((lCount + m_vValues[i]) <= (unsigned int)(m_lNrValues/2)) { lCount += m_vValues[i]; i++; diff --git a/DeepSkyStacker/ImageListModel.cpp b/DeepSkyStacker/ImageListModel.cpp index 1d2083086..a99b7f154 100644 --- a/DeepSkyStacker/ImageListModel.cpp +++ b/DeepSkyStacker/ImageListModel.cpp @@ -34,23 +34,6 @@ ** ****************************************************************************/ #include "stdafx.h" -#include - -#include -using std::min; -using std::max; -#include - -#include -#include - -#include - -#include "DSSCommon.h" -#include "DSSMemory.h" - -#include "resource.h" -#include "FrameList.h" #include "ImageListModel.h" namespace DSS diff --git a/DeepSkyStacker/ImageListModel.h b/DeepSkyStacker/ImageListModel.h index 35018bdc8..b3f5b0d3e 100644 --- a/DeepSkyStacker/ImageListModel.h +++ b/DeepSkyStacker/ImageListModel.h @@ -34,18 +34,7 @@ ** ** ****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include "BitmapBase.h" #include "FrameInfo.h" - - namespace DSS { class ImageListModel : diff --git a/DeepSkyStacker/ImageSinks.cpp b/DeepSkyStacker/ImageSinks.cpp index 420417dc9..d5d881d37 100644 --- a/DeepSkyStacker/ImageSinks.cpp +++ b/DeepSkyStacker/ImageSinks.cpp @@ -1,16 +1,8 @@ #include -#include -#include "dssrect.h" -#include "BitmapExt.h" #include "ImageSinks.h" #include "RegisterEngine.h" #include "BackgroundCalibration.h" - - -#if QT_VERSION < 0x060000 -#define _USE_MATH_DEFINES -#endif -#include +#include "commonresource.h" /* ------------------------------------------------------------------- */ diff --git a/DeepSkyStacker/ImageSinks.h b/DeepSkyStacker/ImageSinks.h index 89c290cbd..50121e6bf 100644 --- a/DeepSkyStacker/ImageSinks.h +++ b/DeepSkyStacker/ImageSinks.h @@ -1,5 +1,11 @@ -#ifndef __IMAGESINKS_H__ -#define __IMAGESINKS_H__ +#pragma once + +#include "WndImage.h" +#include "Stars.h" +#include "BilinearParameters.h" +#include "MatchingStars.h" +#include "GrayBitmap.h" +#include "DSSCommon.h" /* ------------------------------------------------------------------- */ extern bool g_bShowRefStars; @@ -72,11 +78,6 @@ public : /* ------------------------------------------------------------------- */ -#include "Stars.h" -#include "MatchingStars.h" - -/* ------------------------------------------------------------------- */ - class CDelaunayTriangle { public : @@ -364,7 +365,3 @@ public : virtual Image * GetOverlayImage(CRect & rcClient); }; - -/* ------------------------------------------------------------------- */ - -#endif // __IMAGESINKS_H__ \ No newline at end of file diff --git a/DeepSkyStacker/IntermediateFiles.cpp b/DeepSkyStacker/IntermediateFiles.cpp index 7e4c1ad3c..752180369 100644 --- a/DeepSkyStacker/IntermediateFiles.cpp +++ b/DeepSkyStacker/IntermediateFiles.cpp @@ -1,19 +1,8 @@ -#include -using std::min; -using std::max; - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include - +#include "stdafx.h" #include "IntermediateFiles.h" #include "ui/ui_IntermediateFiles.h" - -#include -#include - -#include "DSSCommon.h" #include "Workspace.h" - +#include "DSSCommon.h" IntermediateFiles::IntermediateFiles(QWidget *parent, bool regOnly) : QWidget(parent), diff --git a/DeepSkyStacker/IntermediateFiles.h b/DeepSkyStacker/IntermediateFiles.h index 2c7ebf847..2284ca6eb 100644 --- a/DeepSkyStacker/IntermediateFiles.h +++ b/DeepSkyStacker/IntermediateFiles.h @@ -1,7 +1,4 @@ -#ifndef INTERMEDIATEFILES_H -#define INTERMEDIATEFILES_H - -#include +#pragma once class Workspace; @@ -37,5 +34,3 @@ private slots: void on_saveDebayered_stateChanged(int state); void on_saveIntermediate_stateChanged(int state); }; - -#endif // INTERMEDIATEFILES_H diff --git a/DeepSkyStacker/LinearInterpolationh.h b/DeepSkyStacker/LinearInterpolationh.h new file mode 100644 index 000000000..935f97b87 --- /dev/null +++ b/DeepSkyStacker/LinearInterpolationh.h @@ -0,0 +1,53 @@ +#pragma once + +class CLinearInterpolation +{ +private: + double xm, + a0, b0, + a1, b1; + +public: + CLinearInterpolation() noexcept + { + xm = 0; + a0 = b0 = a1 = b1 = 0; + }; + + CLinearInterpolation(const CLinearInterpolation&) = default; + + CLinearInterpolation(CLinearInterpolation&&) = default; + + CLinearInterpolation& operator = (const CLinearInterpolation&) = default; + + double Interpolate(double x) const noexcept + { + if (x < xm) + return a0 * x + b0; + else + return a1 * x + b1; + }; + + void Initialize(double x0, double x1, double x2, double y0, double y1, double y2) noexcept + { + xm = x1; + if (x0 < x1) + a0 = (y0 - y1) / (x0 - x1); + else + a0 = 0; + + b0 = y0 - a0 * x0; + + if (x1 < x2) + a1 = (y1 - y2) / (x1 - x2); + else + a1 = 0; + b1 = y1 - a1 * x1; + }; + + float getParameterXm() const noexcept { return static_cast(this->xm); } + float getParameterA0() const noexcept { return static_cast(this->a0); } + float getParameterA1() const noexcept { return static_cast(this->a1); } + float getParameterB0() const noexcept { return static_cast(this->b0); } + float getParameterB1() const noexcept { return static_cast(this->b1); } +}; \ No newline at end of file diff --git a/DeepSkyStacker/LuminanceTab.cpp b/DeepSkyStacker/LuminanceTab.cpp index 477f88788..d96eea7f9 100644 --- a/DeepSkyStacker/LuminanceTab.cpp +++ b/DeepSkyStacker/LuminanceTab.cpp @@ -1,8 +1,6 @@ // LuminanceTab.cpp : implementation file // - #include "stdafx.h" -#include "DeepSkyStacker.h" #include "LuminanceTab.h" #include "ProcessingDlg.h" diff --git a/DeepSkyStacker/LuminanceTab.h b/DeepSkyStacker/LuminanceTab.h index 39171e958..f14afddff 100644 --- a/DeepSkyStacker/LuminanceTab.h +++ b/DeepSkyStacker/LuminanceTab.h @@ -1,16 +1,8 @@ -#if !defined(AFX_LUMINANCETAB_H__C143C1EE_81D8_44F1_B5FD_B66EA4028433__INCLUDED_) -#define AFX_LUMINANCETAB_H__C143C1EE_81D8_44F1_B5FD_B66EA4028433__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 -// LuminanceTab.h : header file -// - -#include -#include -#include -#include "afxwin.h" +#include "childprop.h" +#include "BtnST.h" +#include "Label.h" +#include "resourceCZ.h" ///////////////////////////////////////////////////////////////////////////// // CLuminanceTab dialog @@ -72,8 +64,3 @@ private : //}}AFX_MSG DECLARE_MESSAGE_MAP() }; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_LUMINANCETAB_H__C143C1EE_81D8_44F1_B5FD_B66EA4028433__INCLUDED_) diff --git a/DeepSkyStacker/MasterFrames.cpp b/DeepSkyStacker/MasterFrames.cpp index 8cfee7d84..36b8bd0d7 100644 --- a/DeepSkyStacker/MasterFrames.cpp +++ b/DeepSkyStacker/MasterFrames.cpp @@ -3,8 +3,19 @@ #include "MasterFrames.h" #include "DSSProgress.h" #include "DeBloom.h" +#include "Workspace.h" +#include "Ztrace.h" +#include "StackingTasks.h" +#include "BitmapExt.h" + +using namespace DSS; /* ------------------------------------------------------------------- */ +CMasterFrames::CMasterFrames() +{ + Workspace workspace; + m_fDebloom = workspace.value("Stacking/Debloom", false).toBool(); +} bool CMasterFrames::LoadMasters(const CStackingInfo* pStackingInfo, ProgressBase * pProgress) { diff --git a/DeepSkyStacker/MasterFrames.h b/DeepSkyStacker/MasterFrames.h index 8fd8775e0..3982caf7e 100644 --- a/DeepSkyStacker/MasterFrames.h +++ b/DeepSkyStacker/MasterFrames.h @@ -1,41 +1,30 @@ #ifndef __MASTERFRAMES_H__ #define __MASTERFRAMES_H__ - -#include "BitmapExt.h" -#include "FlatFrame.h" #include "DarkFrame.h" -#include "StackingTasks.h" -#include "Stars.h" - -#include "Workspace.h" +#include "FlatFrame.h" +class CMemoryBitmap; +class CStackingInfo; +namespace DSS { class ProgressBase; } class CMasterFrames { private : std::shared_ptr m_pMasterOffset; - CDarkFrame m_MasterDark; - CFlatFrame m_MasterFlat; - bool m_fDebloom; + CDarkFrame m_MasterDark; + CFlatFrame m_MasterFlat; + bool m_fDebloom; public : - CMasterFrames() - { - Workspace workspace; - - m_fDebloom = workspace.value("Stacking/Debloom", false).toBool(); - }; - - virtual ~CMasterFrames() - { - }; + CMasterFrames(); + virtual ~CMasterFrames() = default; - void ApplyMasterOffset(std::shared_ptr pBitmap, ProgressBase * pProgress); - void ApplyMasterDark(std::shared_ptr pBitmap, const STARVECTOR*, ProgressBase * pProgress); - void ApplyMasterFlat(std::shared_ptr pBitmap, ProgressBase * pProgress); - void ApplyHotPixelInterpolation(std::shared_ptr pBitmap, ProgressBase * pProgress); - void ApplyAllMasters(std::shared_ptr pBitmap, const STARVECTOR* pStars, ProgressBase * pProgress); + void ApplyMasterOffset(std::shared_ptr pBitmap, DSS::ProgressBase * pProgress); + void ApplyMasterDark(std::shared_ptr pBitmap, const STARVECTOR*, DSS::ProgressBase* pProgress); + void ApplyMasterFlat(std::shared_ptr pBitmap, DSS::ProgressBase* pProgress); + void ApplyHotPixelInterpolation(std::shared_ptr pBitmap, DSS::ProgressBase* pProgress); + void ApplyAllMasters(std::shared_ptr pBitmap, const STARVECTOR* pStars, DSS::ProgressBase* pProgress); - bool LoadMasters(const CStackingInfo* pStackingInfo, ProgressBase* pProgress); + bool LoadMasters(const CStackingInfo* pStackingInfo, DSS::ProgressBase* pProgress); }; #endif // __MASTERFRAMES_H__ \ No newline at end of file diff --git a/DeepSkyStacker/MatchingStars.cpp b/DeepSkyStacker/MatchingStars.cpp index 4f45b829a..41a62dbf8 100644 --- a/DeepSkyStacker/MatchingStars.cpp +++ b/DeepSkyStacker/MatchingStars.cpp @@ -1,13 +1,10 @@ #include -#include #include "MatchingStars.h" -#include -#include "Workspace.h" +#include "ZExcept.h" #define _NO_EXCEPTION -//#define _NO_TEMPLATE -//#include #include "Matrix.h" +#include "Workspace.h" constexpr int MINPAIRSTOBISQUARED = 25; constexpr int MINPAIRSTOBICUBIC = 40; diff --git a/DeepSkyStacker/MatchingStars.h b/DeepSkyStacker/MatchingStars.h index c494b32b8..504c52edc 100644 --- a/DeepSkyStacker/MatchingStars.h +++ b/DeepSkyStacker/MatchingStars.h @@ -1,11 +1,11 @@ -#ifndef __MATCHINGSTARS_H__ -#define __MATCHINGSTARS_H__ +#pragma once -#include "DSSTools.h" #if !defined(NDEBUG) #include namespace bc = boost::container; #endif +#include "DSSTools.h" +#include "BilinearParameters.h" #pragma pack(push, STARTRIANGLE, 1) @@ -316,7 +316,7 @@ typedef std::vector VOTINGPAIRVECTOR; typedef VOTINGPAIRVECTOR::iterator VOTINGPAIRITERATOR; /* ------------------------------------------------------------------- */ - +class CBilinearParameters; class CMatchingStars { private: @@ -409,6 +409,3 @@ class CMatchingStars vPairs = m_vVotedPairs; } }; - -#endif // __MATCHINGSTARS_H__ - diff --git a/DeepSkyStacker/MedianFilterEngine.cpp b/DeepSkyStacker/MedianFilterEngine.cpp index 86a328eb1..39aa9cbe5 100644 --- a/DeepSkyStacker/MedianFilterEngine.cpp +++ b/DeepSkyStacker/MedianFilterEngine.cpp @@ -1,9 +1,14 @@ #include #include + #include "BitmapBase.h" #include "MedianFilterEngine.h" #include "avx_filter.h" +#include "Multitask.h" +#include "DSSProgress.h" +#include "DSSTools.h" +using namespace DSS; template void CInternalMedianFilterEngineT::CFilterTask::process() @@ -125,3 +130,4 @@ template void CInternalMedianFilterEngineT::ApplyFilter(Progress template void CInternalMedianFilterEngineT::ApplyFilter(ProgressBase*); template void CInternalMedianFilterEngineT::ApplyFilter(ProgressBase*); template void CInternalMedianFilterEngineT::ApplyFilter(ProgressBase*); +template void CInternalMedianFilterEngineT::ApplyFilter(ProgressBase*); diff --git a/DeepSkyStacker/MedianFilterEngine.h b/DeepSkyStacker/MedianFilterEngine.h index 836ca4d1a..63e01f5e9 100644 --- a/DeepSkyStacker/MedianFilterEngine.h +++ b/DeepSkyStacker/MedianFilterEngine.h @@ -1,6 +1,87 @@ #ifndef __MEDIANFILTERENGINE_H__ #define __MEDIANFILTERENGINE_H__ +#include "GrayBitmap.h" +#include "ColorBitmap.h" +namespace DSS { class ProgressBase; } + +////////////////////////////////////////////////////////////////////////// +// Perhaps these classes here (CMedianFilterEngine based) should be in their own headers. +class CMedianFilterEngine +{ +protected: + int m_lFilterSize; + DSS::ProgressBase* m_pProgress; + +public: + CMedianFilterEngine() : + m_lFilterSize{ 1 }, + m_pProgress{ nullptr } + {} + + virtual ~CMedianFilterEngine() {}; + + virtual std::shared_ptr GetFilteredImage(int lFilterSize, DSS::ProgressBase* pProgress) const = 0; +}; + +template +class CGrayMedianFilterEngineT : public CMedianFilterEngine +{ +private: + const CGrayBitmapT* m_pInBitmap; + +public: + CGrayMedianFilterEngineT() : m_pInBitmap{ nullptr } + {}; + virtual ~CGrayMedianFilterEngineT() {}; + + void SetInputBitmap(const CGrayBitmapT* pInBitmap) + { + m_pInBitmap = pInBitmap; + } + + virtual std::shared_ptr GetFilteredImage(const int lFilterSize, DSS::ProgressBase* pProgress) const override; +}; + +template +class CColorMedianFilterEngineT : public CMedianFilterEngine +{ +private: + const CColorBitmapT* m_pInBitmap; + +public: + CColorMedianFilterEngineT() {}; + virtual ~CColorMedianFilterEngineT() {}; + + void SetInputBitmap(const CColorBitmapT* pInBitmap) + { + m_pInBitmap = pInBitmap; + } + + virtual std::shared_ptr GetFilteredImage(int lFilterSize, DSS::ProgressBase* pProgress) const override; +}; + +template +class CopyableSmartPtr final +{ +private: + std::unique_ptr p; +public: + template CopyableSmartPtr(std::unique_ptr&) = delete; + CopyableSmartPtr() = delete; + CopyableSmartPtr& operator=(const CopyableSmartPtr&) = delete; + + template + CopyableSmartPtr(std::unique_ptr&& rhs) : p{ std::move(rhs) } {} + + CopyableSmartPtr(const CopyableSmartPtr& rhs) : p{ rhs->clone() } {} + + typename std::unique_ptr::pointer get() const noexcept { return p.get(); } + typename std::unique_ptr::pointer operator->() const noexcept { return this->get(); } +}; + + +////////////////////////////////////////////////////////////////////////// template class CInternalMedianFilterEngineT @@ -18,10 +99,10 @@ public : { private : CInternalMedianFilterEngineT* m_pEngine = nullptr; - ProgressBase* m_pProgress = nullptr; + DSS::ProgressBase* m_pProgress = nullptr; public : - CFilterTask(CInternalMedianFilterEngineT* peng, ProgressBase* pprg) : + CFilterTask(CInternalMedianFilterEngineT* peng, DSS::ProgressBase* pprg) : m_pEngine{ peng }, m_pProgress{ pprg } {} @@ -45,12 +126,12 @@ public : virtual ~CInternalMedianFilterEngineT() {}; - void ApplyFilter(ProgressBase* pProgress); + void ApplyFilter(DSS::ProgressBase* pProgress); }; template -inline std::shared_ptr CGrayMedianFilterEngineT::GetFilteredImage(const int lFilterSize, ProgressBase* pProgress) const +inline std::shared_ptr CGrayMedianFilterEngineT::GetFilteredImage(const int lFilterSize, DSS::ProgressBase* pProgress) const { if (m_pInBitmap == nullptr) return std::shared_ptr{}; @@ -64,9 +145,9 @@ inline std::shared_ptr CGrayMedianFilterEngineT::GetFilter InternalFilter.m_pvInValues = m_pInBitmap->m_vPixels.data(); InternalFilter.m_pvOutValues = pOutBitmap->m_vPixels.data(); - InternalFilter.m_lWidth = m_pInBitmap->m_lWidth; - InternalFilter.m_lHeight = m_pInBitmap->m_lHeight; - InternalFilter.m_CFAType = m_pInBitmap->m_CFAType; + InternalFilter.m_lWidth = m_pInBitmap->RealWidth(); + InternalFilter.m_lHeight = m_pInBitmap->RealHeight(); + InternalFilter.m_CFAType = m_pInBitmap->GetCFAType(); InternalFilter.m_lFilterSize = InternalFilter.m_CFAType != CFATYPE_NONE ? lFilterSize * 2 : lFilterSize; InternalFilter.ApplyFilter(pProgress); @@ -79,7 +160,7 @@ inline std::shared_ptr CGrayMedianFilterEngineT::GetFilter template -inline std::shared_ptr CColorMedianFilterEngineT::GetFilteredImage(int lFilterSize, ProgressBase* pProgress) const +inline std::shared_ptr CColorMedianFilterEngineT::GetFilteredImage(int lFilterSize, DSS::ProgressBase* pProgress) const { if (m_pInBitmap == nullptr) return std::shared_ptr{}; @@ -91,8 +172,8 @@ inline std::shared_ptr CColorMedianFilterEngineT::GetFilte { CInternalMedianFilterEngineT InternalFilter; - InternalFilter.m_lWidth = m_pInBitmap->m_lWidth; - InternalFilter.m_lHeight = m_pInBitmap->m_lHeight; + InternalFilter.m_lWidth = m_pInBitmap->RealWidth(); + InternalFilter.m_lHeight = m_pInBitmap->RealHeight(); InternalFilter.m_lFilterSize = lFilterSize; InternalFilter.m_CFAType = CFATYPE_NONE; diff --git a/DeepSkyStacker/MemoryBitmap.cpp b/DeepSkyStacker/MemoryBitmap.cpp new file mode 100644 index 000000000..6a31fa3df --- /dev/null +++ b/DeepSkyStacker/MemoryBitmap.cpp @@ -0,0 +1,46 @@ +#include "stdafx.h" +#include "MemoryBitmap.h" +#include "Ztrace.h" +#include "CFABitmapInfo.h" + +CMemoryBitmap::CMemoryBitmap() : + m_bTopDown{ false }, + m_bMaster{ false }, + m_bCFA{ false }, + m_fExposure{ 0.0 }, + m_fAperture{ 0.0 }, + m_lISOSpeed{ 0 }, + m_lGain{ -1 }, + m_lNrFrames{ 0 } +{ + m_DateTime.wYear = 0; +} + +void CMemoryBitmap::CopyFrom(const CMemoryBitmap& mb) +{ + m_ExtraInfo = mb.m_ExtraInfo; + m_bTopDown = mb.m_bTopDown; + m_bMaster = mb.m_bMaster; + m_bCFA = mb.m_bCFA; + m_fExposure = mb.m_fExposure; + m_fAperture = mb.m_fAperture; + m_lISOSpeed = mb.m_lISOSpeed; + m_lGain = mb.m_lGain; + m_lNrFrames = mb.m_lNrFrames; + m_strDescription = mb.m_strDescription; + m_DateTime = mb.m_DateTime; + m_filterName = mb.m_filterName; +} + +void CMemoryBitmap::GetPixel16(const size_t i, const size_t j, COLORREF16& crResult) +{ + constexpr double scalingFactor = double{ 1. + std::numeric_limits::max() }; + constexpr double maxValue = double{ std::numeric_limits::max() }; + // Use get pixel + double fRed, fGreen, fBlue; + GetPixel(i, j, fRed, fGreen, fBlue); + + crResult.red = static_cast(std::min(fRed * scalingFactor, maxValue)); + crResult.green = static_cast(std::min(fGreen * scalingFactor, maxValue)); + crResult.blue = static_cast(std::min(fBlue * scalingFactor, maxValue)); +} diff --git a/DeepSkyStacker/MemoryBitmap.h b/DeepSkyStacker/MemoryBitmap.h new file mode 100644 index 000000000..82fe7a7a9 --- /dev/null +++ b/DeepSkyStacker/MemoryBitmap.h @@ -0,0 +1,213 @@ +#pragma once + +#include "BitmapExtraInfo.h" +#include "ColorRef.h" +#include "Bayer.h" + +// Not nice :( +#include + +class CMultiBitmap; +class CMedianFilterEngine; +class CBitmapCharacteristics; +namespace DSS { class ProgressBase; } + +class CMemoryBitmap +{ +public: + CBitmapExtraInfo m_ExtraInfo; + SYSTEMTIME m_DateTime; + +protected: + bool m_bTopDown; + bool m_bMaster; + bool m_bCFA; + double m_fExposure; + double m_fAperture; + int m_lISOSpeed; + int m_lGain; + int m_lNrFrames; + QString m_strDescription; + QString m_filterName; + +protected: + void CopyFrom(const CMemoryBitmap& mb); + +public: + CMemoryBitmap(); + virtual ~CMemoryBitmap() = default; + + virtual double GetExposure() + { + return m_fExposure; + }; + + virtual CMemoryBitmap& SetExposure(double fExposure) + { + m_fExposure = fExposure; + return *this; + }; + + virtual double GetAperture() + { + return m_fAperture; + }; + + virtual CMemoryBitmap& SetAperture(double fAperture) + { + m_fAperture = fAperture; + return *this; + }; + + virtual int GetISOSpeed() + { + return m_lISOSpeed; + }; + + virtual CMemoryBitmap& SetISOSpeed(int lISOSpeed) + { + m_lISOSpeed = lISOSpeed; + return *this; + }; + + virtual int GetGain() + { + return m_lGain; + }; + + virtual CMemoryBitmap& SetGain(int lGain) + { + m_lGain = lGain; + return *this; + }; + + virtual int GetNrFrames() + { + return m_lNrFrames; + }; + + virtual CMemoryBitmap& SetNrFrames(int lNrFrames) + { + m_lNrFrames = lNrFrames; + return *this; + }; + + virtual CMemoryBitmap& SetDescription(LPCTSTR szDescription) + { + m_strDescription = QString::fromWCharArray(szDescription); + return *this; + }; + + virtual CMemoryBitmap& GetDescription(QString& strDescription) + { + strDescription = m_strDescription; + return *this; + }; + + virtual CMemoryBitmap& setFilterName(const QString& name) + { + m_filterName = name; + return *this; + } + + virtual QString filterName() + { + return m_filterName; + } + + virtual bool Init(int lWidth, int lHeight) = 0; + + virtual void SetPixel(size_t i, size_t j, double fRed, double fGreen, double fBlue) = 0; + virtual void SetPixel(size_t i, size_t j, double fGray) = 0; + virtual void GetPixel(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) = 0; + virtual void GetPixel(size_t i, size_t j, double& fGray) = 0; + + virtual void SetValue(size_t i, size_t j, double fRed, double fGreen, double fBlue) {}; + virtual void GetValue(size_t i, size_t j, double& fRed, double& fGreen, double& fBlue) const {}; + virtual void SetValue(size_t i, size_t j, double fGray) {}; + virtual void GetValue(size_t i, size_t j, double& fGray) const {}; + + virtual bool GetScanLine(size_t j, void* pScanLine) = 0; + virtual bool SetScanLine(size_t j, void* pScanLine) = 0; + + void GetPixel16(const size_t i, const size_t j, COLORREF16& crResult); + + virtual int Width() const = 0; + virtual int Height() const = 0; + virtual int BitPerSample() = 0; + virtual int IsFloat() = 0; + + virtual int RealWidth() const + { + return Width(); + } + + virtual int RealHeight() const + { + return Height(); + } + + void SetOrientation(bool bTopDown) + { + m_bTopDown = bTopDown; + } + + virtual bool IsMonochrome() const = 0; + + virtual void SetMaster(bool bMaster) + { + m_bMaster = bMaster; + } + + virtual bool IsMaster() + { + return m_bMaster; + } + + virtual bool isTopDown() + { + return m_bTopDown; + } + + virtual void SetCFA(bool bCFA) + { + m_bCFA = bCFA; + } + + virtual bool IsCFA() const + { + return m_bCFA; + } + + virtual BAYERCOLOR GetBayerColor(int x, int y) + { + return BAYER_UNKNOWN; + } + + bool IsOk() + { + return (Width() > 0) && (Height() > 0); + } + + virtual CFATYPE GetCFAType() const + { + return CFATYPE_NONE; + } + + virtual std::unique_ptr Clone(bool bEmpty = false) const = 0; + + virtual std::shared_ptr CreateEmptyMultiBitmap() const = 0; + virtual void AverageBitmap(CMemoryBitmap* pBitmap, DSS::ProgressBase* pProgress) {}; + virtual void RemoveHotPixels(DSS::ProgressBase* pProgress = nullptr) = 0; + virtual std::shared_ptr GetMedianFilterEngine() const = 0; + + virtual double GetMaximumValue() const = 0; + virtual void GetCharacteristics(CBitmapCharacteristics& bc) = 0; + + virtual void InitIterator(void*& pRed, void*& pGreen, void*& pBlue, size_t& elementSize, const size_t x, const size_t y) = 0; + virtual void InitIterator(const void*& pRed, const void*& pGreen, const void*& pBlue, size_t& elementSize, const size_t x, const size_t y) const = 0; + virtual std::tuple ConvertValue3(const void* pRed, const void* pGreen, const void* pBlue) const = 0; + virtual double ConvertValue1(const void* pRed, const void* pGreen, const void* pBlue) const = 0; + virtual void ReceiveValue(void* pRed, void* pGreen, void* pBlue, const double gray) const = 0; + virtual void ReceiveValue(void* pRed, void* pGreen, void* pBlue, const double red, const double green, const double blue) const = 0; +}; diff --git a/DeepSkyStacker/MultiBitmap.h b/DeepSkyStacker/MultiBitmap.h new file mode 100644 index 000000000..ac9e7c1a1 --- /dev/null +++ b/DeepSkyStacker/MultiBitmap.h @@ -0,0 +1,118 @@ +#pragma once +#include "DSSCommon.h" +#include "BitmapPartFile.h" + +namespace DSS { class ProgressBase; } +using namespace DSS; +class CMemoryBitmap; +class CMultiBitmap +{ +protected: + std::shared_ptr m_pBitmapModel; + mutable std::shared_ptr m_pHomBitmap; + MULTIBITMAPPROCESSMETHOD m_Method; + double m_fKappa; + int m_lNrIterations; + int m_lNrBitmaps; + int m_lNrAddedBitmaps; + BITMAPPARTFILEVECTOR m_vFiles; + int m_lWidth; + int m_lHeight; + bool m_bInitDone; + bool m_bHomogenization; + double m_fMaxWeight; + std::vector m_vImageOrder; + +private: + void DestroyTempFiles(); + void InitParts(); + std::shared_ptr SmoothOut(CMemoryBitmap* pBitmap, ProgressBase* const pProgress) const; + +public: + CMultiBitmap() : + m_lNrBitmaps{ 0 }, + m_lWidth{ 0 }, + m_lHeight{ 0 }, + m_bInitDone{ false }, + m_lNrAddedBitmaps{ 0 }, + m_bHomogenization{ false }, + m_fMaxWeight{ 0 }, + m_Method{ MULTIBITMAPPROCESSMETHOD{0} }, + m_fKappa{ 0.0 }, + m_lNrIterations{ 0 } + {} + + virtual ~CMultiBitmap() + { + DestroyTempFiles(); + }; + + void SetBitmapModel(const CMemoryBitmap* pBitmap); + virtual bool SetScanLines(CMemoryBitmap* pBitmap, int lLine, const std::vector& vScanLines) = 0; + virtual std::shared_ptr CreateNewMemoryBitmap() const = 0; + virtual std::shared_ptr CreateOutputMemoryBitmap() const = 0; + + virtual void SetNrBitmaps(int lNrBitmaps) + { + m_lNrBitmaps = lNrBitmaps; + }; + + int GetNrBitmaps() + { + return m_lNrBitmaps; + }; + + int GetNrAddedBitmaps() + { + return m_lNrAddedBitmaps; + }; + + void SetImageOrder(const std::vector& vImageOrder) + { + m_vImageOrder = vImageOrder; + }; + + const std::vector& GetImageOrder() const + { + return this->m_vImageOrder; + } + + virtual bool AddBitmap(CMemoryBitmap* pMemoryBitmap, ProgressBase* pProgress = nullptr); + virtual std::shared_ptr GetResult(ProgressBase* pProgress = nullptr); + virtual int GetNrChannels() const = 0; + virtual int GetNrBytesPerChannel() const = 0; + + void SetProcessingMethod(MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations) + { + m_Method = Method; + m_fKappa = fKappa; + m_lNrIterations = lNrIterations; + }; + + void SetHomogenization(bool bSet) + { + m_bHomogenization = bSet; + }; + + bool GetHomogenization() const + { + return m_bHomogenization; + } + + CMemoryBitmap* GetHomogenBitmap() const + { + if (static_cast(this->m_pHomBitmap)) + return m_pHomBitmap.get(); + return nullptr; + } + + int GetProcessingMethod() const + { + return m_Method; + } + + auto GetProcessingParameters() const + { + return std::make_tuple(m_fKappa, m_lNrIterations); + } +}; \ No newline at end of file diff --git a/DeepSkyStacker/MultiBitmapProcess.cpp b/DeepSkyStacker/MultiBitmapProcess.cpp index b84ffb100..313db5b39 100644 --- a/DeepSkyStacker/MultiBitmapProcess.cpp +++ b/DeepSkyStacker/MultiBitmapProcess.cpp @@ -1,15 +1,15 @@ #include -#include "resource.h" -#include "BitmapBase.h" -#include "DSSTools.h" +#include #include "MultiBitmapProcess.h" #include "StackingTasks.h" -#include "DSSProgress.h" -#include -#include +#include "MultiBitmap.h" +#include "MemoryBitmap.h" +#include "Ztrace.h" #include "Multitask.h" #include "avx_output.h" -#include +#include "ZExcBase.h" +#include "GrayBitmap.h" +#include "ColorBitmap.h" /* ------------------------------------------------------------------- */ @@ -37,9 +37,9 @@ void CMultiBitmap::DestroyTempFiles() { for (int i = 0;i CMultiBitmap::GetResult(ProgressBase* pProgress) if (fileSize > buffer.size()) buffer.resize(fileSize); - FILE* hFile = _tfopen(file.m_strFile, _T("rb")); + FILE* hFile = _tfopen(file.m_strFile.toStdWString().c_str(), _T("rb")); if (hFile != nullptr) { bResult = fread(buffer.data(), 1, fileSize, hFile) == fileSize; diff --git a/DeepSkyStacker/MultiBitmapProcess.h b/DeepSkyStacker/MultiBitmapProcess.h index a255ca1bb..36a61aa32 100644 --- a/DeepSkyStacker/MultiBitmapProcess.h +++ b/DeepSkyStacker/MultiBitmapProcess.h @@ -1,6 +1,5 @@ -#ifndef _MULTIBITMAPPROCESS_H__ -#define _MULTIBITMAPPROCESS_H__ - +#pragma once +#include class CBitmapPart { @@ -48,5 +47,3 @@ public : }; typedef std::vector BITMAPPARTVECTOR; - -#endif // _MULTIBITMAPPROCESS_H__ diff --git a/DeepSkyStacker/OutputTab.cpp b/DeepSkyStacker/OutputTab.cpp index 7c1206a67..04db0b752 100644 --- a/DeepSkyStacker/OutputTab.cpp +++ b/DeepSkyStacker/OutputTab.cpp @@ -1,19 +1,4 @@ #include "stdafx.h" -#include -using std::min; -using std::max; - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include - -#include -#include - -#include -#include -#include -#include - #include "OutputTab.h" #include "ui/ui_OutputTab.h" diff --git a/DeepSkyStacker/OutputTab.h b/DeepSkyStacker/OutputTab.h index e2258f44c..ae62742fe 100644 --- a/DeepSkyStacker/OutputTab.h +++ b/DeepSkyStacker/OutputTab.h @@ -1,13 +1,8 @@ -#ifndef OUTPUTTAB_H -#define OUTPUTTAB_H +#pragma once +#include "StackingTasks.h" class QString; -#include - -#include "DSSCommon.h" -#include "StackingTasks.h" - namespace Ui { class OutputTab; } @@ -43,5 +38,3 @@ private slots: void on_otherFolder_clicked(); void on_outputFolder_pressed(); }; - -#endif // OUTPUTTAB_H diff --git a/DeepSkyStacker/PCLTools.cpp b/DeepSkyStacker/PCLTools.cpp deleted file mode 100644 index 2465c71f4..000000000 --- a/DeepSkyStacker/PCLTools.cpp +++ /dev/null @@ -1,296 +0,0 @@ -#include - -#ifdef PCL_PROJECT - -#include "DSSTools.h" -#include "BitmapExt.h" -#include "DSSProgress.h" -#include "PCLTools.h" -#include - -/* ------------------------------------------------------------------- */ - -bool IsPCLPicture(LPCTSTR szFileName, CBitmapInfo & BitmapInfo) -{ - bool bResult = true; - - BitmapInfo.m_bCanLoad = true; - BitmapInfo.m_strFileName = szFileName; - BitmapInfo.m_lNrChannels = 3; - - return bResult; -}; - -/* ------------------------------------------------------------------- */ - -template -bool LoadPCLImageInMemoryBitmap(CMemoryBitmap * pBitmap, PCLImage * pImage, int NrChannels, double fMultiplier) -{ - bool bResult = true; - bool bGray = (NrChannels == 1); - - for (int i = 0;iWidth();i++) - { - for (int j = 0;jHeight();j++) - { - if (bGray) - { - double fGray; - - fGray = fMultiplier * pImage->Pixel(i, j, 0); - pBitmap->SetPixel(i, j, fGray); - } - else - { - double fRed, - fGreen, - fBlue; - - fRed = fMultiplier * pImage->Pixel(i, j, 0); - fGreen = fMultiplier * pImage->Pixel(i, j, 1); - fBlue = fMultiplier * pImage->Pixel(i, j, 2); - - pBitmap->SetPixel(i, j, fRed, fGreen, fBlue); - }; - }; - }; - - return bResult; -}; - -/* ------------------------------------------------------------------- */ - -bool LoadPCLPicture(LPCTSTR szFileName, CMemoryBitmap ** ppBitmap, ProgressBase * pProgress) -{ - bool bResult = false; - CString strFileName = szFileName; - pcl::String filename; - filename = szFileName; - - pcl::ImageWindow PCLWindow( filename); - - if ( PCLWindow.IsNull() ) - { - CString strError; - - strError.Format("Unable to load image file: %s", szFileName); - throw pcl::Error( (LPCTSTR)strError); - } - else - { - CSmartPtr pBitmap; - pcl::View PCLView = PCLWindow.MainView(); - pcl::ImageVariant PCLImage = PCLView.GetImage(); - - int width = PCLImage.AnyImage()->Width(); - int height = PCLImage.AnyImage()->Height(); - int numberOfChannels = PCLImage.AnyImage()->IsColor() ? 3 : 1; - int nBitPerChannel; - bool bFloat; - - PCLWindow.GetSampleFormat(nBitPerChannel, bFloat); - - // From here created the appropriate MemoryBitmap - if (numberOfChannels == 1) - { - switch (nBitPerChannel) - { - case 8 : - pBitmap.Attach(new C8BitGrayBitmap); - break; - case 16 : - pBitmap.Attach(new C16BitGrayBitmap); - break; - case 32 : - case 64 : - if (bFloat) - pBitmap.Attach(new C32BitFloatGrayBitmap); - else - pBitmap.Attach(new C32BitGrayBitmap); - break; - }; - } - else - { - switch (nBitPerChannel) - { - case 8 : - pBitmap.Attach(new C24BitMemoryBitmap); - break; - case 16 : - pBitmap.Attach(new C48BitMemoryBitmap); - break; - case 32 : - case 64 : - if (bFloat) - pBitmap.Attach(new C96BitMemoryBitmap); - else - pBitmap.Attach(new C96BitFloatMemoryBitmap); - break; - }; - }; - - if (pBitmap) - { - // Then fill the memory bitmap with the values - if (pBitmap->Init(width, height)) - { - switch (nBitPerChannel) - { - case 8 : - bResult = LoadPCLImageInMemoryBitmap(pBitmap, reinterpret_cast( PCLImage.AnyImage() ), numberOfChannels, 1.0); - break; - case 16 : - bResult = LoadPCLImageInMemoryBitmap(pBitmap, reinterpret_cast( PCLImage.AnyImage() ), numberOfChannels, 1.0/256.0); - break; - case 32 : - if (bFloat) - bResult = LoadPCLImageInMemoryBitmap(pBitmap, reinterpret_cast( PCLImage.AnyImage() ), numberOfChannels, 256.0); - else - bResult = LoadPCLImageInMemoryBitmap(pBitmap, reinterpret_cast( PCLImage.AnyImage() ), numberOfChannels, 1/256.0/65536.0); - break; - case 64 : - bResult = LoadPCLImageInMemoryBitmap(pBitmap, reinterpret_cast( PCLImage.AnyImage() ), numberOfChannels, 256.0); - break; - }; - - if (bResult) - pBitmap.CopyTo(ppBitmap); - }; - }; - - PCLWindow.Close(); - }; - - return bResult; -}; - -/* ------------------------------------------------------------------- */ - -template -void CreatePCLImageWindow( const pcl::Generic2DImage

& image, const pcl::String& id ) -{ - // Create an image window with a 1x1x1 dummy image. - // Tricky but efficient: the core application understands this and prepares - // to build an actual image in subsequent steps. - pcl::ImageWindow w( 1, 1, 1, P::BitsPerSample(), P::IsFloatSample(), false, true, id ); - - if ( w.IsNull() ) - throw pcl::Error( "Unable to create image window: " + id ); - - image.ResetSelections(); // in case we have made partial selections before - reinterpret_cast*>( w.MainView().GetImage().AnyImage() )->Assign( image ); - - w.Show(); - w.ZoomToFit( false ); // leave'em laughing :-) -} - -/* ------------------------------------------------------------------- */ - -template -bool CreatePCLImage(CMemoryBitmap * pBitmap, pcl::Generic2DImage

& image, double fMultiplier) -{ - bool bResult = false; - pcl::String id; - int i, j; - - try - { - bResult = true; - if (pBitmap->IsMonochrome() && !pBitmap->IsCFA()) - { - image.AllocateData(pBitmap->Width(), pBitmap->Height(), 1, pcl::ColorSpace::Gray); - for (i = 0;iWidth();i++) - { - for (j = 0;jHeight();j++) - { - double fGray; - P::sample * fValue; - - pBitmap->GetPixel(i, j, fGray); - fValue = image.PixelAddress(i, j, 0); - *fValue = fGray*fMultiplier; - }; - }; - } - else - { - image.AllocateData(pBitmap->Width(), pBitmap->Height(), 3, pcl::ColorSpace::RGB); - for (i = 0;iWidth();i++) - { - for (j = 0;jHeight();j++) - { - double fRed, fGreen, fBlue; - P::sample * fValue; - - pBitmap->GetPixel(i, j, fRed, fGreen, fBlue); - fValue = image.PixelAddress(i, j, 0); - *fValue = fRed*fMultiplier; - fValue = image.PixelAddress(i, j, 1); - *fValue = fGreen*fMultiplier; - fValue = image.PixelAddress(i, j, 2); - *fValue = fBlue*fMultiplier; - }; - }; - }; - - if (bResult) - CreatePCLImageWindow(image, id); - } - catch(...) - { - bResult = false; - }; - - return bResult; -}; - -/* ------------------------------------------------------------------- */ - -bool CreatePCLView(CMemoryBitmap * pBitmap) -{ - bool bResult = false; - - if (pBitmap) - { - if (pBitmap->IsFloat()) - { - pcl::Image PCLImage; - - CreatePCLImage(pBitmap, PCLImage, 1/256.0); - } - else - { - switch (pBitmap->BitPerSample()) - { - case 8 : - { - pcl::UInt8Image PCLImage; - - CreatePCLImage(pBitmap, PCLImage, 1.0); - } - break; - case 16 : - { - pcl::UInt16Image PCLImage; - - CreatePCLImage(pBitmap, PCLImage, 256.0); - } - break; - case 32 : - { - pcl::UInt32Image PCLImage; - - CreatePCLImage(pBitmap, PCLImage, 256*0*65536.0); - } - break; - }; - }; - }; - - return bResult; -}; - -/* ------------------------------------------------------------------- */ - -#endif \ No newline at end of file diff --git a/DeepSkyStacker/PCLTools.h b/DeepSkyStacker/PCLTools.h deleted file mode 100644 index 1e380794d..000000000 --- a/DeepSkyStacker/PCLTools.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __PCLTOOLS_H__ -#define __PCLTOOLS_H__ - -#ifdef PCL_PROJECT - -bool IsPCLPicture(LPCTSTR szFileName, CBitmapInfo & BitmapInfo); -bool LoadPCLPicture(LPCTSTR szFileName, CMemoryBitmap ** ppBitmap, ProgressBase * pProgress); -bool CreatePCLView(CMemoryBitmap * pBitmap); - -#endif - -#endif \ No newline at end of file diff --git a/DeepSkyStacker/PixelTransform.h b/DeepSkyStacker/PixelTransform.h index 00965474b..21688b09b 100644 --- a/DeepSkyStacker/PixelTransform.h +++ b/DeepSkyStacker/PixelTransform.h @@ -1,6 +1,7 @@ #pragma once #include "DSSTools.h" +#include "BilinearParameters.h" class CPixelTransform { diff --git a/DeepSkyStacker/PostCalibration.cpp b/DeepSkyStacker/PostCalibration.cpp index b43628848..332214a4d 100644 --- a/DeepSkyStacker/PostCalibration.cpp +++ b/DeepSkyStacker/PostCalibration.cpp @@ -1,33 +1,18 @@ #include "stdafx.h" -#include -using std::min; -using std::max; - -#include -#include - -#include -#include -#include -#include -#include -#include - #include "PostCalibration.h" #include "ui/ui_PostCalibration.h" - -extern bool g_bShowRefStars; - -#include "resource.h" -#include "commonresource.h" +#include "Workspace.h" +#include "StackSettings.h" +#include "ZExcept.h" +#include "Ztrace.h" +#include "QtProgressDlg.h" +#include "MasterFrames.h" +#include "BitmapInfo.h" #include "BitmapExt.h" #include "CosmeticEngine.h" -#include "MasterFrames.h" -#include "DSSProgress.h" -#include "QtProgressDlg.h" -#include "StackSettings.h" -#include "StackingTasks.h" -#include "Workspace.h" +#include "commonresource.h" + +extern bool g_bShowRefStars; PostCalibration::PostCalibration(QWidget *parent) : QWidget(parent), @@ -373,14 +358,13 @@ void PostCalibration::on_testCosmetic_clicked() // Load the bitmap if (GetPictureInfo(strFileName, bmpInfo) && bmpInfo.CanLoad()) { - CString strDescription; - + QString strDescription; bmpInfo.GetDescription(strDescription); if (bmpInfo.m_lNrChannels == 3) - strText = QCoreApplication::translate("PostCalibration", "Loading %1 bit/ch %2 light frame\n%3", "IDS_LOADRGBLIGHT").arg(bmpInfo.m_lBitPerChannel).arg(QString::fromWCharArray(strDescription.GetString())).arg(QString::fromWCharArray(strFileName)); + strText = QCoreApplication::translate("PostCalibration", "Loading %1 bit/ch %2 light frame\n%3", "IDS_LOADRGBLIGHT").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(QString::fromWCharArray(strFileName)); else - strText = QCoreApplication::translate("PostCalibration", "Loading %1 bits gray %2 light frame\n%3", "IDS_LOADGRAYLIGHT").arg(bmpInfo.m_lBitPerChannel).arg(QString::fromWCharArray(strDescription.GetString())).arg(QString::fromWCharArray(strFileName)); + strText = QCoreApplication::translate("PostCalibration", "Loading %1 bits gray %2 light frame\n%3", "IDS_LOADGRAYLIGHT").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(QString::fromWCharArray(strFileName)); dlg.Start2(strText, 0); std::shared_ptr pBitmap; diff --git a/DeepSkyStacker/PostCalibration.h b/DeepSkyStacker/PostCalibration.h index 68a61845e..0d5ec35dc 100644 --- a/DeepSkyStacker/PostCalibration.h +++ b/DeepSkyStacker/PostCalibration.h @@ -1,5 +1,5 @@ -#ifndef POSTCALIBRATION_H -#define POSTCALIBRATION_H +#pragma once +#include "StackingTasks.h" class Workspace; class StackSettings; @@ -8,11 +8,6 @@ class QAction; class QString; class QMenu; -#include - -#include "DSSCommon.h" -#include "StackingTasks.h" - namespace Ui { class PostCalibration; } @@ -59,5 +54,3 @@ private slots: void on_saveDeltaImage_toggled(bool); void on_testCosmetic_clicked(); }; - -#endif // POSTCALIBRATION_H diff --git a/DeepSkyStacker/ProcessSettingsSheet.cpp b/DeepSkyStacker/ProcessSettingsSheet.cpp index 4a5f2905b..f47ab0a80 100644 --- a/DeepSkyStacker/ProcessSettingsSheet.cpp +++ b/DeepSkyStacker/ProcessSettingsSheet.cpp @@ -2,7 +2,6 @@ // #include "stdafx.h" -#include "DeepSkyStacker.h" #include "ProcessSettingsSheet.h" ///////////////////////////////////////////////////////////////////////////// diff --git a/DeepSkyStacker/ProcessSettingsSheet.h b/DeepSkyStacker/ProcessSettingsSheet.h index 26ea529b5..fabbf398f 100644 --- a/DeepSkyStacker/ProcessSettingsSheet.h +++ b/DeepSkyStacker/ProcessSettingsSheet.h @@ -1,15 +1,4 @@ -#if !defined(AFX_PROCESSSETTINGSSHEET_H__E02AC601_555D_4F13_9260_01D84356A200__INCLUDED_) -#define AFX_PROCESSSETTINGSSHEET_H__E02AC601_555D_4F13_9260_01D84356A200__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 -// ProcessSettingsSheet.h : header file -// - -#include "RGBTab.h" -#include "LuminanceTab.h" -#include "SaturationTab.h" ///////////////////////////////////////////////////////////////////////////// // CProcessSettingsSheet @@ -46,9 +35,3 @@ class CProcessSettingsSheet : public CPropertySheet DECLARE_MESSAGE_MAP() }; -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PROCESSSETTINGSSHEET_H__E02AC601_555D_4F13_9260_01D84356A200__INCLUDED_) diff --git a/DeepSkyStacker/ProcessingDlg.cpp b/DeepSkyStacker/ProcessingDlg.cpp index 11d4ab8e4..034acc4c8 100644 --- a/DeepSkyStacker/ProcessingDlg.cpp +++ b/DeepSkyStacker/ProcessingDlg.cpp @@ -2,23 +2,20 @@ // #include "stdafx.h" -#include "DeepSkyStacker.h" #include "ProcessingDlg.h" -#include "QtProgressDlg.h" -#include +#include "DeepSkyStacker.h" +#include "DeepStack.h" #include "SettingsDlg.h" - -#include "SavePicture.h" +#include "Ztrace.h" +#include "QtProgressDlg.h" +#include "StarMaskDlg.h" #include "StarMask.h" #include "FITSUtil.h" #include "TIFFUtil.h" -#include "StarMaskDlg.h" - -#define _USE_MATH_DEFINES -#include +#include "SavePicture.h" #define dssApp DeepSkyStacker::instance() - +extern CString OUTPUTFILE_FILTERS; constexpr unsigned int WM_INITNEWPICTURE = WM_USER + 1; /* ------------------------------------------------------------------- */ diff --git a/DeepSkyStacker/ProcessingDlg.h b/DeepSkyStacker/ProcessingDlg.h index fa2c27a6e..96a992a78 100644 --- a/DeepSkyStacker/ProcessingDlg.h +++ b/DeepSkyStacker/ProcessingDlg.h @@ -1,31 +1,13 @@ -#if !defined(AFX_PROCESSINGDLG_H__744333B6_CE01_4CA9_B554_4EB7D98B544D__INCLUDED_) -#define AFX_PROCESSINGDLG_H__744333B6_CE01_4CA9_B554_4EB7D98B544D__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 -// ProcessingDlg.h : header file -// - -#include -#include -#include -#include "DeepStack.h" -#include +#include "dss_settings.h" +#include "ControlPos.h" +#include "ProcessSettingsSheet.h" +#include "RGBTab.h" +#include "LuminanceTab.h" +#include "SaturationTab.h" #include "ImageSinks.h" -#include -#include -#include "Label.h" - #include "commonresource.h" -#include "ProcessSettingsSheet.h" -#include "dss_settings.h" - -#include - -using namespace Gdiplus; - /* ------------------------------------------------------------------- */ class CValuedRect @@ -441,8 +423,3 @@ inline CProcessingDlg * GetParentProcessingDlg(CWnd * pWnd) return pResult; }; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PROCESSINGDLG_H__744333B6_CE01_4CA9_B554_4EB7D98B544D__INCLUDED_) diff --git a/DeepSkyStacker/QtProgressDlg.cpp b/DeepSkyStacker/QtProgressDlg.cpp index 3f20a45a3..262dbeae9 100644 --- a/DeepSkyStacker/QtProgressDlg.cpp +++ b/DeepSkyStacker/QtProgressDlg.cpp @@ -1,9 +1,7 @@ #include "stdafx.h" -#include "deepskystacker.h" #include "QtProgressDlg.h" -#include -#include "qevent.h" #include "ui/ui_ProgressDlg.h" +#include "DeepSkyStacker.h" using namespace DSS; diff --git a/DeepSkyStacker/QtProgressDlg.h b/DeepSkyStacker/QtProgressDlg.h index 91429e17c..8001a46f8 100644 --- a/DeepSkyStacker/QtProgressDlg.h +++ b/DeepSkyStacker/QtProgressDlg.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "DSSProgress.h" namespace Ui { class ProgressDlg; diff --git a/DeepSkyStacker/RAWUtils.cpp b/DeepSkyStacker/RAWUtils.cpp index 4988de742..f4f95306d 100644 --- a/DeepSkyStacker/RAWUtils.cpp +++ b/DeepSkyStacker/RAWUtils.cpp @@ -1,26 +1,31 @@ #include "stdafx.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "resource.h" -#include "BitmapExt.h" -#include "DSSTools.h" -#include "DSSProgress.h" - #include "RAWUtils.h" -#include "Multitask.h" -#include "Workspace.h" - #include "libraw/libraw.h" +#include "Ztrace.h" +#include "Workspace.h" +#include "DSSProgress.h" +#include "resource.h" +#include "MemoryBitmap.h" +#include "Multitask.h" +#include "MedianFilterEngine.h" +#include "ZExcBase.h" +#include "BitmapInfo.h" + +// #include +// #include +// +// #include "resource.h" +// #include "BitmapExt.h" +// #include "DSSTools.h" +// #include "DSSProgress.h" +// +// #include "RAWUtils.h" +// #include "Multitask.h" +// #include "Workspace.h" +// +// #include "libraw/libraw.h" + +using namespace DSS; namespace { class Timer @@ -162,12 +167,6 @@ void PopRAWSettings() /* ------------------------------------------------------------------- */ -#include -#include -#include -#include -#include - #include "BitMapFiller.h" #define Thread __declspec( thread ) @@ -937,15 +936,19 @@ namespace { // Only use in this .cpp file /* ------------------------------------------------------------------- */ -bool IsRAWPicture(LPCTSTR szFileName, CString& strModel) +bool IsRAWPicture(LPCTSTR szFileName, QString& strModel) { ZFUNCTRACE_RUNTIME(); CRawDecod dcr(szFileName); bool bResult = dcr.IsRawFile(); - if (bResult) - dcr.GetModel(strModel); + CString cstrModel; + if (bResult) + { + dcr.GetModel(cstrModel); + strModel = QString::fromWCharArray(cstrModel.GetString()); + } return bResult; }; @@ -978,7 +981,7 @@ bool IsRAWPicture(LPCTSTR szFileName, CBitmapInfo& BitmapInfo) if (bResult) { - BitmapInfo.m_strFileName = szFileName; + BitmapInfo.m_strFileName = QString::fromWCharArray(szFileName); BitmapInfo.m_strFileType = "RAW"; if (dcr.IsColorRAW()) BitmapInfo.m_CFAType = CFATYPE_NONE; @@ -989,7 +992,9 @@ bool IsRAWPicture(LPCTSTR szFileName, CBitmapInfo& BitmapInfo) BitmapInfo.m_lBitPerChannel = 16; BitmapInfo.m_lNrChannels = dcr.IsColorRAW() ? 3 : 1; BitmapInfo.m_bCanLoad = true; - dcr.GetModel(BitmapInfo.m_strModel); + CString strModel; + dcr.GetModel(strModel); + BitmapInfo.m_strModel = QString::fromWCharArray(strModel.GetString()); BitmapInfo.m_lISOSpeed = dcr.GetISOSpeed(); BitmapInfo.m_fExposure = dcr.GetExposureTime(); BitmapInfo.m_fAperture = dcr.getAperture(); diff --git a/DeepSkyStacker/RAWUtils.h b/DeepSkyStacker/RAWUtils.h index 7ccdf99e2..0aa2da388 100644 --- a/DeepSkyStacker/RAWUtils.h +++ b/DeepSkyStacker/RAWUtils.h @@ -1,7 +1,10 @@ -#ifndef _RAWUTILS_H__ -#define _RAWUTILS_H__ +#pragma once +#include + +class CBitmapInfo; +class CMemoryBitmap; +namespace DSS { class ProgressBase; } -#if DSSFILEDECODING==1 bool IsSuperPixels(); bool IsRawBayer(); bool IsRawAHD(); @@ -10,20 +13,6 @@ bool IsRawBilinear(); void PushRAWSettings(bool bSuperPixel, bool bRawBayer); void PopRAWSettings(); -bool IsRAWPicture(LPCTSTR szFileName, CString& strModel); +bool IsRAWPicture(LPCTSTR szFileName, QString& strModel); bool IsRAWPicture(LPCTSTR szFileName, CBitmapInfo& BitmapInfo); -bool LoadRAWPicture(LPCTSTR szFileName, std::shared_ptr& rpBitmap, ProgressBase* pProgress); - -#else -inline bool IsSuperPixels() { return false; }; -inline bool IsRawBayer() { return false; }; -inline bool IsRawAHD() { return false; }; -inline bool IsRawBilinear() { return false; }; - -inline void PushRAWSettings(bool bSuperPixel, bool bRawBayer) {}; -inline void PopRAWSettings() {}; - -#endif // !DSSFILEDECODING - - -#endif // _RAWUTILS_H__ \ No newline at end of file +bool LoadRAWPicture(LPCTSTR szFileName, std::shared_ptr& rpBitmap, DSS::ProgressBase* pProgress); diff --git a/DeepSkyStacker/RGBTab.cpp b/DeepSkyStacker/RGBTab.cpp index cc908dc37..122cbcfb5 100644 --- a/DeepSkyStacker/RGBTab.cpp +++ b/DeepSkyStacker/RGBTab.cpp @@ -1,10 +1,7 @@ // RGBTab.cpp : implementation file // - #include "stdafx.h" -#include "DeepSkyStacker.h" #include "RGBTab.h" -#include #include "ProcessingDlg.h" ///////////////////////////////////////////////////////////////////////////// diff --git a/DeepSkyStacker/RGBTab.h b/DeepSkyStacker/RGBTab.h index 5a5b5a3d6..fa1d1380a 100644 --- a/DeepSkyStacker/RGBTab.h +++ b/DeepSkyStacker/RGBTab.h @@ -1,17 +1,8 @@ -#if !defined(AFX_RGBTAB_H__82B3FFF2_8DA4_4979_BCC7_09D28857619B__INCLUDED_) -#define AFX_RGBTAB_H__82B3FFF2_8DA4_4979_BCC7_09D28857619B__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 -// RGBTab.h : header file -// - -#include -#include -#include -#include +#include "childprop.h" #include "Histogram.h" +#include "BtnST.h" +#include "gradientctrl.h" ///////////////////////////////////////////////////////////////////////////// // CRGBTab dialog @@ -148,8 +139,3 @@ private : DECLARE_MESSAGE_MAP() }; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_RGBTAB_H__82B3FFF2_8DA4_4979_BCC7_09D28857619B__INCLUDED_) diff --git a/DeepSkyStacker/RationalInterpolation.h b/DeepSkyStacker/RationalInterpolation.h new file mode 100644 index 000000000..69142c616 --- /dev/null +++ b/DeepSkyStacker/RationalInterpolation.h @@ -0,0 +1,57 @@ +#pragma once + +class CRationalInterpolation +{ +private: + double a, b, c; + double fMin, fMax; + +private: + +public: + CRationalInterpolation() + { + a = b = 0; + c = 1; + fMin = 0; + fMax = 0; + }; + + CRationalInterpolation(const CRationalInterpolation&) = default; + + CRationalInterpolation& operator = (const CRationalInterpolation&) = default; + + double Interpolate(double x) const noexcept + { + if (b || c) + return std::max(std::min((x + a) / (b * x + c), fMax), fMin); + else + return std::max(std::min(x + a, fMax), fMin); + }; + + void Initialize(double x0, double x1, double x2, double y0, double y1, double y2) noexcept + { + double t1 = ((x0 * y0 - x1 * y1) * (y0 - y2) - (x0 * y0 - x2 * y2) * (y0 - y1)); + double t2 = ((x0 - x1) * (y0 - y2) - (x0 - x2) * (y0 - y1)); + double t3 = (y0 - y1); + + if (t1) + b = t2 / t1; + else + b = 0; + if (t3) + c = ((x0 - x1) - b * (x0 * y0 - x1 * y1)) / t3; + else + c = 0; + a = (b * x0 + c) * y0 - x0; + + fMin = std::min(std::min(y0, y1), y2); + fMax = std::max(std::max(y0, y1), y2); + }; + + float getParameterA() const noexcept { return static_cast(this->a); } + float getParameterB() const noexcept { return static_cast(this->b); } + float getParameterC() const noexcept { return static_cast(this->c); } + float getParameterMin() const noexcept { return static_cast(this->fMin); } + float getParameterMax() const noexcept { return static_cast(this->fMax); } +}; \ No newline at end of file diff --git a/DeepSkyStacker/RawDDPSettings.cpp b/DeepSkyStacker/RawDDPSettings.cpp index bb61b92cf..99cbf731c 100644 --- a/DeepSkyStacker/RawDDPSettings.cpp +++ b/DeepSkyStacker/RawDDPSettings.cpp @@ -1,82 +1,14 @@ // RawDDPSettings.cpp : implementation file // - -#include -using std::min; -using std::max; - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include -#include -#include -#include - - -//#include - -#include -#include - -#include -#include -#include -#include -#include -#include - +#include "stdafx.h" #include "RawDDPSettings.h" -#include "ui/ui_RawDDPSettings.h" - -extern bool g_bShowRefStars; -#include "commonresource.h" -#include "resource.h" - +#include "dslr.h" +#include "Ztrace.h" +#include "ui_RawDDPSettings.h" +#include "Workspace.h" #include "DeepSkyStacker.h" -#include "DSSCommon.h" -#include "BitmapExt.h" -#include "QtProgressDlg.h" -#include "RegisterEngine.h" +#include "ZExcept.h" #include "StackingDlg.h" -#include "StackSettings.h" - -#include "Workspace.h" - -class CDSLR -{ -public: - QString m_strName; - CFATYPE m_CFAType; - -private: - void CopyFrom(const CDSLR & cd) - { - m_strName = cd.m_strName; - m_CFAType = cd.m_CFAType; - }; - -public: - CDSLR(QString name, CFATYPE CFAType) : - m_strName(name), - m_CFAType(CFAType) - { - }; - - CDSLR(const CDSLR & cd) - { - CopyFrom(cd); - }; - - virtual ~CDSLR() - { - }; - - const CDSLR & operator = (const CDSLR & cd) - { - CopyFrom(cd); - return *this; - }; -}; - void RawDDPSettings::fillDSLRList(std::vector & vDSLRs) { diff --git a/DeepSkyStacker/RawDDPSettings.h b/DeepSkyStacker/RawDDPSettings.h index 3b9154e4e..d31a1b822 100644 --- a/DeepSkyStacker/RawDDPSettings.h +++ b/DeepSkyStacker/RawDDPSettings.h @@ -1,20 +1,13 @@ -#ifndef RAWDDPSETTINGS_H -#define RAWDDPSETTINGS_H -#include - -class Workspace; -class QAbstractButton; -class QValidator; -class CDSLR; -enum CFATYPE : unsigned int; - -#include "DSSCommon.h" -#include +#pragma once +#include "dslr.h" namespace Ui { class RawDDPSettings; } +class Workspace; +class QValidator; +class QShowEvent; class RawDDPSettings : public QDialog { Q_OBJECT @@ -74,5 +67,3 @@ private slots: void showEvent(QShowEvent *event) override; void onInitDialog(); }; - -#endif // RAWDDPSETTINGS_H diff --git a/DeepSkyStacker/RecommendedSettings.cpp b/DeepSkyStacker/RecommendedSettings.cpp index 12e02bfb3..88392e938 100644 --- a/DeepSkyStacker/RecommendedSettings.cpp +++ b/DeepSkyStacker/RecommendedSettings.cpp @@ -1,42 +1,70 @@ // RecommendedSettings.cpp : implementation file // - -#include -using std::min; -using std::max; -#include - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern bool g_bShowRefStars; - -#include "commonresource.h" -#include "DSSCommon.h" +#include "stdafx.h" +#include "RecommendedSettings.h" +#include "ui/ui_RecommendedSettings.h" #include "DeepSkyStacker.h" -#include "Multitask.h" -#include "DSSTools.h" -#include "DSSProgress.h" +#include "StackingDlg.h" -/* ------------------------------------------------------------------- */ -#include "RecommendedSettings.h" -#include "ui/ui_RecommendedSettings.h" +bool RecommendationItem::differsFromWorkspace() +{ + bool bResult = false; + Workspace workspace; + + // Check that the current values are (or not) + for (const auto setting : vSettings) + { + QString keyName; + QVariant value; + QVariant currentValue; + + + keyName = setting.key(); + + currentValue = workspace.value(keyName); + value = setting.value(); + +#if QT_VERSION >= 0x060000 + switch (static_cast(value.typeId())) +#else + switch (value.type()) +#endif + { + case QMetaType::Bool: + bResult = value.toBool() != currentValue.toBool(); + break; + case QMetaType::Double: + bResult = value.toDouble() != currentValue.toDouble(); + break; + default: + bResult = value.toString() != currentValue.toString(); + } + + // + // If different, no need to check any more + // + if (bResult) break; + }; + return bResult; +} + +void RecommendationItem::applySettings() +{ + Workspace workspace; + + for (size_t i = 0; i < vSettings.size(); i++) + { + QString keyName; + QVariant value; + + keyName = vSettings[i].key(); + value = vSettings[i].value(); + + workspace.setValue(keyName, value); + }; +} + // RecommendedSettings dialog diff --git a/DeepSkyStacker/RecommendedSettings.h b/DeepSkyStacker/RecommendedSettings.h index 3fd9ce5a3..8e8c24268 100644 --- a/DeepSkyStacker/RecommendedSettings.h +++ b/DeepSkyStacker/RecommendedSettings.h @@ -1,26 +1,18 @@ #ifndef RECOMMENDEDSETTINGS_H #define RECOMMENDEDSETTINGS_H -#include -#include +#include "Workspace.h" +#include "StackingTasks.h" class Workspace; class QAbstractButton; class QUrl; -#include -#include - -#include "DSSCommon.h" -#include "StackingTasks.h" -#include "Workspace.h" - - class RecommendationItem { public: - WORKSPACESETTINGVECTOR vSettings; - int linkID; - QString recommendation; + WORKSPACESETTINGVECTOR vSettings; + int linkID; + QString recommendation; public: @@ -54,63 +46,8 @@ class RecommendationItem recommendation.clear(); }; - bool differsFromWorkspace() - { - bool bResult = false; - Workspace workspace; - - // Check that the current values are (or not) - for (const auto setting : vSettings) - { - QString keyName; - QVariant value; - QVariant currentValue; - - - keyName = setting.key(); - - currentValue = workspace.value(keyName); - value = setting.value(); - -#if QT_VERSION >= 0x060000 - switch (static_cast(value.typeId())) -#else - switch (value.type()) -#endif - { - case QMetaType::Bool: - bResult = value.toBool() != currentValue.toBool(); - break; - case QMetaType::Double: - bResult = value.toDouble() != currentValue.toDouble(); - break; - default: - bResult = value.toString() != currentValue.toString(); - } - - // - // If different, no need to check any more - // - if (bResult) break; - }; - return bResult; - }; - - void applySettings() - { - Workspace workspace; - - for (size_t i = 0; i < vSettings.size(); i++) - { - QString keyName; - QVariant value; - - keyName = vSettings[i].key(); - value = vSettings[i].value(); - - workspace.setValue(keyName, value); - }; - }; + bool differsFromWorkspace(); + void applySettings(); void setRecommendation(QString text) { diff --git a/DeepSkyStacker/RegisterEngine.cpp b/DeepSkyStacker/RegisterEngine.cpp index 9268484c5..729595cb8 100644 --- a/DeepSkyStacker/RegisterEngine.cpp +++ b/DeepSkyStacker/RegisterEngine.cpp @@ -1,25 +1,25 @@ #include -#include - -#include "resource.h" -#include "dssrect.h" +#include +#include +#include #include "RegisterEngine.h" - -#include "MasterFrames.h" -#include "BackgroundCalibration.h" +#include "Workspace.h" #include "PixelTransform.h" -#include "TIFFUtil.h" -#include "FITSUtil.h" -#include "Filters.h" +#include "Ztrace.h" +#include "BackgroundCalibration.h" +#include "Multitask.h" #include "avx_luminance.h" +#include "ColorHelpers.h" +#include "Filters.h" +#include "StackingTasks.h" +#include "FITSUtil.h" +#include "TIFFUtil.h" +#include "MasterFrames.h" #if QT_VERSION < 0x060000 #define _USE_MATH_DEFINES #endif -#include - -#include /* ------------------------------------------------------------------- */ @@ -71,6 +71,28 @@ inline void NormalizeAngle(int & lAngle) }; /* ------------------------------------------------------------------- */ +void CRegisteredFrame::Reset() +{ + Workspace workspace; + + m_vStars.clear(); + + m_fRoundnessTolerance = 2.0; + m_bInfoOk = false; + + m_bComet = false; + m_fXComet = m_fYComet = -1; + + m_fMinLuminancy = workspace.value("Register/DetectionThreshold").toDouble() / 100.0; + + m_bApplyMedianFilter = workspace.value("Register/ApplyMedianFilter").toBool(); + m_fBackground = 0.0; + + m_SkyBackground.Reset(); + + m_fOverallQuality = 0; + m_fFWHM = 0; +} bool CRegisteredFrame::FindStarShape(CMemoryBitmap* pBitmap, CStar& star) { @@ -832,6 +854,24 @@ bool CRegisteredFrame::LoadRegisteringInfo(LPCTSTR szInfoFileName) /* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */ +void CLightFrameInfo::Reset() +{ + CFrameInfo::Reset(); + CRegisteredFrame::Reset(); + + m_fXOffset = 0; + m_fYOffset = 0; + m_fAngle = 0; + m_bDisabled = false; + m_pProgress = nullptr; + m_bStartingFrame = false; + m_vVotedPairs.clear(); + + m_bTransformedCometPosition = false; + + m_bRemoveHotPixels = Workspace{}.value("Register/DetectHotPixels", false).toBool(); +} + double CLightFrameInfo::ComputeMedianValue(CGrayBitmap & Bitmap) { double fResult = 0.0; @@ -1218,18 +1258,18 @@ void CLightFrameInfo::RegisterPicture() if (GetPictureInfo(filePath.c_str(), bmpInfo) && bmpInfo.CanLoad()) { - QString strText; - CString strDescription; + QString strText; + QString strDescription; bmpInfo.GetDescription(strDescription); if (bmpInfo.m_lNrChannels == 3) strText = QCoreApplication::translate("RegisterEngine", "Loading %1 bit/ch %2 picture\n%3", "IDS_LOADRGBPICTURE").arg(bmpInfo.m_lBitPerChannel) - .arg(QString::fromWCharArray(strDescription.GetString())) + .arg(strDescription) .arg(QString::fromStdU16String(filePath.generic_u16string())); else strText = QCoreApplication::translate("RegisterEngine", "Loading %1 bits gray %2 picture\n%3", "IDS_LOADGRAYPICTURE").arg(bmpInfo.m_lBitPerChannel) - .arg(QString::fromWCharArray(strDescription.GetString())) + .arg(strDescription) .arg(QString::fromStdU16String(filePath.generic_u16string())); if (m_pProgress != nullptr) @@ -1308,6 +1348,13 @@ void CLightFrameInfo::SetBitmap(fs::path path, bool bProcessIfNecessary, bool bF /* ------------------------------------------------------------------- */ +CRegisterEngine::CRegisterEngine() +{ + m_bSaveCalibrated = CAllStackingTasks::GetSaveCalibrated(); + m_IntermediateFileFormat = CAllStackingTasks::GetIntermediateFileFormat(); + m_bSaveCalibratedDebayered = CAllStackingTasks::GetSaveCalibratedDebayered(); +} + bool CRegisterEngine::SaveCalibratedLightFrame(const CLightFrameInfo& lfi, std::shared_ptr pBitmap, ProgressBase* pProgress, CString& strCalibratedFile) { bool bResult = false; @@ -1379,7 +1426,6 @@ bool CRegisterEngine::SaveCalibratedLightFrame(const CLightFrameInfo& lfi, std:: return bResult; } -#include bool CRegisterEngine::RegisterLightFrames(CAllStackingTasks& tasks, bool bForce, ProgressBase* pProgress) { @@ -1447,13 +1493,13 @@ bool CRegisterEngine::RegisterLightFrames(CAllStackingTasks& tasks, bool bForce, if (!success) continue; - CString strDescription; + QString strDescription; bmpInfo->GetDescription(strDescription); QString strText2; if (bmpInfo->m_lNrChannels == 3) - strText2 = QCoreApplication::translate("RegisterEngine", "Loading %1 bit/ch %2 light frame\n%3", "IDS_LOADRGBLIGHT").arg(bmpInfo->m_lBitPerChannel).arg(QString::fromWCharArray(strDescription)).arg(lfInfo->filePath.c_str()); + strText2 = QCoreApplication::translate("RegisterEngine", "Loading %1 bit/ch %2 light frame\n%3", "IDS_LOADRGBLIGHT").arg(bmpInfo->m_lBitPerChannel).arg(strDescription).arg(lfInfo->filePath.c_str()); else - strText2 = QCoreApplication::translate("RegisterEngine", "Loading %1 bits gray %2 light frame\n%3", "IDS_LOADGRAYLIGHT").arg(bmpInfo->m_lBitPerChannel).arg(QString::fromWCharArray(strDescription)).arg(lfInfo->filePath.c_str()); + strText2 = QCoreApplication::translate("RegisterEngine", "Loading %1 bits gray %2 light frame\n%3", "IDS_LOADGRAYLIGHT").arg(bmpInfo->m_lBitPerChannel).arg(strDescription).arg(lfInfo->filePath.c_str()); if (pProgress != nullptr) pProgress->Start2(strText2, 0); diff --git a/DeepSkyStacker/RegisterEngine.h b/DeepSkyStacker/RegisterEngine.h index 5153836b7..80de166ef 100644 --- a/DeepSkyStacker/RegisterEngine.h +++ b/DeepSkyStacker/RegisterEngine.h @@ -1,18 +1,14 @@ #ifndef __REGISTERENGINE_H__ #define __REGISTERENGINE_H__ - -#include "DSSProgress.h" -#include "DSSTools.h" -#include "BitmapExt.h" +#include "Stars.h" +#include "SkyBackground.h" #include "FrameInfo.h" - -#include "StackingTasks.h" -#include "DSSTools.h" +#include "BilinearParameters.h" #include "MatchingStars.h" -#include "SkyBackground.h" -#include -#include "Stars.h" -#include "Workspace.h" +#include "DSSProgress.h" +#include "GrayBitmap.h" + +namespace DSS { class ProgressBase; } /* ------------------------------------------------------------------- */ @@ -100,29 +96,7 @@ protected : m_SkyBackground = rf.m_SkyBackground; }; - void Reset() - { - Workspace workspace; - - m_vStars.clear(); - - m_fRoundnessTolerance = 2.0; - m_bInfoOk = false; - - m_bComet = false; - m_fXComet = m_fYComet = -1; - - m_fMinLuminancy = workspace.value("Register/DetectionThreshold").toDouble() / 100.0; - - m_bApplyMedianFilter = workspace.value("Register/ApplyMedianFilter").toBool(); - m_fBackground = 0.0; - - m_SkyBackground.Reset(); - - m_fOverallQuality = 0; - m_fFWHM = 0; - }; - + void Reset(); bool FindStarShape(CMemoryBitmap* pBitmap, CStar& star); void ComputeOverallQuality() @@ -210,28 +184,12 @@ class CLightFrameInfo : public CFrameInfo, double m_fAngle; bool m_bDisabled; - ProgressBase* m_pProgress; + DSS::ProgressBase* m_pProgress; bool m_bRemoveHotPixels; private: - void Reset() - { - CFrameInfo::Reset(); - CRegisteredFrame::Reset(); - - m_fXOffset = 0; - m_fYOffset = 0; - m_fAngle = 0; - m_bDisabled= false; - m_pProgress= nullptr; - m_bStartingFrame = false; - m_vVotedPairs.clear(); - - m_bTransformedCometPosition = false; - - m_bRemoveHotPixels = Workspace{}.value("Register/DetectHotPixels", false).toBool(); - } + void Reset(); public: CLightFrameInfo() @@ -247,7 +205,7 @@ class CLightFrameInfo : public CFrameInfo, CFrameInfo::CopyFrom(cbi); } - explicit CLightFrameInfo(ProgressBase* const pPrg) + explicit CLightFrameInfo(DSS::ProgressBase* const pPrg) { Reset(); this->SetProgress(pPrg); @@ -266,7 +224,7 @@ class CLightFrameInfo : public CFrameInfo, m_bRemoveHotPixels = bHotPixels; } - void SetProgress(ProgressBase* pProgress) + void SetProgress(DSS::ProgressBase* pProgress) { m_pProgress = pProgress; } @@ -286,7 +244,7 @@ class CLightFrameInfo : public CFrameInfo, } void RegisterPicture(CMemoryBitmap* pBitmap); - void RegisterPicture(LPCTSTR szBitmap, double fMinLuminancy = 0.10, bool bRemoveHotPixels = true, bool bApplyMedianFilter = false, ProgressBase * pProgress = nullptr); + void RegisterPicture(LPCTSTR szBitmap, double fMinLuminancy = 0.10, bool bRemoveHotPixels = true, bool bApplyMedianFilter = false, DSS::ProgressBase* pProgress = nullptr); void SaveRegisteringInfo(); private: @@ -387,7 +345,7 @@ namespace DSS typedef std::vector LIGHTFRAMEINFOVECTOR; /* ------------------------------------------------------------------- */ - +class CAllStackingTasks; class CRegisterEngine { private : @@ -396,21 +354,13 @@ private : bool m_bSaveCalibratedDebayered; private : - bool SaveCalibratedLightFrame(const CLightFrameInfo& lfi, std::shared_ptr pBitmap, ProgressBase* pProgress, CString& strCalibratedFile); + bool SaveCalibratedLightFrame(const CLightFrameInfo& lfi, std::shared_ptr pBitmap, DSS::ProgressBase* pProgress, CString& strCalibratedFile); public : - CRegisterEngine() - { - m_bSaveCalibrated = CAllStackingTasks::GetSaveCalibrated(); - m_IntermediateFileFormat = CAllStackingTasks::GetIntermediateFileFormat(); - m_bSaveCalibratedDebayered = CAllStackingTasks::GetSaveCalibratedDebayered(); - }; - - virtual ~CRegisterEngine() - { - }; + CRegisterEngine(); + virtual ~CRegisterEngine() = default; - bool RegisterLightFrames(CAllStackingTasks & tasks, bool bForceRegister, ProgressBase * pProgress); + bool RegisterLightFrames(CAllStackingTasks & tasks, bool bForceRegister, DSS::ProgressBase* pProgress); }; /* ------------------------------------------------------------------- */ diff --git a/DeepSkyStacker/RegisterSettings.cpp b/DeepSkyStacker/RegisterSettings.cpp index 2db5b177d..3dbdebe9b 100644 --- a/DeepSkyStacker/RegisterSettings.cpp +++ b/DeepSkyStacker/RegisterSettings.cpp @@ -35,46 +35,18 @@ ****************************************************************************/ // RegisterSettings.cpp : implementation file // - -#include -using std::min; -using std::max; - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "commonresource.h" - +#include "stdafx.h" #include "RegisterSettings.h" #include "ui/ui_RegisterSettings.h" - -extern bool g_bShowRefStars; - +#include "Workspace.h" #include "DeepSkyStacker.h" -#include "DSSCommon.h" -#include "commonresource.h" -#include "QtProgressDlg.h" -#include "RegisterEngine.h" #include "StackingDlg.h" -#include "ProcessingDlg.h" +#include "QtProgressDlg.h" +#include "RecommendedSettings.h" #include "StackSettings.h" +#include "RegisterEngine.h" -#include "Workspace.h" - -#include "RecommendedSettings.h" +extern bool g_bShowRefStars; RegisterSettings::RegisterSettings(QWidget *parent) : QDialog(parent), diff --git a/DeepSkyStacker/RegisterSettings.h b/DeepSkyStacker/RegisterSettings.h index ca45ba72b..c6783d4e2 100644 --- a/DeepSkyStacker/RegisterSettings.h +++ b/DeepSkyStacker/RegisterSettings.h @@ -35,15 +35,10 @@ ** ****************************************************************************/ -#include - class Workspace; class CAllStackingTasks; class QValidator; -#include "DSSCommon.h" -#include - namespace Ui { class RegisterSettings; } diff --git a/DeepSkyStacker/ResultParameters.cpp b/DeepSkyStacker/ResultParameters.cpp index e4dac7313..cf3c1bcc5 100644 --- a/DeepSkyStacker/ResultParameters.cpp +++ b/DeepSkyStacker/ResultParameters.cpp @@ -1,23 +1,10 @@ #include "stdafx.h" -#include -using std::min; -using std::max; - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include - -#include - -#include -#include - #include "ResultParameters.h" #include "ui/ui_ResultParameters.h" - +#include "Workspace.h" +#include "ZExcept.h" #include "DSSCommon.h" #include "StackSettings.h" -#include "Workspace.h" - ResultParameters::ResultParameters(QWidget *parent) : QWidget(parent), diff --git a/DeepSkyStacker/ResultParameters.h b/DeepSkyStacker/ResultParameters.h index cd415189f..9da926123 100644 --- a/DeepSkyStacker/ResultParameters.h +++ b/DeepSkyStacker/ResultParameters.h @@ -1,10 +1,4 @@ -#ifndef RESULTPARAMETERS_H -#define RESULTPARAMETERS_H -#include - -#include -#include - +#pragma once class Workspace; class StackSettings; @@ -45,4 +39,3 @@ private slots: void on_alignRGB_clicked(); }; -#endif // RESULTPARAMETERS_H diff --git a/DeepSkyStacker/RunningStackingEngine.cpp b/DeepSkyStacker/RunningStackingEngine.cpp index 705fc99c6..0c7b83157 100644 --- a/DeepSkyStacker/RunningStackingEngine.cpp +++ b/DeepSkyStacker/RunningStackingEngine.cpp @@ -1,22 +1,14 @@ #include - -#include -#define _USE_MATH_DEFINES -#include - -#include -#include -#include "resource.h" - -#include "dssrect.h" - #include "RunningStackingEngine.h" - -#include "MatchingStars.h" -#include "PixelTransform.h" +#include "Ztrace.h" +#include "GrayBitmap.h" +#include "ColorBitmap.h" #include "BitmapIterator.h" - - +#include "StackingTasks.h" +#include "FrameInfo.h" +#include "PixelTransform.h" +#include "Stars.h" +#include "RegisterEngine.h" diff --git a/DeepSkyStacker/RunningStackingEngine.h b/DeepSkyStacker/RunningStackingEngine.h index a410535f5..7a6d6342c 100644 --- a/DeepSkyStacker/RunningStackingEngine.h +++ b/DeepSkyStacker/RunningStackingEngine.h @@ -1,10 +1,10 @@ #ifndef __RUNNINGSTACKINGENGINE_H__ #define __RUNNINGSTACKINGENGINE_H__ - -#include "RegisterEngine.h" -#include "PixelTransform.h" #include "BackgroundCalibration.h" +#include "MatchingStars.h" +class CMemoryBitmap; +class CLightFrameInfo; class CRunningStackingEngine { private: diff --git a/DeepSkyStacker/SaturationTab.cpp b/DeepSkyStacker/SaturationTab.cpp index 5ddd7c64a..8f1147d20 100644 --- a/DeepSkyStacker/SaturationTab.cpp +++ b/DeepSkyStacker/SaturationTab.cpp @@ -1,8 +1,6 @@ // SaturationTab.cpp : implementation file // - #include "stdafx.h" -#include "DeepSkyStacker.h" #include "SaturationTab.h" #include "ProcessingDlg.h" diff --git a/DeepSkyStacker/SaturationTab.h b/DeepSkyStacker/SaturationTab.h index f0018e626..e421d1d73 100644 --- a/DeepSkyStacker/SaturationTab.h +++ b/DeepSkyStacker/SaturationTab.h @@ -1,16 +1,8 @@ -#if !defined(AFX_SATURATIONTAB_H__947342A1_F290_4BAF_AA71_4D5432E47E65__INCLUDED_) -#define AFX_SATURATIONTAB_H__947342A1_F290_4BAF_AA71_4D5432E47E65__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 -// SaturationTab.h : header file -// - -#include -#include -#include "afxwin.h" -#include +#include "childprop.h" +#include "resourceCZ.h" +#include "BtnST.h" +#include "Label.h" ///////////////////////////////////////////////////////////////////////////// // CSaturationTab dialog @@ -61,8 +53,3 @@ private : //}}AFX_MSG DECLARE_MESSAGE_MAP() }; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SATURATIONTAB_H__947342A1_F290_4BAF_AA71_4D5432E47E65__INCLUDED_) diff --git a/DeepSkyStacker/SaveEditChanges.cpp b/DeepSkyStacker/SaveEditChanges.cpp index 508b68063..1783ab461 100644 --- a/DeepSkyStacker/SaveEditChanges.cpp +++ b/DeepSkyStacker/SaveEditChanges.cpp @@ -39,7 +39,6 @@ #include "stdafx.h" #include "SaveEditChanges.h" -#include namespace DSS { SaveEditChanges::SaveEditChanges(QWidget* parent) : diff --git a/DeepSkyStacker/SaveEditChanges.h b/DeepSkyStacker/SaveEditChanges.h index ec5c85690..d859fdb31 100644 --- a/DeepSkyStacker/SaveEditChanges.h +++ b/DeepSkyStacker/SaveEditChanges.h @@ -36,8 +36,6 @@ ****************************************************************************/ // SaveEditChanges.h: definition file // -#include -#include #include "ui/ui_SaveEditChanges.h" enum class EditSaveMode diff --git a/DeepSkyStacker/SavePicture.cpp b/DeepSkyStacker/SavePicture.cpp index 3f5d0ced1..3c463a895 100644 --- a/DeepSkyStacker/SavePicture.cpp +++ b/DeepSkyStacker/SavePicture.cpp @@ -2,8 +2,8 @@ // #include "stdafx.h" -#include "DeepSkyStacker.h" #include "SavePicture.h" +#include "resourceCZ.h" /* ------------------------------------------------------------------- */ // CSavePicture diff --git a/DeepSkyStacker/SavePicture.h b/DeepSkyStacker/SavePicture.h index ee51eb9b3..9d9fa6133 100644 --- a/DeepSkyStacker/SavePicture.h +++ b/DeepSkyStacker/SavePicture.h @@ -1,8 +1,8 @@ #pragma once +#include "DSSCommon.h" +#include "ToolTipButton.h" // CSavePicture -#include - class CSavePicture : public CFileDialog { private : diff --git a/DeepSkyStacker/SetUILanguage.cpp b/DeepSkyStacker/SetUILanguage.cpp index c21d8aaae..d9fbc567a 100644 --- a/DeepSkyStacker/SetUILanguage.cpp +++ b/DeepSkyStacker/SetUILanguage.cpp @@ -1,10 +1,6 @@ #include #include "SetUILanguage.h" - #include "DSS-VersionHelpers.h" -#include -#include -#include /* ------------------------------------------------------------------- */ diff --git a/DeepSkyStacker/Settings.h b/DeepSkyStacker/Settings.h index 4b1f73c28..9f8f11dd1 100644 --- a/DeepSkyStacker/Settings.h +++ b/DeepSkyStacker/Settings.h @@ -154,14 +154,13 @@ protected : void AddFileVariable(LPCTSTR szVariable, LPCTSTR szFileName) { - CString strValue; CBitmapInfo bmpInfo; // Retrieve the date and time of creation and append it to the file name if (GetPictureInfo(szFileName, bmpInfo)) { - strValue.Format(_T("%s[%s]"), szFileName, (LPCTSTR)bmpInfo.m_strDateTime); - AddVariable(szVariable, (LPCTSTR)strValue); + QString strValue = QString("%1[%2]").arg(szFileName, bmpInfo.m_strDateTime); + AddVariable(szVariable, strValue.toStdWString().c_str()); }; }; diff --git a/DeepSkyStacker/SettingsDlg.h b/DeepSkyStacker/SettingsDlg.h index 6d39127a9..e2087fcb1 100644 --- a/DeepSkyStacker/SettingsDlg.h +++ b/DeepSkyStacker/SettingsDlg.h @@ -1,11 +1,5 @@ -#if !defined(AFX_SETTINGSDLG_H__30B991C3_B90C_4C9A_92A3_02C4179F21FA__INCLUDED_) -#define AFX_SETTINGSDLG_H__30B991C3_B90C_4C9A_92A3_02C4179F21FA__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 -// SettingsDlg.h : header file -// +#include "dss_settings.h" ///////////////////////////////////////////////////////////////////////////// // CSettingsDlg dialog @@ -75,8 +69,3 @@ public : //}}AFX_MSG DECLARE_MESSAGE_MAP() }; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SETTINGSDLG_H__30B991C3_B90C_4C9A_92A3_02C4179F21FA__INCLUDED_) diff --git a/DeepSkyStacker/StackRecap.cpp b/DeepSkyStacker/StackRecap.cpp index a58d2c2a7..010eff6a2 100644 --- a/DeepSkyStacker/StackRecap.cpp +++ b/DeepSkyStacker/StackRecap.cpp @@ -1,37 +1,19 @@ // StackRecap.cpp : implementation file // -#include -using std::min; -using std::max; - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -extern bool g_bShowRefStars; - -#include "commonresource.h" -#include "DeepSkyStacker.h" +#include "stdafx.h" #include "StackRecap.h" -#include "StackSettings.h" +#include "ui/ui_StackRecap.h" +#include "DeepSkyStacker.h" +#include "Ztrace.h" +#include "StackingTasks.h" #include "Multitask.h" -#include "DSSTools.h" -#include "DSSProgress.h" -#include "RecommendedSettings.h" #include "FrameInfoSupport.h" +#include "BitmapExt.h" +#include "ZExcBase.h" +#include "StackSettings.h" +#include "RecommendedSettings.h" + +extern bool g_bShowRefStars; constexpr int SSTAB_RESULT = 0; constexpr int SSTAB_COMET = 1; @@ -44,7 +26,6 @@ constexpr int SSTAB_INTERMEDIATE = 7; constexpr int SSTAB_POSTCALIBRATION = 9; constexpr int SSTAB_OUTPUT = 10; -#include "ui/ui_StackRecap.h" StackRecap::StackRecap(QWidget *parent) : QDialog(parent), @@ -452,7 +433,7 @@ void StackRecap::fillWithAllTasks() strHTML += "

  • "; strText = tr("Method: ", "IDS_RECAP_METHOD"); insertHTML(strHTML, strText); - strText = formatMethod(si.m_pLightTask->m_Method, si.m_pLightTask->m_fKappa, si.m_pLightTask->m_lNrIterations); + FormatMethod(strText, si.m_pLightTask->m_Method, si.m_pLightTask->m_fKappa, si.m_pLightTask->m_lNrIterations); insertHTML(strHTML, strText, QColor(Qt::darkBlue), false, false, SSTAB_LIGHT); strHTML += "
  • "; @@ -496,7 +477,7 @@ void StackRecap::fillWithAllTasks() strHTML += "
  • "; strText = tr("Method: ", "IDS_RECAP_METHOD"); insertHTML(strHTML, strText); - strText = formatMethod(si.m_pOffsetTask->m_Method, si.m_pOffsetTask->m_fKappa, si.m_pOffsetTask->m_lNrIterations); + FormatMethod(strText, si.m_pOffsetTask->m_Method, si.m_pOffsetTask->m_fKappa, si.m_pOffsetTask->m_lNrIterations); insertHTML(strHTML, strText, QColor(Qt::darkBlue), false, false, SSTAB_OFFSET); strHTML += "
  • "; }; @@ -551,7 +532,7 @@ void StackRecap::fillWithAllTasks() strHTML += "
  • "; strText = tr("Method: ", "IDS_RECAP_METHOD"); insertHTML(strHTML, strText); - strText = formatMethod(si.m_pDarkTask->m_Method, si.m_pDarkTask->m_fKappa, si.m_pDarkTask->m_lNrIterations); + FormatMethod(strText, si.m_pDarkTask->m_Method, si.m_pDarkTask->m_fKappa, si.m_pDarkTask->m_lNrIterations); insertHTML(strHTML, strText, QColor(Qt::darkBlue), false, false, SSTAB_DARK); strHTML += "
  • "; }; @@ -628,7 +609,7 @@ void StackRecap::fillWithAllTasks() strText = tr("Method: ", "IDS_RECAP_METHOD"); insertHTML(strHTML, strText); strHTML += ""; - strText = formatMethod(si.m_pDarkFlatTask->m_Method, si.m_pDarkFlatTask->m_fKappa, si.m_pDarkFlatTask->m_lNrIterations); + FormatMethod(strText, si.m_pDarkFlatTask->m_Method, si.m_pDarkFlatTask->m_fKappa, si.m_pDarkFlatTask->m_lNrIterations); insertHTML(strHTML, strText, QColor(Qt::darkBlue), false, false, SSTAB_DARK); strHTML += ""; }; @@ -682,7 +663,7 @@ void StackRecap::fillWithAllTasks() strHTML += "
  • "; strText = tr("Method: ", "IDS_RECAP_METHOD"); insertHTML(strHTML, strText); - strText = formatMethod(si.m_pFlatTask->m_Method, si.m_pFlatTask->m_fKappa, si.m_pFlatTask->m_lNrIterations); + FormatMethod(strText, si.m_pFlatTask->m_Method, si.m_pFlatTask->m_fKappa, si.m_pFlatTask->m_lNrIterations); insertHTML(strHTML, strText, QColor(Qt::darkBlue), false, false, SSTAB_FLAT); strHTML += "
  • "; }; diff --git a/DeepSkyStacker/StackRecap.h b/DeepSkyStacker/StackRecap.h index 85eb948ae..81d9d2b68 100644 --- a/DeepSkyStacker/StackRecap.h +++ b/DeepSkyStacker/StackRecap.h @@ -5,11 +5,7 @@ class Workspace; class QAbstractButton; class QUrl; - -#include "DSSCommon.h" -#include "StackingTasks.h" -#include - +class CAllStackingTasks; namespace Ui { class StackRecap; } diff --git a/DeepSkyStacker/StackSettings.cpp b/DeepSkyStacker/StackSettings.cpp index 5593b7a2d..8af97a2d9 100644 --- a/DeepSkyStacker/StackSettings.cpp +++ b/DeepSkyStacker/StackSettings.cpp @@ -1,31 +1,17 @@ -#include -using std::min; -using std::max; - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -extern bool g_bShowRefStars; - -#include "DSSCommon.h" -#include "commonresource.h" -#include "DSSVersion.h" -#include "DeepSkyStacker.h" -#include "Workspace.h" - +#include "stdafx.h" #include "StackSettings.h" #include "ui/ui_StackSettings.h" +#include "Workspace.h" +#include "DeepSkyStacker.h" +#include "Multitask.h" #include "avx_support.h" +#include "ResultParameters.h" +#include "CometStacking.h" +#include "AlignmentParameters.h" +#include "IntermediateFiles.h" +#include "PostCalibration.h" +#include "OutputTab.h" +#include "StackingParameters.h" StackSettings::StackSettings(QWidget *parent) : diff --git a/DeepSkyStacker/StackSettings.h b/DeepSkyStacker/StackSettings.h index 4aa734b42..3ac90a354 100644 --- a/DeepSkyStacker/StackSettings.h +++ b/DeepSkyStacker/StackSettings.h @@ -2,20 +2,19 @@ #define STACKSETTINGS_H -#include -#include "ResultParameters.h" -#include "CometStacking.h" -#include "PostCalibration.h" -#include "OutputTab.h" -#include "IntermediateFiles.h" -#include "AlignmentParameters.h" -#include "StackingParameters.h" -#include "StackingTasks.h" - namespace Ui { class StackSettings; } +class ResultParameters; +class CometStacking; +class AlignmentParameters; +class IntermediateFiles; +class PostCalibration; +class OutputTab; +class StackingParameters; +class CAllStackingTasks; + class StackSettings : public QDialog { friend class StackingParameters; diff --git a/DeepSkyStacker/StackedBitmap.cpp b/DeepSkyStacker/StackedBitmap.cpp index 7bf9b2ea9..2f577d109 100644 --- a/DeepSkyStacker/StackedBitmap.cpp +++ b/DeepSkyStacker/StackedBitmap.cpp @@ -1,21 +1,17 @@ -#include - -#include -#include -#include -#include -#include - -#include "resource.h" -#include "DeepStack.h" - +#include "stdafx.h" +#include "StackedBitmap.h" #include "TIFFUtil.h" +#include "ColorHelpers.h" +#include "Ztrace.h" +#include "DSSProgress.h" +#include "GrayBitmap.h" +#include "ColorBitmap.h" +#include "omp.h" +#include "BitmapInfo.h" +#include "tiffio.h" #include "FITSUtil.h" -#define _USE_MATH_DEFINES -#include - - +using namespace DSS; /* ------------------------------------------------------------------- */ CStackedBitmap::CStackedBitmap() @@ -466,7 +462,7 @@ void CStackedBitmap::SaveDSImage(LPCTSTR szStackedFile, LPRECT pRect, ProgressBa /* ------------------------------------------------------------------- */ -#if !defined(PCL_PROJECT) && !defined(_CONSOLE) +#if !defined(_CONSOLE) class CPixel { public : @@ -604,7 +600,7 @@ HBITMAP CStackedBitmap::GetBitmap(C32BitsBitmap & Bitmap, RECT * pRect) return Bitmap.GetHBITMAP(); }; -#endif // !defined(PCL_PROJECT) && !defined(_CONSOLE) +#endif // !defined(_CONSOLE) /* ------------------------------------------------------------------- */ @@ -692,7 +688,7 @@ bool CStackedBitmap::Load(LPCTSTR szStackedFile, ProgressBase * pProgress) if (GetPictureInfo(szStackedFile, bmpInfo) && bmpInfo.CanLoad()) { - CString strFileType = bmpInfo.m_strFileType.Left(4); + QString strFileType = bmpInfo.m_strFileType.left(4); if (strFileType == "TIFF") return LoadTIFF(szStackedFile, pProgress); @@ -709,7 +705,7 @@ bool CStackedBitmap::Load(LPCTSTR szStackedFile, ProgressBase * pProgress) void CStackedBitmap::ReadSpecificTags(CTIFFReader * tiffReader) { - uint32 nrbitmaps = 1, + uint32_t nrbitmaps = 1, settingsapplied = 0; if (tiffReader) diff --git a/DeepSkyStacker/StackedBitmap.h b/DeepSkyStacker/StackedBitmap.h index bf6390e6b..b46a66140 100644 --- a/DeepSkyStacker/StackedBitmap.h +++ b/DeepSkyStacker/StackedBitmap.h @@ -1,13 +1,14 @@ #ifndef _STACKEDBITMAP_H__ #define _STACKEDBITMAP_H__ - -#include -#include -#include -#include "BitmapExt.h" #include "BezierAdjust.h" #include "Histogram.h" -#include "DSSTools.h" +#include "ColorRef.h" + +#ifndef _CONSOLE +#include "BitmapExt.h" +#endif//_CONSOLE + +namespace DSS { class ProgressBase; } /* ------------------------------------------------------------------- */ @@ -158,9 +159,9 @@ private : CRGBHistogramAdjust m_HistoAdjust; private : - bool LoadDSImage(LPCTSTR szStackedFile, ProgressBase * pProgress = nullptr); - bool LoadTIFF(LPCTSTR szStackedFile, ProgressBase * pProgress = nullptr); - bool LoadFITS(LPCTSTR szStackedFile, ProgressBase * pProgress = nullptr); + bool LoadDSImage(LPCTSTR szStackedFile, DSS::ProgressBase * pProgress = nullptr); + bool LoadTIFF(LPCTSTR szStackedFile, DSS::ProgressBase* pProgress = nullptr); + bool LoadFITS(LPCTSTR szStackedFile, DSS::ProgressBase* pProgress = nullptr); COLORREF GetPixel(float fRed, float fGreen, float fBlue, bool bApplySettings); @@ -300,16 +301,16 @@ public : return m_lNrBitmaps; }; - bool Load(LPCTSTR szStackedFile, ProgressBase * pProgress = nullptr); - void SaveDSImage(LPCTSTR szStackedFile, LPRECT pRect = nullptr, ProgressBase * pProgress = nullptr); - void SaveTIFF16Bitmap(LPCTSTR szBitmapFile, LPRECT pRect = nullptr, ProgressBase * pProgress = nullptr, bool bApplySettings = true, TIFFCOMPRESSION TiffComp = TC_NONE); - void SaveTIFF32Bitmap(LPCTSTR szBitmapFile, LPRECT pRect = nullptr, ProgressBase * pProgress = nullptr, bool bApplySettings = true, bool bFloat = false, TIFFCOMPRESSION TiffComp = TC_NONE); - void SaveFITS16Bitmap(LPCTSTR szBitmapFile, LPRECT pRect = nullptr, ProgressBase * pProgress = nullptr, bool bApplySettings = true); - void SaveFITS32Bitmap(LPCTSTR szBitmapFile, LPRECT pRect = nullptr, ProgressBase * pProgress = nullptr, bool bApplySettings = true, bool bFloat = false); -#if !defined(PCL_PROJECT) && !defined(_CONSOLE) + bool Load(LPCTSTR szStackedFile, DSS::ProgressBase* pProgress = nullptr); + void SaveDSImage(LPCTSTR szStackedFile, LPRECT pRect = nullptr, DSS::ProgressBase* pProgress = nullptr); + void SaveTIFF16Bitmap(LPCTSTR szBitmapFile, LPRECT pRect = nullptr, DSS::ProgressBase* pProgress = nullptr, bool bApplySettings = true, TIFFCOMPRESSION TiffComp = TC_NONE); + void SaveTIFF32Bitmap(LPCTSTR szBitmapFile, LPRECT pRect = nullptr, DSS::ProgressBase* pProgress = nullptr, bool bApplySettings = true, bool bFloat = false, TIFFCOMPRESSION TiffComp = TC_NONE); + void SaveFITS16Bitmap(LPCTSTR szBitmapFile, LPRECT pRect = nullptr, DSS::ProgressBase* pProgress = nullptr, bool bApplySettings = true); + void SaveFITS32Bitmap(LPCTSTR szBitmapFile, LPRECT pRect = nullptr, DSS::ProgressBase* pProgress = nullptr, bool bApplySettings = true, bool bFloat = false); +#if !defined(_CONSOLE) HBITMAP GetBitmap(C32BitsBitmap & Bitmap, RECT * pRect = nullptr); #endif - std::shared_ptr GetBitmap(ProgressBase* const pProgress = nullptr); + std::shared_ptr GetBitmap(DSS::ProgressBase* const pProgress = nullptr); void Clear() { diff --git a/DeepSkyStacker/StackingDlg.cpp b/DeepSkyStacker/StackingDlg.cpp index e155f9531..a9e94037f 100644 --- a/DeepSkyStacker/StackingDlg.cpp +++ b/DeepSkyStacker/StackingDlg.cpp @@ -37,67 +37,31 @@ // #include "stdafx.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "mrupath.h" - -#include "DeepSkyStacker.h" -#include "dssrect.h" #include "StackingDlg.h" -#include "ProcessingDlg.h" -#include "DeepStack.h" -#include "FileProperty.h" -#include "FrameInfoSupport.h" -#include "QtProgressDlg.h" -#include "CheckAbove.h" -#include "RegisterSettings.h" -#include "StackRecap.h" -#include "TIFFUtil.h" -#include "RegisterEngine.h" -#include "StackingEngine.h" +#include "ui_StackingDlg.h" +#include "picturelist.h" +#include "Ztrace.h" #include "DropFilesDlg.h" -#include "SaveEditChanges.h" -#include "AskRegistering.h" -#include "BatchStacking.h" -#include "DSSVersion.h" -#include "group.h" +#include "RenameGroup.h" +#include "toolbar.h" #include "editstars.h" #include "selectrect.h" -#include "toolbar.h" +#include "SaveEditChanges.h" +#include "RegisterEngine.h" +#include "StackingEngine.h" +#include "DeepSkyStacker.h" +#include "CheckAbove.h" +#include "Workspace.h" +#include "QtProgressDlg.h" +#include "RegisterSettings.h" #include "avx_support.h" -#include "ui/ui_StackingDlg.h" -#include "picturelist.h" -#include "RenameGroup.h" - -#include - -#define _USE_MATH_DEFINES -#include +#include "FrameInfoSupport.h" +#include "AskRegistering.h" +#include "FITSUtil.h" +#include "TIFFUtil.h" +#include "BatchStacking.h" +#include "StackRecap.h" +#include "ProcessingDlg.h" #define dssApp DeepSkyStacker::instance() diff --git a/DeepSkyStacker/StackingDlg.h b/DeepSkyStacker/StackingDlg.h index c0bf3e78c..f82e7edd7 100644 --- a/DeepSkyStacker/StackingDlg.h +++ b/DeepSkyStacker/StackingDlg.h @@ -36,27 +36,17 @@ ****************************************************************************/ // StackingDlg.h : header file // - +#include "DSSCommon.h" +#include "BitmapExt.h" +#include "FrameList.h" +#include "dssrect.h" #include "mrupath.h" -#include -#include -#include -#include "Label.h" -#include "StackingTasks.h" -#include "DeepStack.h" -#include -#include -#include "StackingEngine.h" #include "imageloader.h" -#include "FrameList.h" class QNetworkAccessManager; class QNetworkReply; - -#include -#include -#include -#include +class CAllStackingTasks; +class CStackingEngine; namespace DSS { @@ -79,6 +69,7 @@ namespace std::filesystem class QTextOption; class QSortFilterProxyModel; class QLabel; +class Workspace; namespace fs = std::filesystem; diff --git a/DeepSkyStacker/StackingEngine.cpp b/DeepSkyStacker/StackingEngine.cpp index f93c75fa0..bab06aa7b 100644 --- a/DeepSkyStacker/StackingEngine.cpp +++ b/DeepSkyStacker/StackingEngine.cpp @@ -1,11 +1,11 @@ #include +#include #include "StackingEngine.h" #include "MasterFrames.h" #include "MatchingStars.h" #include "PixelTransform.h" #include "EntropyInfo.h" -#include #include "TIFFUtil.h" #include "FITSUtil.h" #include "Multitask.h" @@ -13,16 +13,20 @@ #include "Filters.h" #include "CosmeticEngine.h" #include "ChannelAlign.h" -#include #include "FrameInfoSupport.h" #include "avx.h" #include "avx_avg.h" -#include -#include +#include "Ztrace.h" +#include "Workspace.h" +#include "File.h" +#include "MultiBitmap.h" +#include "ColorBitmap.h" +#include "ColorMultiBitmap.h" +#include "GreyMultiBitmap.h" +#include "AHDDemosaicing.h" #define _USE_MATH_DEFINES -#include #ifndef M_PI #define M_PI 3.14159265358979323846 @@ -2661,7 +2665,8 @@ void CStackingEngine::WriteDescription(CAllStackingTasks& tasks, LPCTSTR szOutpu hFile = _tfopen(strOutputFile, _T("wt")); if (hFile) { - CString strText; + CString strText; + QString strTempText; _tsplitpath(strOutputFile, nullptr, nullptr, szName, nullptr); @@ -2829,7 +2834,8 @@ void CStackingEngine::WriteDescription(CAllStackingTasks& tasks, LPCTSTR szOutpu fprintf(hFile, "
      "); strText.Format(IDS_RECAP_METHOD); fprintf(hFile, CT2CA(strText, CP_UTF8)); - FormatFromMethod(strText, si.m_pLightTask->m_Method, si.m_pLightTask->m_fKappa, si.m_pLightTask->m_lNrIterations); + FormatFromMethod(strTempText, si.m_pLightTask->m_Method, si.m_pLightTask->m_fKappa, si.m_pLightTask->m_lNrIterations); + strText = strTempText.toStdWString().c_str(); fprintf(hFile, CT2CA(strText, CP_UTF8)); fprintf(hFile, "
    "); @@ -2859,7 +2865,8 @@ void CStackingEngine::WriteDescription(CAllStackingTasks& tasks, LPCTSTR szOutpu fprintf(hFile, "
      "); strText.Format(IDS_RECAP_METHOD); fprintf(hFile, CT2CA(strText, CP_UTF8)); - FormatFromMethod(strText, si.m_pOffsetTask->m_Method, si.m_pOffsetTask->m_fKappa, si.m_pOffsetTask->m_lNrIterations); + FormatFromMethod(strTempText, si.m_pOffsetTask->m_Method, si.m_pOffsetTask->m_fKappa, si.m_pOffsetTask->m_lNrIterations); + strText = strTempText.toStdWString().c_str(); fprintf(hFile, CT2CA(strText, CP_UTF8)); fprintf(hFile, "
    "); } @@ -2902,7 +2909,8 @@ void CStackingEngine::WriteDescription(CAllStackingTasks& tasks, LPCTSTR szOutpu fprintf(hFile, "
      "); strText.Format(IDS_RECAP_METHOD); fprintf(hFile, CT2CA(strText, CP_UTF8)); - FormatFromMethod(strText, si.m_pDarkTask->m_Method, si.m_pDarkTask->m_fKappa, si.m_pDarkTask->m_lNrIterations); + FormatFromMethod(strTempText, si.m_pDarkTask->m_Method, si.m_pDarkTask->m_fKappa, si.m_pDarkTask->m_lNrIterations); + strText = strTempText.toStdWString().c_str(); fprintf(hFile, CT2CA(strText, CP_UTF8)); fprintf(hFile, "
    "); }; @@ -2960,7 +2968,8 @@ void CStackingEngine::WriteDescription(CAllStackingTasks& tasks, LPCTSTR szOutpu fprintf(hFile, "
      "); strText.Format(IDS_RECAP_METHOD); fprintf(hFile, (LPCSTR)CT2CA(strText+"
      ", CP_UTF8)); - FormatFromMethod(strText, si.m_pDarkFlatTask->m_Method, si.m_pDarkFlatTask->m_fKappa, si.m_pDarkFlatTask->m_lNrIterations); + FormatFromMethod(strTempText, si.m_pDarkFlatTask->m_Method, si.m_pDarkFlatTask->m_fKappa, si.m_pDarkFlatTask->m_lNrIterations); + strText = strTempText.toStdWString().c_str(); fprintf(hFile, CT2CA(strText, CP_UTF8)); fprintf(hFile, "
    "); } @@ -3002,7 +3011,8 @@ void CStackingEngine::WriteDescription(CAllStackingTasks& tasks, LPCTSTR szOutpu fprintf(hFile, "
      "); strText.Format(IDS_RECAP_METHOD); fprintf(hFile, CT2CA(strText, CP_UTF8)); - FormatFromMethod(strText, si.m_pFlatTask->m_Method, si.m_pFlatTask->m_fKappa, si.m_pFlatTask->m_lNrIterations); + FormatFromMethod(strTempText, si.m_pFlatTask->m_Method, si.m_pFlatTask->m_fKappa, si.m_pFlatTask->m_lNrIterations); + strText = strTempText.toStdWString().c_str(); fprintf(hFile, CT2CA(strText, CP_UTF8)); fprintf(hFile, "
    "); }; diff --git a/DeepSkyStacker/StackingEngine.h b/DeepSkyStacker/StackingEngine.h index 4a8cd36f4..60cb94ff0 100644 --- a/DeepSkyStacker/StackingEngine.h +++ b/DeepSkyStacker/StackingEngine.h @@ -4,6 +4,7 @@ #include "RegisterEngine.h" #include "PixelTransform.h" #include "BackgroundCalibration.h" +#include "StackingTasks.h" class CComputeOffsetTask; @@ -131,7 +132,7 @@ public : }; /* ------------------------------------------------------------------- */ - +class CTaskInfo; class CStackingEngine final { private: diff --git a/DeepSkyStacker/StackingParameters.cpp b/DeepSkyStacker/StackingParameters.cpp index 6676ebbc5..185965279 100644 --- a/DeepSkyStacker/StackingParameters.cpp +++ b/DeepSkyStacker/StackingParameters.cpp @@ -1,29 +1,12 @@ #include "stdafx.h" -#include -using std::min; -using std::max; - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include - #include "StackingParameters.h" #include "ui/ui_StackingParameters.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "BackgroundOptions.h" -#include "DSSCommon.h" +#include "Workspace.h" #include "StackSettings.h" +#include "ZExcept.h" #include "StackingTasks.h" -#include "Workspace.h" +#include "BackgroundOptions.h" + StackingParameters::StackingParameters(QWidget *parent, PICTURETYPE theType) : QWidget(parent), diff --git a/DeepSkyStacker/StackingParameters.h b/DeepSkyStacker/StackingParameters.h index bc8109d79..498c5905c 100644 --- a/DeepSkyStacker/StackingParameters.h +++ b/DeepSkyStacker/StackingParameters.h @@ -1,7 +1,4 @@ -#ifndef STACKINGPARAMETERS_H -#define STACKINGPARAMETERS_H - -#include +#pragma once class Workspace; class StackSettings; @@ -88,5 +85,3 @@ private slots: void updateControls(MULTIBITMAPPROCESSMETHOD newMethod); }; - -#endif // STACKINGPARAMETERS_H diff --git a/DeepSkyStacker/StackingTasks.cpp b/DeepSkyStacker/StackingTasks.cpp index d2e9b0bd0..fe9d94e42 100644 --- a/DeepSkyStacker/StackingTasks.cpp +++ b/DeepSkyStacker/StackingTasks.cpp @@ -1,14 +1,20 @@ #include -#include #include -#include -#include "resource.h" #include "StackingTasks.h" - +#include "DSSProgress.h" +#include "Ztrace.h" +#include "BitmapInfo.h" +#include "BitmapExt.h" +#include "RAWUtils.h" +#include "TaskInfo.h" #include "TIFFUtil.h" - #include "Settings.h" +#include "ZExcBase.h" +#include "MemoryBitmap.h" +#include "resource.h" + +using namespace DSS; /* ------------------------------------------------------------------- */ @@ -32,6 +38,41 @@ bool AreExposureEquals(double fExposure1, double fExposure2) return bResult; }; +void SpaceToString(__int64 ulSpace, CString& strSpace) +{ + double fKb, + fMb, + fGb; + + fKb = ulSpace / 1024.0; + fMb = fKb / 1024.0; + fGb = fMb / 1024.0; + + if (fKb < 900) + strSpace.Format(IDS_RECAP_KILOBYTES, fKb); + else if (fMb < 900) + strSpace.Format(IDS_RECAP_MEGABYTES, fMb); + else + strSpace.Format(IDS_RECAP_GIGABYTES, fGb); +}; + +void SpaceToQString(__int64 ulSpace, QString& strSpace) +{ + double fKb(ulSpace / 1024.0); + double fMb(fKb / 1024.0); + double fGb(fMb / 1024.0); + + if (fKb < 900) + strSpace = QCoreApplication::translate("StackRecap", "%L1 kB", "IDS_RECAP_KILOBYTES") + .arg(fKb, 0, 'f', 1); + else if (fMb < 900) + strSpace = QCoreApplication::translate("StackRecap", "%L1 MB", "IDS_RECAP_MEGABYTES") + .arg(fMb, 0, 'f', 1); + else + strSpace = QCoreApplication::translate("StackRecap", "%L1 GB", "IDS_RECAP_GIGABYTES") + .arg(fGb, 0, 'f', 1); +} + /* ------------------------------------------------------------------- */ bool LoadFrame(const fs::path filePath, PICTURETYPE PictureType, ProgressBase* pProgress, std::shared_ptr& rpBitmap) @@ -47,43 +88,42 @@ bool LoadFrame(const fs::path filePath, PICTURETYPE PictureType, ProgressBase* p if (GetPictureInfo(szFile, bmpInfo) && bmpInfo.CanLoad()) { QString strText; - CString strDescription; + QString strDescription; bool bOverrideRAW = true; bmpInfo.GetDescription(strDescription); - const auto pDescription = static_cast(strDescription); switch (PictureType) { case PICTURETYPE_DARKFRAME: if (bmpInfo.m_lNrChannels==3) - strText = QCoreApplication::translate("StackingTasks", "Loading %1 bit/ch %2 dark frame\n%3", "IDS_LOADRGBDARK").arg(bmpInfo.m_lBitPerChannel).arg(pDescription).arg(szFile); + strText = QCoreApplication::translate("StackingTasks", "Loading %1 bit/ch %2 dark frame\n%3", "IDS_LOADRGBDARK").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(szFile); else - strText = QCoreApplication::translate("StackingTasks", "Loading %1 bits gray %2 dark frame\n%3", "IDS_LOADGRAYDARK").arg(bmpInfo.m_lBitPerChannel).arg(pDescription).arg(szFile); + strText = QCoreApplication::translate("StackingTasks", "Loading %1 bits gray %2 dark frame\n%3", "IDS_LOADGRAYDARK").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(szFile); break; case PICTURETYPE_DARKFLATFRAME: if (bmpInfo.m_lNrChannels == 3) - strText = QCoreApplication::translate("StackingTasks", "Loading %1 bit/ch %2 dark flat frame\n%3", "IDS_LOADRGBDARKFLAT").arg(bmpInfo.m_lBitPerChannel).arg(pDescription).arg(szFile); + strText = QCoreApplication::translate("StackingTasks", "Loading %1 bit/ch %2 dark flat frame\n%3", "IDS_LOADRGBDARKFLAT").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(szFile); else - strText = QCoreApplication::translate("StackingTasks", "Loading %1 bits gray %2 dark flat frame\n%3", "IDS_LOADGRAYDARKFLAT").arg(bmpInfo.m_lBitPerChannel).arg(pDescription).arg(szFile); + strText = QCoreApplication::translate("StackingTasks", "Loading %1 bits gray %2 dark flat frame\n%3", "IDS_LOADGRAYDARKFLAT").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(szFile); break; case PICTURETYPE_OFFSETFRAME: if (bmpInfo.m_lNrChannels == 3) - strText = QCoreApplication::translate("StackingTasks", "Loading %1 bit/ch %2 offset frame\n%3", "IDS_LOADRGBOFFSET").arg(bmpInfo.m_lBitPerChannel).arg(pDescription).arg(szFile); + strText = QCoreApplication::translate("StackingTasks", "Loading %1 bit/ch %2 offset frame\n%3", "IDS_LOADRGBOFFSET").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(szFile); else - strText = QCoreApplication::translate("StackingTasks", "Loading %1 bits gray %2 offset frame\n%3", "IDS_LOADGRAYOFFSET").arg(bmpInfo.m_lBitPerChannel).arg(pDescription).arg(szFile); + strText = QCoreApplication::translate("StackingTasks", "Loading %1 bits gray %2 offset frame\n%3", "IDS_LOADGRAYOFFSET").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(szFile); break; case PICTURETYPE_FLATFRAME: if (bmpInfo.m_lNrChannels == 3) - strText = QCoreApplication::translate("StackingTasks", "Loading %1 bit/ch %2 flat frame\n%3", "IDS_LOADRGBFLAT").arg(bmpInfo.m_lBitPerChannel).arg(pDescription).arg(szFile); + strText = QCoreApplication::translate("StackingTasks", "Loading %1 bit/ch %2 flat frame\n%3", "IDS_LOADRGBFLAT").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(szFile); else - strText = QCoreApplication::translate("StackingTasks", "Loading %1 bits gray %2 flat frame\n%3", "IDS_LOADGRAYFLAT").arg(bmpInfo.m_lBitPerChannel).arg(pDescription).arg(szFile); + strText = QCoreApplication::translate("StackingTasks", "Loading %1 bits gray %2 flat frame\n%3", "IDS_LOADGRAYFLAT").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(szFile); break; case PICTURETYPE_LIGHTFRAME: if (bmpInfo.m_lNrChannels == 3) - strText = QCoreApplication::translate("StackingTasks", "Loading %1 bit/ch %2 light frame\n%3", "IDS_LOADRGBLIGHT").arg(bmpInfo.m_lBitPerChannel).arg(pDescription).arg(szFile); + strText = QCoreApplication::translate("StackingTasks", "Loading %1 bit/ch %2 light frame\n%3", "IDS_LOADRGBLIGHT").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(szFile); else - strText = QCoreApplication::translate("StackingTasks", "Loading %1 bits gray %2 light frame\n%3", "IDS_LOADGRAYLIGHT").arg(bmpInfo.m_lBitPerChannel).arg(pDescription).arg(szFile); + strText = QCoreApplication::translate("StackingTasks", "Loading %1 bits gray %2 light frame\n%3", "IDS_LOADGRAYLIGHT").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(szFile); bOverrideRAW = false; break; }; diff --git a/DeepSkyStacker/StackingTasks.h b/DeepSkyStacker/StackingTasks.h index bbeee57a5..d1276e2e3 100644 --- a/DeepSkyStacker/StackingTasks.h +++ b/DeepSkyStacker/StackingTasks.h @@ -1,16 +1,18 @@ #ifndef _STACKINGTASKS_H__ #define _STACKINGTASKS_H__ -#include +#include "DSSCommon.h" +#include "DSSProgress.h" #include "dssrect.h" -#include "BitmapExt.h" -#include "FrameInfo.h" #include "TaskInfo.h" +namespace DSS { class ProgressBase; } +class CMemoryBitmap; +class CFrameInfo; /* ------------------------------------------------------------------- */ -bool LoadFrame(const fs::path filePath, PICTURETYPE PistureType, ProgressBase * pProgress, std::shared_ptr& rpBitmap); +bool LoadFrame(const fs::path filePath, PICTURETYPE PictureType, DSS::ProgressBase * pProgress, std::shared_ptr& rpBitmap); bool AreExposureEquals(double fExposure1, double fExposure2); /* ------------------------------------------------------------------- */ @@ -129,8 +131,8 @@ public : /* ------------------------------------------------------------------- */ - -bool GetTaskResult(const CTaskInfo* pTaskInfo, ProgressBase* pProgress, std::shared_ptr& rpBitmap); +class CTaskInfo; +bool GetTaskResult(const CTaskInfo* pTaskInfo, DSS::ProgressBase* pProgress, std::shared_ptr& rpBitmap); void ClearTaskCache(); /* ------------------------------------------------------------------- */ @@ -187,10 +189,10 @@ public : return (*this); }; - bool DoOffsetTask(ProgressBase* const pProgress); - bool DoDarkTask(ProgressBase* const pProgress); - bool DoFlatTask(ProgressBase* const pProgress); - bool DoDarkFlatTask(ProgressBase* const pProgress); + bool DoOffsetTask(DSS::ProgressBase* const pProgress); + bool DoDarkTask(DSS::ProgressBase* const pProgress); + bool DoFlatTask(DSS::ProgressBase* const pProgress); + bool DoDarkFlatTask(DSS::ProgressBase* const pProgress); }; /* ------------------------------------------------------------------- */ @@ -383,11 +385,11 @@ public : return GetResultMode(); } - bool DoOffsetTasks(ProgressBase* pProgress); - bool DoDarkTasks(ProgressBase* pProgress); - bool DoFlatTasks(ProgressBase* pProgress); - bool DoDarkFlatTasks(ProgressBase* pProgress); - bool DoAllPreTasks(ProgressBase* pProgress); + bool DoOffsetTasks(DSS::ProgressBase* pProgress); + bool DoDarkTasks(DSS::ProgressBase* pProgress); + bool DoFlatTasks(DSS::ProgressBase* pProgress); + bool DoDarkFlatTasks(DSS::ProgressBase* pProgress); + bool DoAllPreTasks(DSS::ProgressBase* pProgress); std::int64_t computeNecessaryDiskSpace(const DSSRect& rcOutput); std::int64_t computeNecessaryDiskSpace(); @@ -444,40 +446,8 @@ public : /* ------------------------------------------------------------------- */ -inline void SpaceToString(__int64 ulSpace, CString & strSpace) -{ - double fKb, - fMb, - fGb; - - fKb = ulSpace / 1024.0; - fMb = fKb / 1024.0; - fGb = fMb / 1024.0; - - if (fKb < 900) - strSpace.Format(IDS_RECAP_KILOBYTES, fKb); - else if (fMb < 900) - strSpace.Format(IDS_RECAP_MEGABYTES, fMb); - else - strSpace.Format(IDS_RECAP_GIGABYTES, fGb); -}; - -inline void SpaceToQString(__int64 ulSpace, QString & strSpace) -{ - double fKb(ulSpace / 1024.0); - double fMb(fKb / 1024.0); - double fGb(fMb / 1024.0); - - if (fKb < 900) - strSpace = QCoreApplication::translate("StackRecap", "%L1 kB", "IDS_RECAP_KILOBYTES") - .arg(fKb, 0, 'f', 1); - else if (fMb < 900) - strSpace = QCoreApplication::translate("StackRecap", "%L1 MB", "IDS_RECAP_MEGABYTES") - .arg(fMb, 0, 'f', 1); - else - strSpace = QCoreApplication::translate("StackRecap", "%L1 GB", "IDS_RECAP_GIGABYTES") - .arg(fGb, 0, 'f', 1); -}; +void SpaceToString(__int64 ulSpace, CString& strSpace); +void SpaceToQString(__int64 ulSpace, QString& strSpace); /* ------------------------------------------------------------------- */ diff --git a/DeepSkyStacker/StarMask.cpp b/DeepSkyStacker/StarMask.cpp index 8e4b5e84c..ed0685438 100644 --- a/DeepSkyStacker/StarMask.cpp +++ b/DeepSkyStacker/StarMask.cpp @@ -1,14 +1,10 @@ -#include +#include "stdafx.h" #include "StarMask.h" +#include "DSSProgress.h" #include "RegisterEngine.h" +#include "GrayBitmap.h" -#if QT_VERSION < 0x060000 -#define _USE_MATH_DEFINES -#endif -#include - -#include -using namespace Gdiplus; +using namespace DSS; // Can't be const due to RegisterPicture(pBitmap). std::shared_ptr CStarMaskEngine::CreateStarMask2(CMemoryBitmap* pBitmap, ProgressBase* pProgress) diff --git a/DeepSkyStacker/StarMask.h b/DeepSkyStacker/StarMask.h index da09d0d03..fd554148e 100644 --- a/DeepSkyStacker/StarMask.h +++ b/DeepSkyStacker/StarMask.h @@ -1,8 +1,8 @@ #ifndef __STARMASK_H__ #define __STARMASK_H__ -#include -#include "RegisterEngine.h" +class CMemoryBitmap; +namespace DSS { class ProgressBase; } /* ------------------------------------------------------------------- */ @@ -239,7 +239,7 @@ private : } // bool CreateStarMask(CMemoryBitmap* pBitmap, CMemoryBitmap ** ppBitmap, ProgressBase * pProgress = nullptr); - std::shared_ptr CreateStarMask2(CMemoryBitmap* pBitmap, ProgressBase* pProgress = nullptr); + std::shared_ptr CreateStarMask2(CMemoryBitmap* pBitmap, DSS::ProgressBase* pProgress = nullptr); }; #endif // __STARMASK_H__ diff --git a/DeepSkyStacker/StarMaskDlg.cpp b/DeepSkyStacker/StarMaskDlg.cpp index d6683ff53..21ed164eb 100644 --- a/DeepSkyStacker/StarMaskDlg.cpp +++ b/DeepSkyStacker/StarMaskDlg.cpp @@ -1,12 +1,10 @@ // StarMaskDlg.cpp : implementation file // - #include "stdafx.h" -#include "DeepSkyStacker.h" #include "StarMaskDlg.h" +#include "DSSCommon.h" -#include - +extern CString STARMASKFILE_FILTERS; // CStarMaskDlg dialog /* ------------------------------------------------------------------- */ diff --git a/DeepSkyStacker/StarMaskDlg.h b/DeepSkyStacker/StarMaskDlg.h index 90247717b..4621f7042 100644 --- a/DeepSkyStacker/StarMaskDlg.h +++ b/DeepSkyStacker/StarMaskDlg.h @@ -1,4 +1,5 @@ #pragma once +#include "commonresource.h" // CStarMaskDlg dialog diff --git a/DeepSkyStacker/Stars.h b/DeepSkyStacker/Stars.h index bf5828625..775a87baa 100644 --- a/DeepSkyStacker/Stars.h +++ b/DeepSkyStacker/Stars.h @@ -1,10 +1,7 @@ -#ifndef __STARS_H__ -#define __STARS_H__ - -#include -#include -#include "DSSTools.h" +#pragma once #include "dssrect.h" +#include "DSSTools.h" + class CStar { @@ -229,5 +226,3 @@ inline int FindNearestStarWithinDistance(double fX, double fY, STARVECTOR & vSta return lResult; }; - -#endif // __STARS_H__ \ No newline at end of file diff --git a/DeepSkyStacker/StdAfx.h b/DeepSkyStacker/StdAfx.h index 57e980550..98d1d84ed 100644 --- a/DeepSkyStacker/StdAfx.h +++ b/DeepSkyStacker/StdAfx.h @@ -2,67 +2,88 @@ // or project specific include files that are used frequently, but // are changed infrequently // - #pragma once #if defined(USE_HOARD) #pragma comment(lib, "lib\\winhoard.lib") #endif -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -// -// Want to support windows 7 and up -// -#define _WIN32_WINNT _WIN32_WINNT_WIN7 +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define _WIN32_WINNT _WIN32_WINNT_WIN7 // Want to support windows 7 and up // Visual Leak Detector // #include -#include +// Qt Files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Standard Libraries +#include +#include +#include +#include +#include +#include +#include +namespace fs = std::filesystem; + +using std::min; +using std::max; + +// Windows Files (eventaully to go!) #include #include // MFC core and standard components #include // MFC extensions #include // MFC support for Internet Explorer 4 Common Controls #include -#ifndef _AFX_NO_AFXCMN_SUPPORT #include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include - -#include -#ifndef NDEBUG -//#include -#endif - -#include #include - -#include -using std::min; -using std::max; - -#include -#include - -#include "DSSCommon.h" -#include "DSSMemory.h" -#include "Ztrace.h" - -extern CString OUTPUTFILE_FILTERS; -extern CString OUTPUTLIST_FILTERS; -extern CString SETTINGFILE_FILTERS; -extern CString STARMASKFILE_FILTERS; - -extern bool g_bShowRefStars; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#include "resource.h" -#include "commonresource.h" -#include - -#include "BitmapExt.h" +#include +using namespace Gdiplus; diff --git a/DeepSkyStacker/TIFFUtil.cpp b/DeepSkyStacker/TIFFUtil.cpp index 6fc3616a9..16db22337 100644 --- a/DeepSkyStacker/TIFFUtil.cpp +++ b/DeepSkyStacker/TIFFUtil.cpp @@ -4,9 +4,20 @@ #include #include #include +#include #include "resource.h" #include "TIFFUtil.h" +#include "Ztrace.h" +#include "BitmapInfo.h" +#include "DSSProgress.h" +#include "Multitask.h" +#include "ColorHelpers.h" +#include "ColorBitmap.h" +#include "ZExcBase.h" +#include "RAWUtils.h" + +using namespace DSS; #define NRCUSTOMTIFFTAGS 12 @@ -463,6 +474,15 @@ bool CTIFFReader::Close() /* ------------------------------------------------------------------- */ +CTIFFWriter::CTIFFWriter(LPCTSTR szFileName, ProgressBase* pProgress) : + m_tiff{ nullptr }, + m_strFileName{ szFileName }, + m_pProgress{ pProgress }, + m_Format{ TF_UNKNOWN } +{ + compression = COMPRESSION_NONE; +} + void CTIFFWriter::SetFormat(int lWidth, int lHeight, TIFFFORMAT TiffFormat, CFATYPE CFAType, bool bMaster) { cfatype = CFAType; @@ -519,6 +539,19 @@ void CTIFFWriter::SetFormat(int lWidth, int lHeight, TIFFFORMAT TiffFormat, CFAT samplemax = 1.0; break; }; +} +void CTIFFWriter::SetCompression(TIFFCOMPRESSION tiffcomp) +{ + compression = COMPRESSION_NONE; + switch (tiffcomp) + { + case TC_LZW: + compression = COMPRESSION_LZW; + break; + case TC_DEFLATE: + compression = COMPRESSION_DEFLATE; + break; + }; }; /* ------------------------------------------------------------------- */ @@ -907,8 +940,8 @@ bool CTIFFWriteFromMemoryBitmap::OnOpen() lWidth = m_pMemoryBitmap->Width(); lHeight = m_pMemoryBitmap->Height(); - if (::IsCFA(m_pMemoryBitmap)) - CFAType = ::GetCFAType(m_pMemoryBitmap); + if (m_pMemoryBitmap->IsCFA()) + CFAType = m_pMemoryBitmap->GetCFAType(); bMaster = m_pMemoryBitmap->IsMaster(); if (m_Format == TF_UNKNOWN) @@ -1257,15 +1290,15 @@ bool GetTIFFInfo(LPCTSTR szFileName, CBitmapInfo & BitmapInfo) if (tiff.Open()) { - BitmapInfo.m_strFileName = szFileName; + BitmapInfo.m_strFileName = QString::fromWCharArray(szFileName); CString strMakeModel; tiff.GetMakeModel(strMakeModel); if (strMakeModel.GetLength()) - BitmapInfo.m_strFileType.Format(_T("TIFF (%s)"), (LPCTSTR)strMakeModel); + BitmapInfo.m_strFileType = QString("TIFF (%1)").arg(QString::fromWCharArray(strMakeModel.GetString())); else - BitmapInfo.m_strFileType = _T("TIFF"); + BitmapInfo.m_strFileType = "TIFF"; BitmapInfo.m_lWidth = tiff.Width(); BitmapInfo.m_lHeight = tiff.Height(); BitmapInfo.m_lBitPerChannel = tiff.BitPerChannels(); @@ -1324,3 +1357,35 @@ int LoadTIFFPicture(LPCTSTR szFileName, CBitmapInfo& BitmapInfo, std::shared_ptr } return result; } + +CTIFFHeader::CTIFFHeader() +{ + TIFFSetWarningHandler(nullptr); + TIFFSetWarningHandlerExt(nullptr); + //TIFFSetErrorHandler(nullptr); + //TIFFSetErrorHandlerExt(nullptr); + DSSTIFFInitialize(); + samplemax = 1.0; + samplemin = 0.0; + exposureTime = 0.0; + aperture = 0.0; + isospeed = 0; + gain = -1; + cfatype = 0; + cfa = 0; + nrframes = 0; + m_DateTime = { 0, 0, 0, 0, 0, 0, 0, 0 }; + w = 0; + h = 0; + spp = 0; + bps = 0; + photo = 0; + compression = 0; + planarconfig = 0; + sampleformat = 0; + master = 0; +} +bool CTIFFHeader::IsFloat() +{ + return (sampleformat == SAMPLEFORMAT_IEEEFP) && (bps == 32); +}; \ No newline at end of file diff --git a/DeepSkyStacker/TIFFUtil.h b/DeepSkyStacker/TIFFUtil.h index b7e0db04f..22c9a9b76 100644 --- a/DeepSkyStacker/TIFFUtil.h +++ b/DeepSkyStacker/TIFFUtil.h @@ -2,10 +2,12 @@ #define _TIFFUTIL_H__ /* ------------------------------------------------------------------- */ -#include "DSSTools.h" -#include "BitmapExt.h" -#include "DSSProgress.h" -#include +// #include "DSSTools.h" +// #include "BitmapExt.h" +// #include "DSSProgress.h" +#include +#include "cfa.h" +#include "DSSCommon.h" const int TIFFTAG_DSS_BASE = 50000; const int TIFFTAG_DSS_NRFRAMES = (TIFFTAG_DSS_BASE + 0); @@ -47,34 +49,8 @@ class CTIFFHeader SYSTEMTIME m_DateTime; public : - CTIFFHeader() - { - TIFFSetWarningHandler(nullptr); - TIFFSetWarningHandlerExt(nullptr); - //TIFFSetErrorHandler(nullptr); - //TIFFSetErrorHandlerExt(nullptr); - DSSTIFFInitialize(); - samplemax = 1.0; - samplemin = 0.0; - exposureTime = 0.0; - aperture = 0.0; - isospeed = 0; - gain = -1; - cfatype = 0; - cfa = 0; - nrframes = 0; - m_DateTime = { 0, 0, 0, 0, 0, 0, 0, 0}; - w = 0; - h = 0; - spp = 0; - bps = 0; - photo = 0; - compression = 0; - planarconfig = 0; - sampleformat = 0; - master = 0; - }; - virtual ~CTIFFHeader() {}; + CTIFFHeader(); + virtual ~CTIFFHeader() = default; public : bool IsCFA() @@ -92,10 +68,7 @@ public : return master; }; - bool IsFloat() - { - return (sampleformat == SAMPLEFORMAT_IEEEFP) && (bps == 32); - }; + bool IsFloat(); int Height() { @@ -196,6 +169,9 @@ public : }; }; +typedef struct tiff TIFF; +namespace DSS { class ProgressBase; } +using namespace DSS; class CTIFFReader : public CTIFFHeader { public : @@ -240,29 +216,10 @@ class CTIFFWriter : public CTIFFHeader protected: void SetFormat(int lWidth, int lHeight, TIFFFORMAT TiffFormat, CFATYPE CFAType, bool bMaster); - void SetCompression(TIFFCOMPRESSION tiffcomp) - { - compression = COMPRESSION_NONE; - switch (tiffcomp) - { - case TC_LZW : - compression = COMPRESSION_LZW; - break; - case TC_DEFLATE : - compression = COMPRESSION_DEFLATE; - break; - }; - }; + void SetCompression(TIFFCOMPRESSION tiffcomp); public: - CTIFFWriter(LPCTSTR szFileName, ProgressBase* pProgress) : - m_tiff{ nullptr }, - m_strFileName{ szFileName }, - m_pProgress{ pProgress }, - m_Format{ TF_UNKNOWN } - { - compression = COMPRESSION_NONE; - } + CTIFFWriter(LPCTSTR szFileName, ProgressBase* pProgress); virtual ~CTIFFWriter() { @@ -290,6 +247,8 @@ class CTIFFWriter : public CTIFFHeader }; /* ------------------------------------------------------------------- */ +class CBitmapInfo; +class CMemoryBitmap; bool GetTIFFInfo(LPCTSTR szFileName, CBitmapInfo & BitmapInfo); bool ReadTIFF(LPCTSTR szFileName, std::shared_ptr& rpBitmap, ProgressBase * pProgress); diff --git a/DeepSkyStacker/TaskInfo.cpp b/DeepSkyStacker/TaskInfo.cpp new file mode 100644 index 000000000..63257c31c --- /dev/null +++ b/DeepSkyStacker/TaskInfo.cpp @@ -0,0 +1,65 @@ +#include "stdafx.h" +#include "TaskInfo.h" +#include "MemoryBitmap.h" +#include "MultiBitmap.h" + +CTaskInfo::CTaskInfo() : + m_dwTaskID{ 0 }, + m_groupID{ 0 }, + m_TaskType{ PICTURETYPE(0) }, + m_lISOSpeed{ 0 }, + m_lGain{ -1 }, + m_fExposure{ 0.0 }, + m_fAperture{ 0.0 }, + m_bUnmodified{ false }, + m_bDone{ false }, + m_strOutputFile{}, + m_vBitmaps{}, + m_Method{ MBP_MEDIAN }, + m_fKappa{ 2.0 }, + m_lNrIterations{ 5 }, + m_pMaster{} +{ +} + +void CTaskInfo::SetMethod(MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations) +{ + m_Method = Method; + m_fKappa = fKappa; + m_lNrIterations = lNrIterations; +} + +void CTaskInfo::CreateEmptyMaster(const CMemoryBitmap* pBitmap) +{ + if (pBitmap == nullptr) + return; + m_pMaster = pBitmap->CreateEmptyMultiBitmap(); + m_pMaster->SetNrBitmaps(static_cast(m_vBitmaps.size())); + m_pMaster->SetProcessingMethod(m_Method, m_fKappa, m_lNrIterations); +} + +void CTaskInfo::AddToMaster(CMemoryBitmap* pBitmap, ProgressBase* pProgress) +{ + if (static_cast(m_pMaster)) + m_pMaster->AddBitmap(pBitmap, pProgress); +} + +std::shared_ptr CTaskInfo::GetMaster(ProgressBase* const pProgress) +{ + std::shared_ptr pBitmap; + + if (static_cast(m_pMaster) && m_pMaster->GetNrBitmaps() > 1) + { + pBitmap = m_pMaster->GetResult(pProgress); + if (static_cast(pBitmap)) + pBitmap->SetMaster(true); + } + m_pMaster.reset(); + return pBitmap; +} + +bool CTaskInfo::HasISOSpeed() const +{ + // Has valid ISOSpeed value or no valid Gain value. + return m_lISOSpeed != 0 || m_lGain < 0; +} \ No newline at end of file diff --git a/DeepSkyStacker/TaskInfo.h b/DeepSkyStacker/TaskInfo.h index 8fdc13ced..aa7350c0f 100644 --- a/DeepSkyStacker/TaskInfo.h +++ b/DeepSkyStacker/TaskInfo.h @@ -1,8 +1,12 @@ #pragma once +#include "DSSCommon.h" #include "FrameInfo.h" - +class CMultiBitmap; +class CMemoryBitmap; +namespace DSS { class ProgressBase; } +using namespace DSS; class CTaskInfo { public: @@ -23,67 +27,14 @@ class CTaskInfo std::shared_ptr m_pMaster; public: - CTaskInfo() : - m_dwTaskID{ 0 }, - m_groupID{ 0 }, - m_TaskType{ PICTURETYPE(0) }, - m_lISOSpeed{ 0 }, - m_lGain{ -1 }, - m_fExposure{ 0.0 }, - m_fAperture{ 0.0 }, - m_bUnmodified{ false }, - m_bDone{ false }, - m_strOutputFile{}, - m_vBitmaps{}, - m_Method{ MBP_MEDIAN }, - m_fKappa{ 2.0 }, - m_lNrIterations{ 5 }, - m_pMaster{} - {} - + CTaskInfo(); CTaskInfo(const CTaskInfo&) = default; CTaskInfo& operator=(const CTaskInfo&) = default; virtual ~CTaskInfo() = default; - void SetMethod(MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations) - { - m_Method = Method; - m_fKappa = fKappa; - m_lNrIterations = lNrIterations; - } - - void CreateEmptyMaster(const CMemoryBitmap* pBitmap) - { - if (pBitmap == nullptr) - return; - m_pMaster = pBitmap->CreateEmptyMultiBitmap(); - m_pMaster->SetNrBitmaps(static_cast(m_vBitmaps.size())); - m_pMaster->SetProcessingMethod(m_Method, m_fKappa, m_lNrIterations); - } - - void AddToMaster(CMemoryBitmap* pBitmap, ProgressBase* pProgress) - { - if (static_cast(m_pMaster)) - m_pMaster->AddBitmap(pBitmap, pProgress); - } - - std::shared_ptr GetMaster(ProgressBase* const pProgress) - { - std::shared_ptr pBitmap; - - if (static_cast(m_pMaster) && m_pMaster->GetNrBitmaps() > 1) - { - pBitmap = m_pMaster->GetResult(pProgress); - if (static_cast(pBitmap)) - pBitmap->SetMaster(true); - } - m_pMaster.reset(); - return pBitmap; - } - - bool HasISOSpeed() const - { - // Has valid ISOSpeed value or no valid Gain value. - return m_lISOSpeed != 0 || m_lGain < 0; - } + void SetMethod(MULTIBITMAPPROCESSMETHOD Method, double fKappa, int lNrIterations); + void CreateEmptyMaster(const CMemoryBitmap* pBitmap); + void AddToMaster(CMemoryBitmap* pBitmap, ProgressBase* pProgress); + std::shared_ptr GetMaster(ProgressBase* const pProgress); + bool HasISOSpeed() const; }; diff --git a/DeepSkyStacker/Workspace.cpp b/DeepSkyStacker/Workspace.cpp index 3b83f6e8a..5298ac233 100644 --- a/DeepSkyStacker/Workspace.cpp +++ b/DeepSkyStacker/Workspace.cpp @@ -1,19 +1,7 @@ #include -#include -#include -#include -#include -#include -#include -#include - -#include "resource.h" #include "Workspace.h" - -#include "BitmapExt.h" -#include "DSSProgress.h" -#include "DSSTools.h" -#include "StackingTasks.h" +#include "DSSCommon.h" +#include "ZExcBase.h" class WorkspaceSettings { diff --git a/DeepSkyStacker/Workspace.h b/DeepSkyStacker/Workspace.h index d277ff049..fcc6c458e 100644 --- a/DeepSkyStacker/Workspace.h +++ b/DeepSkyStacker/Workspace.h @@ -2,9 +2,7 @@ #define __WORKSPACE_H__ #include -#include -#include -#include +#include namespace fs = std::filesystem; class WorkspaceSettings; diff --git a/DeepSkyStacker/avx.cpp b/DeepSkyStacker/avx.cpp index 0526d27f0..f5ca371b3 100644 --- a/DeepSkyStacker/avx.cpp +++ b/DeepSkyStacker/avx.cpp @@ -1,10 +1,13 @@ -#include "StdAfx.h" -#include +#include "stdafx.h" #include "avx_support.h" #include "dssrect.h" #include "avx.h" -#include -#include +#include "PixelTransform.h" +#include "BilinearParameters.h" +#include "TaskInfo.h" +#include "BackgroundCalibration.h" +#include "avx_entropy.h" +#include "EntropyInfo.h" AvxStacking::AvxStacking(int lStart, int lEnd, CMemoryBitmap& inputbm, CMemoryBitmap& tempbm, const DSSRect& resultRect, AvxEntropy& entrdat) : lineStart{ lStart }, lineEnd{ lEnd }, colEnd{ inputbm.Width() }, diff --git a/DeepSkyStacker/avx.h b/DeepSkyStacker/avx.h index ac404c6ad..cb58867a9 100644 --- a/DeepSkyStacker/avx.h +++ b/DeepSkyStacker/avx.h @@ -1,16 +1,10 @@ #pragma once - -#include -#include - #include "avx_cfa.h" -#include "avx_entropy.h" -#include "PixelTransform.h" -#include "TaskInfo.h" -#include "BackgroundCalibration.h" -#include "BitmapBase.h" - +class AvxEntropy; +class CPixelTransform; +class CTaskInfo; +class CBackgroundCalibration; class AvxStacking { private: diff --git a/DeepSkyStacker/avx_avg.cpp b/DeepSkyStacker/avx_avg.cpp index 35482e40d..add616f7b 100644 --- a/DeepSkyStacker/avx_avg.cpp +++ b/DeepSkyStacker/avx_avg.cpp @@ -1,12 +1,9 @@ -#include "StdAfx.h" -#include -#include -#include -#include "dssrect.h" +#include "stdafx.h" #include "avx_avg.h" +#include "dssrect.h" #include "avx_support.h" #include "TaskInfo.h" -#include +#include "Ztrace.h" AvxAccumulation::AvxAccumulation(const DSSRect& resultRect, const CTaskInfo& tInfo, CMemoryBitmap& tempbm, CMemoryBitmap& outbm, AvxEntropy& entroinfo) noexcept : resultWidth{ resultRect.width() }, resultHeight{ resultRect.height() }, diff --git a/DeepSkyStacker/avx_avg.h b/DeepSkyStacker/avx_avg.h index 61bd35537..365bfe261 100644 --- a/DeepSkyStacker/avx_avg.h +++ b/DeepSkyStacker/avx_avg.h @@ -4,7 +4,9 @@ #include "avx_entropy.h" class CTaskInfo; - +class DSSRect; +class CMemoryBitmap; +class AvxEntropy; class AvxAccumulation { diff --git a/DeepSkyStacker/avx_bitmap_filler.cpp b/DeepSkyStacker/avx_bitmap_filler.cpp index d0d2fd406..4266f5a72 100644 --- a/DeepSkyStacker/avx_bitmap_filler.cpp +++ b/DeepSkyStacker/avx_bitmap_filler.cpp @@ -1,8 +1,8 @@ -#include "StdAfx.h" -#include "BitMapFiller.h" +#include "stdafx.h" + #include "avx_bitmap_filler.h" #include "avx_support.h" -#include +#include "ZExcept.h" // --------------------------------- diff --git a/DeepSkyStacker/avx_bitmap_filler.h b/DeepSkyStacker/avx_bitmap_filler.h index f8b955df2..ba59216fc 100644 --- a/DeepSkyStacker/avx_bitmap_filler.h +++ b/DeepSkyStacker/avx_bitmap_filler.h @@ -1,13 +1,14 @@ #pragma once - #include "BitMapFiller.h" +namespace DSS { class ProgressBase; } + class AvxBitmapFiller : public BitmapFillerBase { private: std::vector sourceBuffer; public: - AvxBitmapFiller(CMemoryBitmap* pB, ProgressBase* pP, const double redWb, const double greenWb, const double blueWb); + AvxBitmapFiller(CMemoryBitmap* pB, DSS::ProgressBase* pP, const double redWb, const double greenWb, const double blueWb); AvxBitmapFiller(const AvxBitmapFiller&) = default; // For cloning. virtual ~AvxBitmapFiller() {} @@ -20,7 +21,7 @@ class AvxBitmapFiller : public BitmapFillerBase class NonAvxBitmapFiller : public BitmapFillerBase { public: - NonAvxBitmapFiller(CMemoryBitmap* pB, ProgressBase* pP, const double redWb, const double greenWb, const double blueWb); + NonAvxBitmapFiller(CMemoryBitmap* pB, DSS::ProgressBase* pP, const double redWb, const double greenWb, const double blueWb); NonAvxBitmapFiller(const NonAvxBitmapFiller&) = default; // For cloning. virtual ~NonAvxBitmapFiller() {} diff --git a/DeepSkyStacker/avx_cfa.cpp b/DeepSkyStacker/avx_cfa.cpp index b426d3df1..1c9d23e20 100644 --- a/DeepSkyStacker/avx_cfa.cpp +++ b/DeepSkyStacker/avx_cfa.cpp @@ -1,7 +1,6 @@ -#include "StdAfx.h" +#include "stdafx.h" #include "avx_cfa.h" #include "avx_support.h" -#include AvxCfaProcessing::AvxCfaProcessing(const size_t lineStart, const size_t lineEnd, CMemoryBitmap& inputbm) : redPixels{}, diff --git a/DeepSkyStacker/avx_cfa.h b/DeepSkyStacker/avx_cfa.h index 50298ea28..65a58db62 100644 --- a/DeepSkyStacker/avx_cfa.h +++ b/DeepSkyStacker/avx_cfa.h @@ -1,7 +1,6 @@ #pragma once #include "BitmapBase.h" -#include class AvxCfaProcessing { diff --git a/DeepSkyStacker/avx_entropy.cpp b/DeepSkyStacker/avx_entropy.cpp index e92da89f9..8cf7a6901 100644 --- a/DeepSkyStacker/avx_entropy.cpp +++ b/DeepSkyStacker/avx_entropy.cpp @@ -1,10 +1,9 @@ -#include "StdAfx.h" +#include "stdafx.h" #include "avx_entropy.h" -#include "avx_support.h" -#include "avx_cfa.h" -#include "avx_histogram.h" -#include -#include +#include "avx_support.h" +#include "avx_cfa.h" +#include "avx_histogram.h" +#include "Multitask.h" AvxEntropy::AvxEntropy(CMemoryBitmap& inputbm, const CEntropyInfo& entrinfo, CMemoryBitmap* entropycov) : inputBitmap{ inputbm }, diff --git a/DeepSkyStacker/avx_entropy.h b/DeepSkyStacker/avx_entropy.h index 70034a532..309307975 100644 --- a/DeepSkyStacker/avx_entropy.h +++ b/DeepSkyStacker/avx_entropy.h @@ -1,15 +1,12 @@ #pragma once -#include "BitmapBase.h" -#include "EntropyInfo.h" -#include - /* * Class for * 1. Calculation of the entropy data of the squares, * 2. Managing the entropy coverage (the coverage bitmap itself is calculated while stacking with the class AvxStacking). */ - +class CMemoryBitmap; +class CEntropyInfo; class AvxEntropy { private: diff --git a/DeepSkyStacker/avx_filter.cpp b/DeepSkyStacker/avx_filter.cpp index d65d3a66a..c276b75e0 100644 --- a/DeepSkyStacker/avx_filter.cpp +++ b/DeepSkyStacker/avx_filter.cpp @@ -1,10 +1,8 @@ -#include "StdAfx.h" -#include "resource.h" -#include "BitmapBase.h" -#include "BitmapExt.h" +#include "stdafx.h" +#include #include "avx_filter.h" #include "avx_support.h" -#include +#include "MedianFilterEngine.h" template <> AvxImageFilter::AvxImageFilter(CInternalMedianFilterEngineT* filEng) : diff --git a/DeepSkyStacker/avx_histogram.cpp b/DeepSkyStacker/avx_histogram.cpp index 3f3079353..89d519d2e 100644 --- a/DeepSkyStacker/avx_histogram.cpp +++ b/DeepSkyStacker/avx_histogram.cpp @@ -1,6 +1,5 @@ -#include "StdAfx.h" +#include "stdafx.h" #include "avx_histogram.h" -#include AvxHistogram::AvxHistogram(CMemoryBitmap& inputbm) : avxReady{ AvxSupport::checkSimdAvailability() }, diff --git a/DeepSkyStacker/avx_histogram.h b/DeepSkyStacker/avx_histogram.h index 78a44b0e5..089bda6fe 100644 --- a/DeepSkyStacker/avx_histogram.h +++ b/DeepSkyStacker/avx_histogram.h @@ -1,8 +1,6 @@ #pragma once - -#include "avx_support.h" #include "avx_cfa.h" -#include +#include "avx_support.h" class AvxHistogram { diff --git a/DeepSkyStacker/avx_luminance.cpp b/DeepSkyStacker/avx_luminance.cpp index c97977c8b..63cb43b05 100644 --- a/DeepSkyStacker/avx_luminance.cpp +++ b/DeepSkyStacker/avx_luminance.cpp @@ -1,4 +1,4 @@ -#include "StdAfx.h" +#include "stdafx.h" #include "avx_luminance.h" #include "avx_cfa.h" #include "avx_support.h" diff --git a/DeepSkyStacker/avx_output.cpp b/DeepSkyStacker/avx_output.cpp index ce7088c47..fdcda1a81 100644 --- a/DeepSkyStacker/avx_output.cpp +++ b/DeepSkyStacker/avx_output.cpp @@ -1,8 +1,11 @@ -#include "StdAfx.h" +#include "stdafx.h" +#include #include "avx_output.h" #include "avx_support.h" #include "avx_median.h" -#include +#include "MultiBitmap.h" +#include "ColorMultiBitmap.h" +#include "GreyMultiBitmap.h" AvxOutputComposition::AvxOutputComposition(CMultiBitmap& mBitmap, CMemoryBitmap& outputbm) : inputBitmap{ mBitmap }, diff --git a/DeepSkyStacker/avx_output.h b/DeepSkyStacker/avx_output.h index 67c03aae7..b6a2b8e65 100644 --- a/DeepSkyStacker/avx_output.h +++ b/DeepSkyStacker/avx_output.h @@ -3,7 +3,7 @@ #include "BitmapBase.h" #include - +class CMultiBitmap; class AvxOutputComposition { private: diff --git a/DeepSkyStacker/avx_support.cpp b/DeepSkyStacker/avx_support.cpp index 5db739178..a3155441f 100644 --- a/DeepSkyStacker/avx_support.cpp +++ b/DeepSkyStacker/avx_support.cpp @@ -1,6 +1,8 @@ -#include "StdAfx.h" +#include "stdafx.h" #include "avx_support.h" -#include +#include "BitmapCharacteristics.h" +#include "Multitask.h" + AvxSupport::AvxSupport(CMemoryBitmap& b) noexcept : diff --git a/DeepSkyStacker/avx_support.h b/DeepSkyStacker/avx_support.h index 412e7b12f..68267ee4e 100644 --- a/DeepSkyStacker/avx_support.h +++ b/DeepSkyStacker/avx_support.h @@ -1,7 +1,8 @@ #pragma once -#include "BitmapBase.h" - +#include "cfa.h" +#include "ColorBitmap.h" +#include "GrayBitmap.h" class AvxSupport { diff --git a/DeepSkyStacker/cfa.h b/DeepSkyStacker/cfa.h new file mode 100644 index 000000000..94d40e2fc --- /dev/null +++ b/DeepSkyStacker/cfa.h @@ -0,0 +1,71 @@ +#pragma once + +enum CFATYPE : std::uint32_t +{ + CFATYPE_NONE = 0, + CFATYPE_BGGR = 1, + CFATYPE_GRBG = 2, + CFATYPE_GBRG = 3, + CFATYPE_RGGB = 4, + + // A = Cyan B = Green C = Magenta D = Yellow + CFATYPE_CGMY = 0xABCD, + CFATYPE_CGYM = 0xABDC, + CFATYPE_CMGY = 0xACBD, + CFATYPE_CMYG = 0xACDB, + CFATYPE_CYMG = 0xADCB, + CFATYPE_CYGM = 0xADBC, + + CFATYPE_GCMY = 0xBACD, + CFATYPE_GCYM = 0xBADC, + CFATYPE_GMCY = 0xBCAD, + CFATYPE_GMYC = 0xBCDA, + CFATYPE_GYCM = 0xBDAC, + CFATYPE_GYMC = 0xBDCA, + + CFATYPE_MCGY = 0xCABD, + CFATYPE_MCYG = 0xCADB, + CFATYPE_MGYC = 0xCBDA, + CFATYPE_MGCY = 0xCBAD, + CFATYPE_MYGC = 0xCDBA, + CFATYPE_MYCG = 0xCDAB, + + CFATYPE_YCGM = 0xDABC, + CFATYPE_YCMG = 0xDACB, + CFATYPE_YGMC = 0xDBCA, + CFATYPE_YGCM = 0xDBAC, + CFATYPE_YMCG = 0xDCAB, + CFATYPE_YMGC = 0xDCBA, + + CFATYPE_CYMGCYGM = 0xADCBADBC, + CFATYPE_YCGMYCMG = 0xDABCDACB, + CFATYPE_CYGMCYMG = 0xADBCADCB, + CFATYPE_YCMGYCGM = 0xDACBDABC, + + CFATYPE_MGYCMGCY = 0xCBDACBAD, + CFATYPE_GMCYGMYC = 0xBCADBCDA, + CFATYPE_MGCYMGYC = 0xCBADCBDA, + CFATYPE_GMYCGMCY = 0xBCDABCAD, + + CFATYPE_GMCYMGCY = 0xBCADCBAD, + CFATYPE_MGYCGMYC = 0xCBDABCDA, + CFATYPE_MGCYGMCY = 0xCBADBCAD, + CFATYPE_GMYCMGYC = 0xBCDACBDA, + + CFATYPE_CYMGYCMG = 0xADCBDACB, + CFATYPE_YCGMCYGM = 0xDABCADBC, + CFATYPE_YCMGCYMG = 0xDACBADCB, + CFATYPE_CYGMYCGM = 0xADBCDABC +}; +inline bool IsCYMGType(CFATYPE Type) { return ((Type & 0xFFFFFFF0) != 0); } +inline bool IsSimpleCYMG(CFATYPE Type) { return !(Type & 0xFFFF0000); } + +typedef enum CFATRANSFORMATION +{ + CFAT_NONE = 0, + CFAT_SUPERPIXEL = 1, + CFAT_RAWBAYER = 2, + CFAT_BILINEAR = 3, + CFAT_GRADIENT = 4, + CFAT_AHD = 5 +} CFATRANSFORMATION; diff --git a/DeepSkyStacker/commonresource.h b/DeepSkyStacker/commonresource.h index ce3c1bbac..f8af1ef8c 100644 --- a/DeepSkyStacker/commonresource.h +++ b/DeepSkyStacker/commonresource.h @@ -3,7 +3,7 @@ // Used by DeepSkyStacker.rc // #define IDC_DELETE 2 -#define IDC_STOP 3 +//#define IDC_STOP 3 #define IDC_ADD 3 #define IDC_LOAD 4 #define IDD_DEEPSTACKER 101 @@ -17,7 +17,7 @@ #define IDI_OPENFILE 108 #define IDI_UNDO 109 #define IDI_REDO 110 -#define IDD_PROGRESS 111 +//#define IDD_PROGRESS 111 #define IDD_SETTINGS 112 #define IDI_SETTINGS 113 #define IDD_SATURATION 113 @@ -68,7 +68,7 @@ #define IDB_IMAGELIST_CFA_RGB 157 #define IDB_BITMAP4 158 #define IDB_IMAGELIST_COLOR 158 -#define IDB_BITMAP1 160 +//#define IDB_BITMAP1 160 #define IDB_IMAGELIST_MASK 160 #define IDD_DROPFILES 162 #define IDD_STACKINGINTERMEDIATE 163 @@ -136,7 +136,7 @@ #define IDS_COLUMN_EXPOSURE 213 #define IDB_RGBCALIBRATION_MINIMUM 213 #define IDS_COLUMN_STARS 214 -#define IDB_4CORNERS 216 +//#define IDB_4CORNERS 216 #define IDB_INTERSECTIONMODE 217 #define IDS_TYPE_LIGHT 300 #define IDS_TYPE_DARK 301 diff --git a/DeepSkyStacker/dslr.h b/DeepSkyStacker/dslr.h new file mode 100644 index 000000000..c287725c8 --- /dev/null +++ b/DeepSkyStacker/dslr.h @@ -0,0 +1,38 @@ +#pragma once +#include "cfa.h" + +class CDSLR +{ +public: + QString m_strName; + CFATYPE m_CFAType; + +private: + void CopyFrom(const CDSLR& cd) + { + m_strName = cd.m_strName; + m_CFAType = cd.m_CFAType; + }; + +public: + CDSLR(QString name, CFATYPE CFAType) : + m_strName(name), + m_CFAType(CFAType) + { + }; + + CDSLR(const CDSLR& cd) + { + CopyFrom(cd); + }; + + virtual ~CDSLR() + { + }; + + const CDSLR& operator = (const CDSLR& cd) + { + CopyFrom(cd); + return *this; + }; +}; diff --git a/DeepSkyStacker/dss_settings.cpp b/DeepSkyStacker/dss_settings.cpp index 4ed030ef6..498eee995 100644 --- a/DeepSkyStacker/dss_settings.cpp +++ b/DeepSkyStacker/dss_settings.cpp @@ -34,9 +34,6 @@ ** ****************************************************************************/ #include "stdafx.h" - -#include "BezierAdjust.h" -#include "Histogram.h" #include "dss_settings.h" #pragma pack(push, HDSETTINGS, 2) diff --git a/DeepSkyStacker/dss_settings.h b/DeepSkyStacker/dss_settings.h index 6fd392401..02622848d 100644 --- a/DeepSkyStacker/dss_settings.h +++ b/DeepSkyStacker/dss_settings.h @@ -1,4 +1,6 @@ #pragma once +#include "BezierAdjust.h" +#include "Histogram.h" /**************************************************************************** ** ** Copyright (C) 2022 David C. Partridge diff --git a/DeepSkyStacker/editstars.cpp b/DeepSkyStacker/editstars.cpp index 3983cb53d..3b193c5d5 100644 --- a/DeepSkyStacker/editstars.cpp +++ b/DeepSkyStacker/editstars.cpp @@ -33,31 +33,15 @@ ** ** ****************************************************************************/ -#include "StdAfx.h" - -#include -#include -#include -#include -#include -#include -#include - -#if QT_VERSION < 0x060000 -#define _USE_MATH_DEFINES -#endif -#include - -#include "DeepSkyStacker.h" -#include "dssrect.h" +#include "stdafx.h" #include "editstars.h" -#include "imageview.h" #include "Delaunay.h" -#include "Stars.h" -#include "MatchingStars.h" +#include "imageview.h" +#include "DSSCommon.h" +#include "StackingDlg.h" #include "RegisterEngine.h" #include "BackgroundCalibration.h" -#include "StackingDlg.h" +#include "DeepSkyStacker.h" // Classes etc. private to this file namespace @@ -190,6 +174,38 @@ namespace DSS //)); } + void EditStars::setTransformation(const CBilinearParameters& Tr, const VOTINGPAIRVECTOR& vVP) + { + if (g_bShowRefStars) + { + transformation = Tr; + vVotedPairs = vVP; + }; + } + + void EditStars::clearRefStars() + { + refStars.clear(); + }; + + void EditStars::setBitmap(std::shared_ptr bmp) + { + m_pBitmap = bmp; + m_GrayBitmap.Init(RCCHECKSIZE + 1, RCCHECKSIZE + 1); + m_bDirty = false; + m_fBackground = 0; + if (static_cast(m_pBitmap)) + computeBackgroundValue(); + } + + void EditStars::setRefStars(STARVECTOR const& Stars) + { + if (g_bShowRefStars) + { + refStars = Stars; + std::sort(refStars.begin(), refStars.end(), CompareStarLuminancy); + }; + } void EditStars::leaveEvent([[maybe_unused]] QEvent* e) { diff --git a/DeepSkyStacker/editstars.h b/DeepSkyStacker/editstars.h index 110c45fd2..c8dcb601b 100644 --- a/DeepSkyStacker/editstars.h +++ b/DeepSkyStacker/editstars.h @@ -1,4 +1,7 @@ #pragma once +#include "Stars.h" +#include "MatchingStars.h" +#include "GrayBitmap.h" /**************************************************************************** ** ** Copyright (C) 2020 David C. Partridge @@ -35,14 +38,9 @@ ** ****************************************************************************/ class QMouseEvent; - -#include -#include "DSSCommon.h" -#include "DSSTools.h" -#include "Stars.h" -#include "MatchingStars.h" - class CMemoryBitmap; +class CBilinearParameters; +extern bool g_bShowRefStars; namespace DSS { @@ -144,39 +142,10 @@ namespace DSS return m_bDirty; }; - void setTransformation(const CBilinearParameters& Tr, const VOTINGPAIRVECTOR& vVP) - { - if (g_bShowRefStars) - { - transformation = Tr; - vVotedPairs = vVP; - }; - }; - - void setBitmap(std::shared_ptr bmp) - { - m_pBitmap = bmp; - m_GrayBitmap.Init(RCCHECKSIZE + 1, RCCHECKSIZE + 1); - m_bDirty = false; - m_fBackground = 0; - if (static_cast(m_pBitmap)) - computeBackgroundValue(); - } - - void setRefStars(STARVECTOR const& Stars) - { - if (g_bShowRefStars) - { - refStars = Stars; - std::sort(refStars.begin(), refStars.end(), CompareStarLuminancy); - }; - }; - - void clearRefStars() - { - refStars.clear(); - }; - + void setTransformation(const CBilinearParameters& Tr, const VOTINGPAIRVECTOR& vVP); + void setBitmap(std::shared_ptr bmp); + void setRefStars(STARVECTOR const& Stars); + void clearRefStars(); void saveRegisterSettings(); public slots: diff --git a/DeepSkyStacker/group.cpp b/DeepSkyStacker/group.cpp index d01e4e044..957e44adc 100644 --- a/DeepSkyStacker/group.cpp +++ b/DeepSkyStacker/group.cpp @@ -34,111 +34,130 @@ ** ****************************************************************************/ #include "stdafx.h" -#include -using std::min; -using std::max; -#include - +#include "group.h" +#include "ImageListModel.h" #include "Ztrace.h" -#include -#include "dsscommon.h" -#include "framelist.h" +#include "FrameInfo.h" +#include "RegisterEngine.h" -#include "group.h" +using namespace DSS; -namespace DSS +Group::Group() : + pictures{ std::make_unique() }, + Index{ nextIndex++ }, // First group is Main Group with Index of 0 + Dirty{ false } { - void Group::addFile(fs::path file, PICTURETYPE PictureType, bool bCheck, [[maybe_unused]] int32_t nItem) + if (0 == Index) { - ZFUNCTRACE_RUNTIME(); + Name = QCoreApplication::translate("DSS::StackingDlg", "Main Group", "IDS_MAINGROUP"); + } + else + { + Name = QCoreApplication::translate("DSS::StackingDlg", "Group %1", "IDS_GROUPIDMASK").arg(Index); + } +} - ListBitMap lb; +void Group::addImage(const ListBitMap& image) +{ + pictures->addImage(image); + Dirty = true; +} + +size_t Group::size() const noexcept +{ + return pictures->rowCount(); +} - lb.m_groupId = Index; +void Group::addFile(fs::path file, PICTURETYPE PictureType, bool bCheck, [[maybe_unused]] int32_t nItem) +{ + ZFUNCTRACE_RUNTIME(); + + ListBitMap lb; + + lb.m_groupId = Index; - if (lb.InitFromFile(file, PictureType)) + if (lb.InitFromFile(file, PictureType)) + { + if (PictureType == PICTURETYPE_DARKFRAME) { - if (PictureType == PICTURETYPE_DARKFRAME) - { - lb.m_strType = QCoreApplication::translate("DSS::Group", "Dark", "IDS_TYPE_DARK"); - } - else if (PictureType == PICTURETYPE_DARKFLATFRAME) - { - lb.m_strType = QCoreApplication::translate("DSS::Group", "Dark Flat", "IDS_TYPE_DARKFLAT"); - } - else if (PictureType == PICTURETYPE_FLATFRAME) - { - lb.m_strType = QCoreApplication::translate("DSS::Group", "Flat", "IDS_TYPE_FLAT"); - } - else if (PictureType == PICTURETYPE_OFFSETFRAME) - { - lb.m_strType = QCoreApplication::translate("DSS::Group", "Bias/Offset", "IDS_TYPE_OFFSET"); - } - else - { - lb.m_strType = QCoreApplication::translate("DSS::Group", "Light", "IDS_TYPE_LIGHT"); - }; + lb.m_strType = QCoreApplication::translate("DSS::Group", "Dark", "IDS_TYPE_DARK"); + } + else if (PictureType == PICTURETYPE_DARKFLATFRAME) + { + lb.m_strType = QCoreApplication::translate("DSS::Group", "Dark Flat", "IDS_TYPE_DARKFLAT"); + } + else if (PictureType == PICTURETYPE_FLATFRAME) + { + lb.m_strType = QCoreApplication::translate("DSS::Group", "Flat", "IDS_TYPE_FLAT"); + } + else if (PictureType == PICTURETYPE_OFFSETFRAME) + { + lb.m_strType = QCoreApplication::translate("DSS::Group", "Bias/Offset", "IDS_TYPE_OFFSET"); + } + else + { + lb.m_strType = QCoreApplication::translate("DSS::Group", "Light", "IDS_TYPE_LIGHT"); + }; - if (bCheck) - lb.m_bChecked = Qt::Checked; - else - lb.m_bChecked = Qt::Unchecked; + if (bCheck) + lb.m_bChecked = Qt::Checked; + else + lb.m_bChecked = Qt::Unchecked; - if (file.has_parent_path()) - lb.m_strPath = QString::fromStdU16String(file.parent_path().generic_u16string()); - else - lb.m_strPath = QString::fromStdU16String(file.root_path().generic_u16string()); + if (file.has_parent_path()) + lb.m_strPath = QString::fromStdU16String(file.parent_path().generic_u16string()); + else + lb.m_strPath = QString::fromStdU16String(file.root_path().generic_u16string()); - lb.m_strFile = QString::fromStdU16String(file.filename().generic_u16string()); + lb.m_strFile = QString::fromStdU16String(file.filename().generic_u16string()); - if (lb.m_PictureType == PICTURETYPE_LIGHTFRAME) - { - CLightFrameInfo bmpInfo; - - bmpInfo.SetBitmap(file.c_str(), false); - if (bmpInfo.m_bInfoOk) - { - lb.m_bRegistered = true; - lb.m_fOverallQuality = bmpInfo.m_fOverallQuality; - lb.m_fFWHM = bmpInfo.m_fFWHM; - lb.m_lNrStars = static_cast(bmpInfo.m_vStars.size()); - lb.m_bComet = bmpInfo.m_bComet; - lb.m_SkyBackground = bmpInfo.m_SkyBackground; - lb.m_bUseAsStarting = (PictureType == PICTURETYPE_REFLIGHTFRAME); - } - }; - - lb.m_strSizes = QString("%1 x %2").arg(lb.m_lWidth).arg(lb.m_lHeight); - - if (lb.m_lNrChannels == 3) - lb.m_strDepth = QCoreApplication::translate("DSS::Group", "RGB %1 bit/ch", "IDS_FORMAT_RGB").arg(lb.m_lBitPerChannels); - else - lb.m_strDepth = QCoreApplication::translate("DSS::Group", "Gray %1 bit", "IDS_FORMAT_GRAY").arg(lb.m_lBitPerChannels); - - if (lb.IsMasterFrame()) - { - if (PictureType == PICTURETYPE_DARKFRAME) - lb.m_strType = QCoreApplication::translate("DSS::Group", "Master Dark", "IDS_TYPE_MASTERDARK"); - else if (PictureType == PICTURETYPE_DARKFLATFRAME) - lb.m_strType = QCoreApplication::translate("DSS::Group", "Master Dark Flat", "IDS_TYPE_MASTERDARKFLAT"); - else if (PictureType == PICTURETYPE_FLATFRAME) - lb.m_strType = QCoreApplication::translate("DSS::Group", "Master Flat", "IDS_TYPE_MASTERFLAT"); - else if (PictureType == PICTURETYPE_OFFSETFRAME) - lb.m_strType = QCoreApplication::translate("DSS::Group", "Master Offset", "IDS_TYPE_MASTEROFFSET"); - }; - - if (lb.GetCFAType() != CFATYPE_NONE) - lb.m_strCFA = QCoreApplication::translate("DSS::Group", "Yes", "IDS_YES"); - else - lb.m_strCFA = QCoreApplication::translate("DSS::Group", "No", "IDS_NO"); + if (lb.m_PictureType == PICTURETYPE_LIGHTFRAME) + { + CLightFrameInfo bmpInfo; + bmpInfo.SetBitmap(file.c_str(), false); + if (bmpInfo.m_bInfoOk) + { + lb.m_bRegistered = true; + lb.m_fOverallQuality = bmpInfo.m_fOverallQuality; + lb.m_fFWHM = bmpInfo.m_fFWHM; + lb.m_lNrStars = static_cast(bmpInfo.m_vStars.size()); + lb.m_bComet = bmpInfo.m_bComet; + lb.m_SkyBackground = bmpInfo.m_SkyBackground; + lb.m_bUseAsStarting = (PictureType == PICTURETYPE_REFLIGHTFRAME); + } }; - pathToGroup.emplace(file, Index); + lb.m_strSizes = QString("%1 x %2").arg(lb.m_lWidth).arg(lb.m_lHeight); - pictures->addImage(lb); + if (lb.m_lNrChannels == 3) + lb.m_strDepth = QCoreApplication::translate("DSS::Group", "RGB %1 bit/ch", "IDS_FORMAT_RGB").arg(lb.m_lBitPerChannels); + else + lb.m_strDepth = QCoreApplication::translate("DSS::Group", "Gray %1 bit", "IDS_FORMAT_GRAY").arg(lb.m_lBitPerChannels); + if (lb.IsMasterFrame()) + { + if (PictureType == PICTURETYPE_DARKFRAME) + lb.m_strType = QCoreApplication::translate("DSS::Group", "Master Dark", "IDS_TYPE_MASTERDARK"); + else if (PictureType == PICTURETYPE_DARKFLATFRAME) + lb.m_strType = QCoreApplication::translate("DSS::Group", "Master Dark Flat", "IDS_TYPE_MASTERDARKFLAT"); + else if (PictureType == PICTURETYPE_FLATFRAME) + lb.m_strType = QCoreApplication::translate("DSS::Group", "Master Flat", "IDS_TYPE_MASTERFLAT"); + else if (PictureType == PICTURETYPE_OFFSETFRAME) + lb.m_strType = QCoreApplication::translate("DSS::Group", "Master Offset", "IDS_TYPE_MASTEROFFSET"); + }; + + if (lb.GetCFAType() != CFATYPE_NONE) + lb.m_strCFA = QCoreApplication::translate("DSS::Group", "Yes", "IDS_YES"); + else + lb.m_strCFA = QCoreApplication::translate("DSS::Group", "No", "IDS_NO"); }; + + pathToGroup.emplace(file, Index); + + pictures->addImage(lb); + + } \ No newline at end of file diff --git a/DeepSkyStacker/group.h b/DeepSkyStacker/group.h index 19a6f4581..95bf859fc 100644 --- a/DeepSkyStacker/group.h +++ b/DeepSkyStacker/group.h @@ -34,12 +34,12 @@ ** ** ****************************************************************************/ - -#include - -#include -#include +#include +#include "DSSCommon.h" #include "ImageListModel.h" +namespace fs = std::filesystem; + +class ListBitMap; namespace DSS { @@ -60,22 +60,9 @@ namespace DSS // // Qt Table Model class derived from QAbstractTableModel // - std::unique_ptr pictures; + std::unique_ptr pictures; - explicit Group() : - pictures { std::make_unique() }, - Index { nextIndex++ }, // First group is Main Group with Index of 0 - Dirty{ false } - { - if (0 == Index) - { - Name = QCoreApplication::translate("DSS::StackingDlg", "Main Group", "IDS_MAINGROUP"); - } - else - { - Name = QCoreApplication::translate("DSS::StackingDlg", "Group %1", "IDS_GROUPIDMASK").arg(Index); - } - } + explicit Group(); // // Don't intend this to be copied or assigned. @@ -107,10 +94,7 @@ namespace DSS // // Accessors // - inline size_t size() const noexcept - { - return pictures->rowCount(); - } + size_t size() const noexcept; inline QString name() const noexcept { return Name; }; inline Group& setName(QString const& name) noexcept { Name = name; return *this; }; @@ -127,11 +111,7 @@ namespace DSS // // Add an image (row) to the table // - void addImage(const ListBitMap& image) - { - pictures->addImage(image); - Dirty = true; - } + void addImage(const ListBitMap& image); static int16_t whichGroupContains(const fs::path& path) { diff --git a/DeepSkyStacker/imageloader.cpp b/DeepSkyStacker/imageloader.cpp index 15fcb13bc..1afc512f0 100644 --- a/DeepSkyStacker/imageloader.cpp +++ b/DeepSkyStacker/imageloader.cpp @@ -1,39 +1,9 @@ #include "stdafx.h" - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -// -// Want to support windows 7 and up -// -#define _WIN32_WINNT _WIN32_WINNT_WIN7 - -#include -#include // MFC core and standard components -#include // MFC extensions -#include // MFC support for Internet Explorer 4 Common Controls -#include -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -//#include - -//#include - -#include -#include - -#include -using std::min; -using std::max; - +#include "imageloader.h" #include "Ztrace.h" - -#include "DSSCommon.h" #include "BitmapExt.h" -//#include "DSSMemory.h" -#include +#include "ZExcBase.h" -#include "imageloader.h" void ThreadLoader::run() { diff --git a/DeepSkyStacker/imageloader.h b/DeepSkyStacker/imageloader.h index 1aa3dbd37..db838f217 100644 --- a/DeepSkyStacker/imageloader.h +++ b/DeepSkyStacker/imageloader.h @@ -1,9 +1,4 @@ #pragma once -#include -#include -#include -#include -#include class CMemoryBitmap; class C32BitsBitmap; diff --git a/DeepSkyStacker/matrix.h b/DeepSkyStacker/matrix.h index 8fdcee31f..5abc43656 100644 --- a/DeepSkyStacker/matrix.h +++ b/DeepSkyStacker/matrix.h @@ -104,6 +104,7 @@ # include # include #endif +#include "../ZCLass/Ztrace.h" #if defined(_MSC_VER) && _MSC_VER <= 1000 # define _NO_EXCEPTION // stdexception is not fully supported in MSVC++ 4.0 diff --git a/DeepSkyStacker/mrulist.cpp b/DeepSkyStacker/mrulist.cpp index 98febc3c0..6f9a7ea08 100644 --- a/DeepSkyStacker/mrulist.cpp +++ b/DeepSkyStacker/mrulist.cpp @@ -49,7 +49,7 @@ void MRUList::readSettings() count = settings.value(keyName, 0).toUInt(); - for (int i = 0; i < count; i++) + for (uint32_t i = 0; i < count; i++) { QString keyName = QString("%1/MRU%2") .arg(baseKeyName).arg(i); diff --git a/DeepSkyStacker/mrupath.h b/DeepSkyStacker/mrupath.h index 0582fa514..55a098e67 100644 --- a/DeepSkyStacker/mrupath.h +++ b/DeepSkyStacker/mrupath.h @@ -1,10 +1,4 @@ #pragma once -#include - -#include -#include - -namespace fs = std::filesystem; class MRUPath { diff --git a/DeepSkyStacker/picturelist.h b/DeepSkyStacker/picturelist.h index f58d55bd5..909e2eb48 100644 --- a/DeepSkyStacker/picturelist.h +++ b/DeepSkyStacker/picturelist.h @@ -1,6 +1,5 @@ #pragma once -#include #include "ui/ui_PictureList.h" namespace DSS diff --git a/DeepSkyStacker/resource.h b/DeepSkyStacker/resource.h index 76ab1dd57..73e8c3d2b 100644 --- a/DeepSkyStacker/resource.h +++ b/DeepSkyStacker/resource.h @@ -64,7 +64,7 @@ #define IDB_IMAGELIST_CFA_RGB 157 #define IDB_BITMAP4 158 #define IDB_IMAGELIST_COLOR 158 -#define IDB_BITMAP1 160 +//#define IDB_BITMAP1 160 #define IDB_IMAGELIST_MASK 160 #define IDD_DROPFILES 162 #define IDD_STACKINGINTERMEDIATE 163 diff --git a/DeepSkyStacker/resourceCZ.h b/DeepSkyStacker/resourceCZ.h index 7ccd87dae..7dfdc5eee 100644 --- a/DeepSkyStacker/resourceCZ.h +++ b/DeepSkyStacker/resourceCZ.h @@ -64,7 +64,7 @@ #define IDB_IMAGELIST_CFA_RGB 157 #define IDB_BITMAP4 158 #define IDB_IMAGELIST_COLOR 158 -#define IDB_BITMAP1 160 +//#define IDB_BITMAP1 160 #define IDB_IMAGELIST_MASK 160 #define IDD_DROPFILES 162 #define IDD_STACKINGINTERMEDIATE 163 diff --git a/DeepSkyStacker/resourceES.h b/DeepSkyStacker/resourceES.h index 9fc4e954f..a6856d33b 100644 --- a/DeepSkyStacker/resourceES.h +++ b/DeepSkyStacker/resourceES.h @@ -64,7 +64,7 @@ #define IDB_IMAGELIST_CFA_RGB 157 #define IDB_BITMAP4 158 #define IDB_IMAGELIST_COLOR 158 -#define IDB_BITMAP1 160 +//#define IDB_BITMAP1 160 #define IDB_IMAGELIST_MASK 160 #define IDD_DROPFILES 162 #define IDD_STACKINGINTERMEDIATE 163 diff --git a/DeepSkyStacker/resourceIT.h b/DeepSkyStacker/resourceIT.h index 4fb550de5..6388b121d 100644 --- a/DeepSkyStacker/resourceIT.h +++ b/DeepSkyStacker/resourceIT.h @@ -64,7 +64,7 @@ #define IDB_IMAGELIST_CFA_RGB 157 #define IDB_BITMAP4 158 #define IDB_IMAGELIST_COLOR 158 -#define IDB_BITMAP1 160 +//#define IDB_BITMAP1 160 #define IDB_IMAGELIST_MASK 160 #define IDD_DROPFILES 162 #define IDD_STACKINGINTERMEDIATE 163 diff --git a/DeepSkyStacker/selectrect.cpp b/DeepSkyStacker/selectrect.cpp index c692931bd..c542aa0cd 100644 --- a/DeepSkyStacker/selectrect.cpp +++ b/DeepSkyStacker/selectrect.cpp @@ -33,31 +33,11 @@ ** ** ****************************************************************************/ -#include -#include -#include -#include -#include - -#include -using std::min; -using std::max; - -#define _WIN32_WINNT _WIN32_WINNT_WIN7 -#include -#include -#include - -#include "ZTrace.h" - -extern bool g_bShowRefStars; - -#include "imageview.h" +#include "stdafx.h" #include "selectrect.h" -#include "DSSCommon.h" -#include "commonresource.h" -#include "DeepSkyStacker.h" +#include "imageview.h" #include "StackingDlg.h" +#include "DeepSkyStacker.h" enum class SelectionMode : quint8 { diff --git a/DeepSkyStacker/selectrect.h b/DeepSkyStacker/selectrect.h index 0b0cd00f3..297897785 100644 --- a/DeepSkyStacker/selectrect.h +++ b/DeepSkyStacker/selectrect.h @@ -36,11 +36,6 @@ ****************************************************************************/ class QMouseEvent; -#include -#include -#include -#include - enum class SelectionMode : quint8; namespace DSS diff --git a/DeepSkyStacker/toolbar.cpp b/DeepSkyStacker/toolbar.cpp index 7f07db05b..06e0fafea 100644 --- a/DeepSkyStacker/toolbar.cpp +++ b/DeepSkyStacker/toolbar.cpp @@ -34,19 +34,11 @@ ** ****************************************************************************/ #include "stdafx.h" -#include -#include -#include - -#include "FrameList.h" -#include "StackingDlg.h" -#include "editstars.h" -#include "selectrect.h" #include "toolbar.h" +#include "StackingDlg.h" +#include "ZExcBase.h" #include "SaveEditChanges.h" -#include "ZTrace.h" - namespace DSS { ToolBar::ToolBar(QWidget* parent) : diff --git a/DeepSkyStacker/toolbar.h b/DeepSkyStacker/toolbar.h index fe0a07a4d..da37afb00 100644 --- a/DeepSkyStacker/toolbar.h +++ b/DeepSkyStacker/toolbar.h @@ -34,10 +34,6 @@ ** ** ****************************************************************************/ -#include -#include -#include - class QMouseEvent; namespace DSS diff --git a/DeepSkyStackerCL/DeepSkyStackerCL.cpp b/DeepSkyStackerCL/DeepSkyStackerCL.cpp index ad4b85c57..a88c6f33c 100644 --- a/DeepSkyStackerCL/DeepSkyStackerCL.cpp +++ b/DeepSkyStackerCL/DeepSkyStackerCL.cpp @@ -2,6 +2,11 @@ // #include +#include +#include +using namespace Gdiplus; +//#pragma comment(lib, "gdiplus.lib") + #include "DeepSkyStackerCL.h" #include "QtProgressConsole.h" #include "FrameList.h" diff --git a/DeepSkyStackerCL/DeepSkyStackerCL.h b/DeepSkyStackerCL/DeepSkyStackerCL.h index 6ce93980f..219173a84 100644 --- a/DeepSkyStackerCL/DeepSkyStackerCL.h +++ b/DeepSkyStackerCL/DeepSkyStackerCL.h @@ -1,4 +1,6 @@ #pragma once +#include "DSSCommon.h" +class CMemoryBitmap; class StackingParams { diff --git a/DeepSkyStackerCL/DeepSkyStackerCL.vcxproj b/DeepSkyStackerCL/DeepSkyStackerCL.vcxproj index 6693095c5..fb0b87fd2 100644 --- a/DeepSkyStackerCL/DeepSkyStackerCL.vcxproj +++ b/DeepSkyStackerCL/DeepSkyStackerCL.vcxproj @@ -102,7 +102,7 @@ false MachineX64 - zlibstat.lib;%(AdditionalDependencies) + gdi32.lib;gdiplus.lib;zlibstat.lib;%(AdditionalDependencies) MSVCRT @@ -138,7 +138,7 @@ DSS_COMMANDLINE;%(PreprocessorDefinitions) - zlibstat.lib;%(AdditionalDependencies) + gdi32.lib;gdiplus.lib;zlibstat.lib;%(AdditionalDependencies) Console @@ -174,31 +174,42 @@ + + + + + + + + + + - NotUsing - NotUsing + Use + Use - NotUsing - NotUsing + Use + Use + @@ -207,6 +218,7 @@ + @@ -233,11 +245,16 @@ + + + + + @@ -246,16 +263,20 @@ + + + + @@ -265,6 +286,7 @@ + diff --git a/DeepSkyStackerCL/DeepSkyStackerCL.vcxproj.filters b/DeepSkyStackerCL/DeepSkyStackerCL.vcxproj.filters index 00dc49d20..d3012651d 100644 --- a/DeepSkyStackerCL/DeepSkyStackerCL.vcxproj.filters +++ b/DeepSkyStackerCL/DeepSkyStackerCL.vcxproj.filters @@ -150,6 +150,42 @@ Source Files + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel +
    @@ -293,6 +329,36 @@ Header Files + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + diff --git a/DeepSkyStackerCL/ProgressConsole.h b/DeepSkyStackerCL/ProgressConsole.h deleted file mode 100644 index ff26cbcab..000000000 --- a/DeepSkyStackerCL/ProgressConsole.h +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef _PROGRESSCONSOLE_H__ -#define _PROGRESSCONSOLE_H__ - -#include "DSSProgress.h" - -class CProgressConsole : public CDSSProgress -{ -private : - LONG m_lTotal1, - m_lTotal2; - DWORD m_dwStartTime, - m_dwLastTime; - LONG m_lLastTotal1, - m_lLastTotal2; - BOOL m_bFirstProgress; - CString m_strTitle; - CString m_strStartText; - CString m_strStart2Text; - BOOL m_bTitleDone; - BOOL m_bStartTextDone; - BOOL m_bStart2TextDone; - CString m_strLastOut; - -private : - void AnsiToOEM(CString & str) - { - CHAR szOut[2000]; - - ::CharToOem((LPCTSTR)str, szOut); - str = szOut; - }; - - void PrintText(LPCTSTR szText) - { - CString strOut = szText; - - // AnsiToOEM(strOut); - - if (strOut.GetLength() && m_strLastOut.CompareNoCase(strOut)) - { - _tprintf(_T("%s\n"), (LPCTSTR)strOut); - m_strLastOut = strOut; - }; - }; - -public : - CProgressConsole() - { - m_bTitleDone = FALSE; - m_bStartTextDone = FALSE; - m_bStart2TextDone = FALSE; - }; - virtual ~CProgressConsole() - { - Close(); - }; - - virtual void GetStartText(CString & strText) - { - strText = m_strStartText; - }; - - virtual void GetStart2Text(CString & strText) - { - strText = m_strStart2Text; - }; - - virtual void Start(LPCTSTR szTitle, LONG lTotal1, BOOL bEnableCancel = TRUE) - { - CString strTitle = szTitle; - - m_lLastTotal1 = 0; - m_lTotal1 = lTotal1; - m_dwStartTime = GetTickCount(); - m_dwLastTime = m_dwStartTime; - m_bFirstProgress = TRUE; - if (strTitle.GetLength()) - { - if (m_strTitle.CompareNoCase(szTitle)) - m_bTitleDone = FALSE; - m_strTitle = strTitle; - if (!m_bTitleDone) - { - PrintText(m_strTitle); - m_bTitleDone = TRUE; - }; - }; - }; - virtual void Progress1(LPCTSTR szText, LONG lAchieved1) - { - CString strText = szText; - DWORD dwCurrentTime = GetTickCount(); - - if (strText.GetLength()) - { - if (m_strStartText.CompareNoCase(szText)) - m_bStartTextDone = FALSE; - m_strStartText = szText; - }; - - if (m_bFirstProgress || ((double)(lAchieved1-m_lLastTotal1) > (m_lTotal1 / 100.0)) || ((dwCurrentTime - m_dwLastTime) > 1000)) - { - m_bFirstProgress = FALSE; - m_lLastTotal1 = lAchieved1; - m_dwLastTime = dwCurrentTime; - - double fAchieved =0.0; - if (m_lTotal1) - fAchieved = (double)lAchieved1/(double)m_lTotal1 * 100.0; - - // Update progress - if (!m_bStartTextDone && m_strStartText.GetLength()) - { - PrintText(m_strStartText); - m_bStartTextDone = TRUE; - }; - - printf("%.1f %% \r", fAchieved); - }; - }; - - virtual void Start2(LPCTSTR szText, LONG lTotal2) - { - CString strText = szText; - - m_lLastTotal2 = 0; - if (strText.GetLength()) - { - if (m_strStart2Text.CompareNoCase(szText)) - m_bStart2TextDone = FALSE; - - m_strStart2Text = strText; - if (!m_bStart2TextDone && m_strStart2Text.GetLength()) - { - PrintText(m_strStart2Text); - m_bStart2TextDone = TRUE; - }; - }; - - m_lTotal2 = lTotal2; - -// if (m_bJointProgress) -// Start(szText, lTotal2, FALSE); - }; - - virtual void Progress2(LPCTSTR szText, LONG lAchieved2) - { - if ((double)(lAchieved2 - m_lLastTotal2) > (m_lTotal2 / 100.0)) - { - CString strText = szText; - - m_lLastTotal2 = lAchieved2; - - if (strText.GetLength()) - { - if (m_strStart2Text.CompareNoCase(szText)) - m_bStart2TextDone = FALSE; - m_strStart2Text = strText; - }; - - double fAchieved =0.0; - if (m_lTotal2) - fAchieved = (double)lAchieved2/(double)m_lTotal2 * 100.0; - - if (!m_bStart2TextDone && m_strStart2Text.GetLength()) - { - PrintText(m_strStart2Text); - m_bStart2TextDone = TRUE; - }; - printf("%.1f %% \r", fAchieved); - }; - -// if (m_bJointProgress) -// Progress1(szText, lAchieved2); - }; - - virtual void End2() - { - // printf("\n"); - }; - - virtual bool IsCanceled() - { - return false; - }; - virtual bool Close() - { - return true; - }; -}; - -#endif // _PROGRESSCONSOLE_H__ \ No newline at end of file diff --git a/DeepSkyStackerCL/stdafx.h b/DeepSkyStackerCL/stdafx.h index 3180132d3..a1a54345d 100644 --- a/DeepSkyStackerCL/stdafx.h +++ b/DeepSkyStackerCL/stdafx.h @@ -3,21 +3,56 @@ // are changed infrequently // #pragma once +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include using std::min; using std::max; // This is for CString's in BitmapExt.h :( -#include +//#include -#include -#include -#include "BitmapExt.h" +// #include +// #include +// #include "BitmapExt.h" -// Need to get rid of these soon! +// Windows Files (eventaully to go!) +#include +#include // MFC core and standard components +#include // MFC extensions +#include // MFC support for Internet Explorer 4 Common Controls +#include +#include +#include // MFC support for Windows Common Controls +#include +#include +#include #include -using namespace Gdiplus; -#pragma comment(lib, "gdiplus.lib") \ No newline at end of file +using namespace Gdiplus; \ No newline at end of file diff --git a/DeepSkyStackerLive/DeepSkyStackerLive.cpp b/DeepSkyStackerLive/DeepSkyStackerLive.cpp index a751649b5..acb7af7a2 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLive.cpp +++ b/DeepSkyStackerLive/DeepSkyStackerLive.cpp @@ -2,30 +2,14 @@ // #include "stdafx.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -using namespace Gdiplus; - -#pragma comment(lib, "gdiplus.lib") - -#include "resource.h" - -#include "qmfcapp.h" - #include "DeepSkyStackerLive.h" #include "DeepSkyStackerLiveDlg.h" - +#include "commonresource.h" +#include "Ztrace.h" #include "SetUILanguage.h" +bool g_bShowRefStars = false; + // CDeepSkyStackerLiveApp BEGIN_MESSAGE_MAP(CDeepSkyStackerLiveApp, CWinApp) diff --git a/DeepSkyStackerLive/DeepSkyStackerLive.rc b/DeepSkyStackerLive/DeepSkyStackerLive.rc index 9ed6d9ea7..aa60a7719 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLive.rc +++ b/DeepSkyStackerLive/DeepSkyStackerLive.rc @@ -44,7 +44,7 @@ BEGIN CTEXT "Image List",IDC_IMAGELIST,231,28,76,10,NOT WS_VISIBLE | WS_BORDER CTEXT "Log",IDC_LOGLIST,307,28,76,10,NOT WS_VISIBLE | WS_BORDER PUSHBUTTON "Monitor",IDC_MONITOR,6,6,19,18,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Stack",IDC_STACK,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Stack",IDC_STACK_DSSLIVE,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stop",IDC_STOP,49,6,18,18,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Settings",IDC_WARNINGS,383,28,76,10,NOT WS_VISIBLE | WS_BORDER LTEXT "",IDC_PROGRESS,75,7,347,8,NOT WS_VISIBLE | WS_BORDER @@ -68,7 +68,7 @@ STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYS FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN LTEXT "",IDC_BACKGROUND,2,3,169,24 - LTEXT "Static",IDC_FILENAME,6,4,195,8,SS_ENDELLIPSIS + LTEXT "Static",IDC_FILENAME_DSSLIVE,6,4,195,8,SS_ENDELLIPSIS LTEXT "Copy current picture to clipboard",IDC_COPYTOCLIPBOARD,6,16,160,8 LTEXT "",IDC_PICTURE,0,29,335,137,WS_BORDER CONTROL "Gradient",IDC_GAMMA,"MFCGradientCtrl",WS_TABSTOP,206,2,127,26 @@ -95,7 +95,7 @@ BEGIN CONTROL "Sky Background",IDC_SKYBACKGROUND,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,198,3,67,10 END -IDD_SETTINGS DIALOGEX 0, 0, 393, 353 +IDD_SETTINGS_LIVE DIALOGEX 0, 0, 393, 353 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN @@ -207,7 +207,7 @@ BEGIN CTEXT "Log",IDC_LOGLIST,307,71,76,16,NOT WS_VISIBLE | WS_BORDER LTEXT "",IDC_MONITOREDFOLDER,56,7,370,8,SS_PATHELLIPSIS PUSHBUTTON "Monitor",IDC_MONITOR,21,22,35,32,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Stack",IDC_STACK,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Stack", IDC_STACK_DSSLIVE,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stop",IDC_STOP,123,22,35,32,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Settings",IDC_WARNINGS,383,71,76,16,NOT WS_VISIBLE | WS_BORDER LTEXT "Static",IDC_PROGRESS,166,24,286,22,NOT WS_VISIBLE | WS_BORDER @@ -248,7 +248,7 @@ BEGIN BOTTOMMARGIN, 104 END - IDD_SETTINGS, DIALOG + IDD_SETTINGS_LIVE, DIALOG BEGIN RIGHTMARGIN, 388 VERTGUIDE, 7 @@ -330,7 +330,7 @@ BEGIN 0 END -IDD_SETTINGS AFX_DIALOG_LAYOUT +IDD_SETTINGS_LIVE AFX_DIALOG_LAYOUT BEGIN 0 END diff --git a/DeepSkyStackerLive/DeepSkyStackerLive.vcxproj b/DeepSkyStackerLive/DeepSkyStackerLive.vcxproj index 877b7c27c..f835f5b1b 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLive.vcxproj +++ b/DeepSkyStackerLive/DeepSkyStackerLive.vcxproj @@ -101,7 +101,7 @@ false MachineX64 - htmlhelp.lib;zlibstat.lib;%(AdditionalDependencies) + gdi32.lib;gdiplus.lib;htmlhelp.lib;zlibstat.lib;%(AdditionalDependencies) NotSet MSVCRT @@ -143,7 +143,7 @@ $(IntDir);%(AdditionalIncludeDirectories) - htmlhelp.lib;zlibstat.lib;%(AdditionalDependencies) + gdi32.lib;gdiplus.lib;htmlhelp.lib;zlibstat.lib;%(AdditionalDependencies) Windows true false @@ -185,23 +185,36 @@ + + + + + + + + + + + + + @@ -211,6 +224,7 @@ + @@ -275,29 +289,42 @@ + + + + + + + + + + + + + @@ -309,6 +336,7 @@ + diff --git a/DeepSkyStackerLive/DeepSkyStackerLive.vcxproj.filters b/DeepSkyStackerLive/DeepSkyStackerLive.vcxproj.filters index 2976e2388..cad3686d3 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLive.vcxproj.filters +++ b/DeepSkyStackerLive/DeepSkyStackerLive.vcxproj.filters @@ -246,68 +246,71 @@ Kernel + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + - Source Files + Kernel - Source Files + Kernel - + Kernel - + Kernel - - Source Files + + Kernel - + Kernel - + Kernel - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Header Files @@ -527,16 +530,97 @@ Kernel - + Header Files - + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + Header Files - + Header Files - + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + + Kernel + + Kernel diff --git a/DeepSkyStackerLive/DeepSkyStackerLiveCAT.rc b/DeepSkyStackerLive/DeepSkyStackerLiveCAT.rc index d2616ffad..04d32059b 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLiveCAT.rc +++ b/DeepSkyStackerLive/DeepSkyStackerLiveCAT.rc @@ -44,7 +44,7 @@ BEGIN WS_BORDER CTEXT "Log",IDC_LOGLIST,307,28,76,10,NOT WS_VISIBLE | WS_BORDER PUSHBUTTON "Supervisar",IDC_MONITOR,6,6,19,18,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Apilar",IDC_STACK,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Apilar", IDC_STACK_DSSLIVE,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Atura",IDC_STOP,49,6,18,18,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Configuració",IDC_WARNINGS,383,28,76,10,NOT WS_VISIBLE | WS_BORDER @@ -83,7 +83,7 @@ BEGIN LTEXT "", IDC_MONITOREDFOLDER,56,7,370,8,SS_PATHELLIPSIS PUSHBUTTON "Supervisar",IDC_MONITOR,21,22,35,32,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Apilar",IDC_STACK,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Apilar", IDC_STACK_DSSLIVE,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Atura",IDC_STOP,123,22,35,32,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Configuració",IDC_WARNINGS,383,71,76,16,NOT WS_VISIBLE | WS_BORDER @@ -109,7 +109,7 @@ STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYS FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN LTEXT "",IDC_BACKGROUND,2,3,169,24 - LTEXT "Static",IDC_FILENAME,6,4,163,8,SS_ENDELLIPSIS + LTEXT "Static", IDC_FILENAME_DSSLIVE,6,4,163,8,SS_ENDELLIPSIS LTEXT "Copiar la imatge al portapapers",IDC_COPYTOCLIPBOARD,6, 16,160,8 LTEXT "",IDC_PICTURE,0,29,335,137,WS_BORDER @@ -147,7 +147,7 @@ BEGIN WS_GROUP | WS_TABSTOP,219,3,67,10 END -IDD_SETTINGS DIALOGEX 0, 0, 393, 353 +IDD_SETTINGS_LIVE DIALOGEX 0, 0, 393, 353 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN @@ -288,7 +288,7 @@ BEGIN BOTTOMMARGIN, 104 END - IDD_SETTINGS, DIALOG + IDD_SETTINGS_LIVE, DIALOG BEGIN RIGHTMARGIN, 388 VERTGUIDE, 7 diff --git a/DeepSkyStackerLive/DeepSkyStackerLiveCN.rc b/DeepSkyStackerLive/DeepSkyStackerLiveCN.rc index e8388d639411c9e55088ffb10e166a8c20367faf..f5f68d5b03bc73e87f98ce358fba524264b1f67e 100644 GIT binary patch delta 147 zcmccfmTAsArVT#?l@%B~8C)2g8R8j&8A2Ewfh=zz+XcuAX7B;Zg)z8p<`gpKAxfdI qTra0O!bCTqejf%`20x&=zCaqq+|BRRCvr2!Pj(d5+`PcprWpX;fgYOx delta 49 zcmbR9j_J-@rVT#?Cx4O@+AJev!~zz1gRlS<>9JV%Cu*NwrG!H2<>!H>a_!FRK_%4hD$ N4v7kzGYr0M005nh6&L^j diff --git a/DeepSkyStackerLive/DeepSkyStackerLiveDE.rc b/DeepSkyStackerLive/DeepSkyStackerLiveDE.rc index 41858ed88..6d200dae2 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLiveDE.rc +++ b/DeepSkyStackerLive/DeepSkyStackerLiveDE.rc @@ -43,7 +43,7 @@ BEGIN WS_BORDER CTEXT "Protokoll",IDC_LOGLIST,307,28,76,10,NOT WS_VISIBLE | WS_BORDER PUSHBUTTON "Überwachen",IDC_MONITOR,6,6,19,18,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Stacken",IDC_STACK,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Stacken", IDC_STACK_DSSLIVE,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stopp",IDC_STOP,49,6,18,18,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Einstellungen",IDC_WARNINGS,383,28,76,10,NOT WS_VISIBLE | WS_BORDER @@ -82,7 +82,7 @@ BEGIN LTEXT "", IDC_MONITOREDFOLDER,77,7,349,9,SS_PATHELLIPSIS PUSHBUTTON "Überwachen",IDC_MONITOR,21,22,35,32,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Stacken",IDC_STACK,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Stacken", IDC_STACK_DSSLIVE,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stopp",IDC_STOP,123,22,35,32,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Einstellungen",IDC_WARNINGS,383,71,76,16,NOT WS_VISIBLE | WS_BORDER @@ -108,7 +108,7 @@ STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYS FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN LTEXT "",IDC_BACKGROUND,2,3,169,24 - LTEXT "Statik",IDC_FILENAME,6,4,163,8,SS_ENDELLIPSIS + LTEXT "Statik", IDC_FILENAME_DSSLIVE,6,4,163,8,SS_ENDELLIPSIS LTEXT "Bild in die Zwischenablage kopieren",IDC_COPYTOCLIPBOARD, 6,16,160,8 LTEXT "",IDC_PICTURE,0,29,335,137,WS_BORDER @@ -146,7 +146,7 @@ BEGIN WS_GROUP | WS_TABSTOP,214,3,79,10 END -IDD_SETTINGS DIALOGEX 0, 0, 393, 333 +IDD_SETTINGS_LIVE DIALOGEX 0, 0, 393, 333 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN @@ -286,7 +286,7 @@ BEGIN BOTTOMMARGIN, 104 END - IDD_SETTINGS, DIALOG + IDD_SETTINGS_LIVE, DIALOG BEGIN RIGHTMARGIN, 388 VERTGUIDE, 7 diff --git a/DeepSkyStackerLive/DeepSkyStackerLiveDlg.cpp b/DeepSkyStackerLive/DeepSkyStackerLiveDlg.cpp index 77b1301ac..990b4d5dc 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLiveDlg.cpp +++ b/DeepSkyStackerLive/DeepSkyStackerLiveDlg.cpp @@ -2,10 +2,10 @@ // #include "stdafx.h" +#include "DeepSkyStackerLiveDlg.h" #include "resource.h" -#include #include "DeepSkyStackerLive.h" -#include "DeepSkyStackerLiveDlg.h" +#include "Workspace.h" // CDeepSkyStackerLiveDlg dialog @@ -131,7 +131,7 @@ BOOL CDeepSkyStackerLiveDlg::OnInitDialog() m_ImageList.Create(IDD_IMAGELIST, this); m_ImageList.SetToDarkMode(m_bUseDarkTheme); m_Graphs.Create(IDD_GRAPHS, this); - m_Settings.Create(IDD_SETTINGS, this); + m_Settings.Create(IDD_SETTINGS_LIVE, this); { QSettings settings; @@ -342,3 +342,239 @@ void CDeepSkyStackerLiveDlg::CallHelp() }; /* ------------------------------------------------------------------- */ + + +CDeepSkyStackerLiveDlg* GetDSSLiveDlg(CWnd* pDialog) +{ + if (pDialog) + { + CWnd* pParent = pDialog->GetParent(); + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pParent); + + return pDlg; + } + else + { + CWnd* pWnd = GetDSSLiveApp()->m_pMainWnd; + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + + return pDlg; + }; +} +void AddToLog(QString szString, BOOL bAddDateTime /* = FALSE */, BOOL bBold /* = FALSE */, BOOL bItalic /* = FALSE */, COLORREF crColor /* = RGB(0, 0, 0) */) +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetLogTab().AddToLog(szString, bAddDateTime, bBold, bItalic, crColor); + }; +} + +/* ------------------------------------------------------------------- */ + +void SetLastImage(const std::shared_ptr& pBitmap, const std::shared_ptr& pWndBitmap, LPCTSTR szFileName /* = nullptr */) +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetLastImageTab().SetImage(pBitmap, pWndBitmap, szFileName); + }; +} + +/* ------------------------------------------------------------------- */ + +void SetStackedImage(const std::shared_ptr& pBitmap, const std::shared_ptr& pWndBitmap) +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetStackedImageTab().SetImage(pBitmap, pWndBitmap, nullptr); + }; +} + +/* ------------------------------------------------------------------- */ + +void AdviseStackedImageSaved() +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetStackedImageTab().OnStackedImageSaved(); + }; +} + +/* ------------------------------------------------------------------- */ + +void AddImageToList(LPCTSTR szImage) +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetImageListTab().AddImage(szImage); + }; +} + +/* ------------------------------------------------------------------- */ + +void ChangeImageStatusInList(LPCTSTR szImage, IMAGESTATUS status) +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetImageListTab().ChangeImageStatus(szImage, status); + }; +} + +/* ------------------------------------------------------------------- */ + +void ChangeImageInfoInCharts(LPCTSTR szFileName, STACKIMAGEINFO info) +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetGraphsTab().ChangeImageInfo(szFileName, info); + }; +} + +/* ------------------------------------------------------------------- */ + +void UpdateImageOffsetsInList(LPCTSTR szImage, double fdX, double fdY, double fAngle) +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetImageListTab().UpdateImageOffsets(szImage, fdX, fdY, fAngle); + }; +} + +/* ------------------------------------------------------------------- */ + +void SetFootprintInStackedImage(QPointF const& pt1, QPointF const& pt2, QPointF const& pt3, QPointF const& pt4) +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetStackedImageTab().OnSetFootprint(pt1, pt2, pt3, pt4); + }; +} + +/* ------------------------------------------------------------------- */ + +void AddScoreFWHMStarsToGraph(LPCTSTR szFileName, double fScore, double fFWHM, double fStars, double fSkyBackground) +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetGraphsTab().AddScoreFWHMStars(szFileName, fScore, fFWHM, fStars, fSkyBackground); + }; +} + +/* ------------------------------------------------------------------- */ + +void AddOffsetsAngleToGraph(LPCTSTR szFileName, double fdX, double fdY, double fAngle) +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetGraphsTab().AddOffsetAngle(szFileName, fdX, fdY, fAngle); + }; +} + +/* ------------------------------------------------------------------- */ + +void UpdateLiveSettings() +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetMainBoard().UpdateLiveSettings(); + }; +} + +/* ------------------------------------------------------------------- */ + +void ResetEmailCount() +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetMainBoard().ResetEmailCount(); + }; +} + +/* ------------------------------------------------------------------- */ + +void PostSaveStackedImage() +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetMainBoard().PostSaveStackedImage(); + }; +} + +/* ------------------------------------------------------------------- */ + +void ShowResetEmailCountButton() +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + { + CDeepSkyStackerLiveDlg* pDlg = dynamic_cast(pWnd); + if (pDlg) + pDlg->GetSettingsTab().ShowResetEmailCountButton(); + }; +} + +/* ------------------------------------------------------------------- */ + +void FlashMainWindow() +{ + CWnd* pWnd = AfxGetApp()->GetMainWnd(); + + if (pWnd) + pWnd->FlashWindowEx(FLASHW_ALL, 4, 0); +} \ No newline at end of file diff --git a/DeepSkyStackerLive/DeepSkyStackerLiveDlg.h b/DeepSkyStackerLive/DeepSkyStackerLiveDlg.h index 065024811..75bf89044 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLiveDlg.h +++ b/DeepSkyStackerLive/DeepSkyStackerLiveDlg.h @@ -114,242 +114,20 @@ public : /* ------------------------------------------------------------------- */ -inline CDeepSkyStackerLiveDlg * GetDSSLiveDlg(CWnd * pDialog) -{ - if (pDialog) - { - CWnd * pParent = pDialog->GetParent(); - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pParent); - - return pDlg; - } - else - { - CWnd * pWnd = GetDSSLiveApp()->m_pMainWnd; - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - - return pDlg; - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void AddToLog(QString szString, BOOL bAddDateTime = FALSE, BOOL bBold = FALSE, BOOL bItalic = FALSE, COLORREF crColor = RGB(0, 0, 0)) -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetLogTab().AddToLog(szString, bAddDateTime, bBold, bItalic, crColor); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void SetLastImage(const std::shared_ptr& pBitmap, const std::shared_ptr& pWndBitmap, LPCTSTR szFileName = nullptr) -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetLastImageTab().SetImage(pBitmap, pWndBitmap, szFileName); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void SetStackedImage(const std::shared_ptr& pBitmap, const std::shared_ptr& pWndBitmap) -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetStackedImageTab().SetImage(pBitmap, pWndBitmap, nullptr); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void AdviseStackedImageSaved() -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetStackedImageTab().OnStackedImageSaved(); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void AddImageToList(LPCTSTR szImage) -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetImageListTab().AddImage(szImage); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void ChangeImageStatusInList(LPCTSTR szImage, IMAGESTATUS status) -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetImageListTab().ChangeImageStatus(szImage, status); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void ChangeImageInfoInCharts(LPCTSTR szFileName, STACKIMAGEINFO info) -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetGraphsTab().ChangeImageInfo(szFileName, info); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void UpdateImageOffsetsInList(LPCTSTR szImage, double fdX, double fdY, double fAngle) -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetImageListTab().UpdateImageOffsets(szImage, fdX, fdY, fAngle); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void SetFootprintInStackedImage(QPointF const& pt1, QPointF const& pt2, QPointF const& pt3, QPointF const& pt4) -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetStackedImageTab().OnSetFootprint(pt1, pt2, pt3, pt4); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void AddScoreFWHMStarsToGraph(LPCTSTR szFileName, double fScore, double fFWHM, double fStars, double fSkyBackground) -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetGraphsTab().AddScoreFWHMStars(szFileName, fScore, fFWHM, fStars, fSkyBackground); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void AddOffsetsAngleToGraph(LPCTSTR szFileName, double fdX, double fdY, double fAngle) -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetGraphsTab().AddOffsetAngle(szFileName, fdX, fdY, fAngle); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void UpdateLiveSettings() -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetMainBoard().UpdateLiveSettings(); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void ResetEmailCount() -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetMainBoard().ResetEmailCount(); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void PostSaveStackedImage() -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetMainBoard().PostSaveStackedImage(); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void ShowResetEmailCountButton() -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - { - CDeepSkyStackerLiveDlg * pDlg = dynamic_cast(pWnd); - if (pDlg) - pDlg->GetSettingsTab().ShowResetEmailCountButton(); - }; -}; - -/* ------------------------------------------------------------------- */ - -inline void FlashMainWindow() -{ - CWnd * pWnd = AfxGetApp()->GetMainWnd(); - - if (pWnd) - pWnd->FlashWindowEx(FLASHW_ALL, 4, 0); -}; - -/* ------------------------------------------------------------------- */ +CDeepSkyStackerLiveDlg* GetDSSLiveDlg(CWnd* pDialog); +void AddToLog(QString szString, BOOL bAddDateTime = FALSE, BOOL bBold = FALSE, BOOL bItalic = FALSE, COLORREF crColor = RGB(0, 0, 0)); +void SetLastImage(const std::shared_ptr& pBitmap, const std::shared_ptr& pWndBitmap, LPCTSTR szFileName = nullptr); +void SetStackedImage(const std::shared_ptr& pBitmap, const std::shared_ptr& pWndBitmap); +void AdviseStackedImageSaved(); +void AddImageToList(LPCTSTR szImage); +void ChangeImageStatusInList(LPCTSTR szImage, IMAGESTATUS status); +void ChangeImageInfoInCharts(LPCTSTR szFileName, STACKIMAGEINFO info); +void UpdateImageOffsetsInList(LPCTSTR szImage, double fdX, double fdY, double fAngle); +void SetFootprintInStackedImage(QPointF const& pt1, QPointF const& pt2, QPointF const& pt3, QPointF const& pt4); +void AddScoreFWHMStarsToGraph(LPCTSTR szFileName, double fScore, double fFWHM, double fStars, double fSkyBackground); +void AddOffsetsAngleToGraph(LPCTSTR szFileName, double fdX, double fdY, double fAngle); +void UpdateLiveSettings(); +void ResetEmailCount(); +void PostSaveStackedImage(); +void ShowResetEmailCountButton(); +void FlashMainWindow(); diff --git a/DeepSkyStackerLive/DeepSkyStackerLiveES.rc b/DeepSkyStackerLive/DeepSkyStackerLiveES.rc index 6f1a0778e..37a416edb 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLiveES.rc +++ b/DeepSkyStackerLive/DeepSkyStackerLiveES.rc @@ -60,7 +60,7 @@ BEGIN CTEXT "Lista de Imágenes",IDC_IMAGELIST,231,28,76,10,NOT WS_VISIBLE | WS_BORDER CTEXT "Log",IDC_LOGLIST,307,28,76,10,NOT WS_VISIBLE | WS_BORDER PUSHBUTTON "Monitorear",IDC_MONITOR,6,6,19,18,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Apilar",IDC_STACK,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Apilar", IDC_STACK_DSSLIVE,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Detener",IDC_STOP,49,6,18,18,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Configuración",IDC_WARNINGS,383,28,76,10,NOT WS_VISIBLE | WS_BORDER LTEXT "",IDC_PROGRESS,75,7,347,8,NOT WS_VISIBLE | WS_BORDER @@ -89,7 +89,7 @@ BEGIN CTEXT "Log",IDC_LOGLIST,307,71,76,16,NOT WS_VISIBLE | WS_BORDER LTEXT "",IDC_MONITOREDFOLDER,56,7,370,8,SS_PATHELLIPSIS PUSHBUTTON "Monitorear",IDC_MONITOR,21,22,35,32,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Apilar",IDC_STACK,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Apilar", IDC_STACK_DSSLIVE,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Detener",IDC_STOP,123,22,35,32,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Configuración",IDC_WARNINGS,383,71,76,16,NOT WS_VISIBLE | WS_BORDER LTEXT "Static",IDC_PROGRESS,166,24,286,22,NOT WS_VISIBLE | WS_BORDER @@ -112,7 +112,7 @@ STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYS FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN LTEXT "",IDC_BACKGROUND,2,3,169,24 - LTEXT "Static",IDC_FILENAME,6,4,163,8,SS_ENDELLIPSIS + LTEXT "Static", IDC_FILENAME_DSSLIVE,6,4,163,8,SS_ENDELLIPSIS LTEXT "Copiar la imagen al portapapeles",IDC_COPYTOCLIPBOARD,6,16,160,8 LTEXT "",IDC_PICTURE,0,29,335,137,WS_BORDER CONTROL "Gradiente",IDC_GAMMA,"MFCGradientCtrl",WS_TABSTOP,206,2,127,26 @@ -139,7 +139,7 @@ BEGIN CONTROL "Fondo del Cielo",IDC_SKYBACKGROUND,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,210,3,67,10 END -IDD_SETTINGS DIALOGEX 0, 0, 393, 333 +IDD_SETTINGS_LIVE DIALOGEX 0, 0, 393, 333 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN diff --git a/DeepSkyStackerLive/DeepSkyStackerLiveFR.rc b/DeepSkyStackerLive/DeepSkyStackerLiveFR.rc index c75b6b1f2..e1044a4a4 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLiveFR.rc +++ b/DeepSkyStackerLive/DeepSkyStackerLiveFR.rc @@ -43,7 +43,7 @@ BEGIN WS_BORDER CTEXT "Journal",IDC_LOGLIST,307,28,76,10,NOT WS_VISIBLE | WS_BORDER PUSHBUTTON "Surveiller",IDC_MONITOR,6,6,19,18,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Empiler",IDC_STACK,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Empiler", IDC_STACK_DSSLIVE,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stop",IDC_STOP,49,6,18,18,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Paramètres",IDC_WARNINGS,383,28,76,10,NOT WS_VISIBLE | WS_BORDER @@ -82,7 +82,7 @@ BEGIN LTEXT "", IDC_MONITOREDFOLDER,68,7,358,9,SS_PATHELLIPSIS PUSHBUTTON "Surveiller",IDC_MONITOR,21,22,35,32,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Empiler",IDC_STACK,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Empiler", IDC_STACK_DSSLIVE,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stop",IDC_STOP,123,22,35,32,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Paramètres",IDC_WARNINGS,383,71,76,16,NOT WS_VISIBLE | WS_BORDER @@ -108,7 +108,7 @@ STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYS FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN LTEXT "",IDC_BACKGROUND,2,3,169,24 - LTEXT "Static",IDC_FILENAME,6,4,163,8,SS_ENDELLIPSIS + LTEXT "Static", IDC_FILENAME_DSSLIVE,6,4,163,8,SS_ENDELLIPSIS LTEXT "Copier l'image dans le presse-papier",IDC_COPYTOCLIPBOARD, 6,16,160,8 LTEXT "",IDC_PICTURE,0,29,335,137,WS_BORDER @@ -146,7 +146,7 @@ BEGIN WS_GROUP | WS_TABSTOP,200,3,67,10 END -IDD_SETTINGS DIALOGEX 0, 0, 393, 333 +IDD_SETTINGS_LIVE DIALOGEX 0, 0, 393, 333 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN @@ -286,7 +286,7 @@ BEGIN BOTTOMMARGIN, 104 END - IDD_SETTINGS, DIALOG + IDD_SETTINGS_LIVE, DIALOG BEGIN RIGHTMARGIN, 388 VERTGUIDE, 7 diff --git a/DeepSkyStackerLive/DeepSkyStackerLiveIT.rc b/DeepSkyStackerLive/DeepSkyStackerLiveIT.rc index cbb14320c..6ec001220 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLiveIT.rc +++ b/DeepSkyStackerLive/DeepSkyStackerLiveIT.rc @@ -35,7 +35,7 @@ BEGIN CTEXT "Lista Immagini",IDC_IMAGELIST,231,28,76,10,NOT WS_VISIBLE | WS_BORDER CTEXT "Registro",IDC_LOGLIST,307,28,76,10,NOT WS_VISIBLE | WS_BORDER PUSHBUTTON "Controllo",IDC_MONITOR,6,6,19,18,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Combina",IDC_STACK,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Combina", IDC_STACK_DSSLIVE,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stop",IDC_STOP,49,6,18,18,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Settaggi",IDC_WARNINGS,383,28,76,10,NOT WS_VISIBLE | WS_BORDER LTEXT "",IDC_PROGRESS,75,7,347,8,NOT WS_VISIBLE | WS_BORDER @@ -64,7 +64,7 @@ BEGIN CTEXT "Registro",IDC_LOGLIST,339,70,80,17,NOT WS_VISIBLE | WS_BORDER LTEXT "",IDC_MONITOREDFOLDER,56,7,370,8,SS_PATHELLIPSIS PUSHBUTTON "Controllo",IDC_MONITOR,21,22,35,32,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Combina",IDC_STACK,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Combina", IDC_STACK_DSSLIVE,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stop",IDC_STOP,123,22,35,32,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Settaggi",IDC_WARNINGS,419,70,80,17,NOT WS_VISIBLE | WS_BORDER LTEXT "Static",IDC_PROGRESS,168,24,325,22,NOT WS_VISIBLE | WS_BORDER @@ -87,7 +87,7 @@ STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYS FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN LTEXT "",IDC_BACKGROUND,2,3,169,24 - LTEXT "Static",IDC_FILENAME,6,4,163,8,SS_ENDELLIPSIS + LTEXT "Static", IDC_FILENAME_DSSLIVE,6,4,163,8,SS_ENDELLIPSIS LTEXT "Copia l'immagine nella clipboard",IDC_COPYTOCLIPBOARD,6,16,160,8 LTEXT "",IDC_PICTURE,0,29,335,137,WS_BORDER CONTROL "Gradiente",IDC_GAMMA,"MFCGradientCtrl",WS_TABSTOP,206,2,127,26 @@ -114,7 +114,7 @@ BEGIN CONTROL "Fondo Cielo",IDC_SKYBACKGROUND,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,202,3,67,10 END -IDD_SETTINGS DIALOGEX 0, 0, 393, 333 +IDD_SETTINGS_LIVE DIALOGEX 0, 0, 393, 333 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN @@ -251,7 +251,7 @@ BEGIN BOTTOMMARGIN, 104 END - IDD_SETTINGS, DIALOG + IDD_SETTINGS_LIVE, DIALOG BEGIN RIGHTMARGIN, 388 VERTGUIDE, 7 diff --git a/DeepSkyStackerLive/DeepSkyStackerLiveNL.rc b/DeepSkyStackerLive/DeepSkyStackerLiveNL.rc index 0536cacfa..dc79598f5 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLiveNL.rc +++ b/DeepSkyStackerLive/DeepSkyStackerLiveNL.rc @@ -43,7 +43,7 @@ BEGIN WS_BORDER CTEXT "Log",IDC_LOGLIST,307,28,76,10,NOT WS_VISIBLE | WS_BORDER PUSHBUTTON "Controle",IDC_MONITOR,6,6,19,18,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Stapel",IDC_STACK,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Stapel", IDC_STACK_DSSLIVE,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stop",IDC_STOP,49,6,18,18,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Instellingen",IDC_WARNINGS,383,28,76,10,NOT WS_VISIBLE | WS_BORDER @@ -82,7 +82,7 @@ BEGIN LTEXT "",IDC_MONITOREDFOLDER, 56,7,370,8,SS_PATHELLIPSIS PUSHBUTTON "Controle",IDC_MONITOR,21,22,35,32,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Stapel",IDC_STACK,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Stapel", IDC_STACK_DSSLIVE,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stop",IDC_STOP,123,22,35,32,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Instellingen",IDC_WARNINGS,416,71,75,17,NOT WS_VISIBLE | WS_BORDER @@ -108,7 +108,7 @@ STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYS FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN LTEXT "",IDC_BACKGROUND,2,3,169,24 - LTEXT "Static",IDC_FILENAME,6,4,163,8,SS_ENDELLIPSIS + LTEXT "Static", IDC_FILENAME_DSSLIVE,6,4,163,8,SS_ENDELLIPSIS LTEXT "Kopieer huidige afbeelding naar klembord",IDC_COPYTOCLIPBOARD, 6,16,160,8 LTEXT "",IDC_PICTURE,0,29,335,137,WS_BORDER @@ -146,7 +146,7 @@ BEGIN WS_GROUP | WS_TABSTOP,206,3,74,10 END -IDD_SETTINGS DIALOGEX 0, 0, 393, 333 +IDD_SETTINGS_LIVE DIALOGEX 0, 0, 393, 333 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN @@ -287,7 +287,7 @@ BEGIN BOTTOMMARGIN, 104 END - IDD_SETTINGS, DIALOG + IDD_SETTINGS_LIVE, DIALOG BEGIN RIGHTMARGIN, 388 VERTGUIDE, 7 diff --git a/DeepSkyStackerLive/DeepSkyStackerLivePTB.rc b/DeepSkyStackerLive/DeepSkyStackerLivePTB.rc index e9d92e202..3dc3f71bd 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLivePTB.rc +++ b/DeepSkyStackerLive/DeepSkyStackerLivePTB.rc @@ -34,7 +34,7 @@ BEGIN CTEXT "Lista de Fotos",IDC_IMAGELIST,231,28,76,10,NOT WS_VISIBLE | WS_BORDER CTEXT "Log",IDC_LOGLIST,307,28,76,10,NOT WS_VISIBLE | WS_BORDER PUSHBUTTON "Monitor",IDC_MONITOR,6,6,19,18,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Integrar",IDC_STACK,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Integrar", IDC_STACK_DSSLIVE,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Parar",IDC_STOP,49,6,18,18,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Configuracoes",IDC_WARNINGS,383,28,76,10,NOT WS_VISIBLE | WS_BORDER LTEXT "",IDC_PROGRESS,75,7,347,8,NOT WS_VISIBLE | WS_BORDER @@ -58,7 +58,7 @@ STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYS FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN LTEXT "",IDC_BACKGROUND,2,3,169,24 - LTEXT "Estatico",IDC_FILENAME,6,4,195,8,SS_ENDELLIPSIS + LTEXT "Estatico", IDC_FILENAME_DSSLIVE,6,4,195,8,SS_ENDELLIPSIS LTEXT "Copia imagem para clipboard",IDC_COPYTOCLIPBOARD,6,16,160,8 LTEXT "",IDC_PICTURE,0,29,335,137,WS_BORDER CONTROL "Gradiente",IDC_GAMMA,"MFCGradientCtrl",WS_TABSTOP,206,2,127,26 @@ -85,7 +85,7 @@ BEGIN CONTROL "Sky Background",IDC_SKYBACKGROUND,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,220,3,67,10 END -IDD_SETTINGS DIALOGEX 0, 0, 393, 333 +IDD_SETTINGS_LIVE DIALOGEX 0, 0, 393, 333 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN @@ -197,7 +197,7 @@ BEGIN CTEXT "Log",IDC_LOGLIST,307,71,76,16,NOT WS_VISIBLE | WS_BORDER LTEXT "",IDC_MONITOREDFOLDER,83,7,343,8,SS_PATHELLIPSIS PUSHBUTTON "Monitor",IDC_MONITOR,21,22,35,32,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Integrar",IDC_STACK,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Integrar", IDC_STACK_DSSLIVE,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Parar",IDC_STOP,123,22,35,32,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Configuracoes",IDC_WARNINGS,383,71,76,16,NOT WS_VISIBLE | WS_BORDER LTEXT "Estatico",IDC_PROGRESS,166,24,286,22,NOT WS_VISIBLE | WS_BORDER @@ -238,7 +238,7 @@ BEGIN BOTTOMMARGIN, 104 END - IDD_SETTINGS, DIALOG + IDD_SETTINGS_LIVE, DIALOG BEGIN RIGHTMARGIN, 388 VERTGUIDE, 7 diff --git a/DeepSkyStackerLive/DeepSkyStackerLiveRO.rc b/DeepSkyStackerLive/DeepSkyStackerLiveRO.rc index d0550c7fe..cd1cfb148 100644 --- a/DeepSkyStackerLive/DeepSkyStackerLiveRO.rc +++ b/DeepSkyStackerLive/DeepSkyStackerLiveRO.rc @@ -34,7 +34,7 @@ BEGIN CTEXT "Lista imagini",IDC_IMAGELIST,231,28,76,10,NOT WS_VISIBLE | WS_BORDER CTEXT "Log",IDC_LOGLIST,307,28,76,10,NOT WS_VISIBLE | WS_BORDER PUSHBUTTON "Monitor",IDC_MONITOR,6,6,19,18,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Stack",IDC_STACK,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Stack", IDC_STACK_DSSLIVE,28,6,18,18,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stop",IDC_STOP,49,6,18,18,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Setari",IDC_WARNINGS,383,28,76,10,NOT WS_VISIBLE | WS_BORDER LTEXT "",IDC_PROGRESS,75,7,347,8,NOT WS_VISIBLE | WS_BORDER @@ -58,7 +58,7 @@ STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYS FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN LTEXT "",IDC_BACKGROUND,2,3,169,24 - LTEXT "Static",IDC_FILENAME,6,4,195,8,SS_ENDELLIPSIS + LTEXT "Static", IDC_FILENAME_DSSLIVE,6,4,195,8,SS_ENDELLIPSIS LTEXT "Copiaza imaginea curenta in clipboard",IDC_COPYTOCLIPBOARD,6,16,160,8 LTEXT "",IDC_PICTURE,0,29,335,137,WS_BORDER CONTROL "Gradient",IDC_GAMMA,"MFCGradientCtrl",WS_TABSTOP,206,2,127,26 @@ -85,7 +85,7 @@ BEGIN CONTROL "Fundal cer",IDC_SKYBACKGROUND,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,198,3,46,10 END -IDD_SETTINGS DIALOGEX 0, 0, 393, 333 +IDD_SETTINGS_LIVE DIALOGEX 0, 0, 393, 333 STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU FONT 8, "MS Shell Dlg 2", 400, 0, 0x1 BEGIN @@ -197,7 +197,7 @@ BEGIN CTEXT "Log",IDC_LOGLIST,307,71,76,16,NOT WS_VISIBLE | WS_BORDER LTEXT "",IDC_MONITOREDFOLDER,56,7,370,8,SS_PATHELLIPSIS PUSHBUTTON "Monitor",IDC_MONITOR,21,22,35,32,BS_MULTILINE | NOT WS_VISIBLE - PUSHBUTTON "Stack",IDC_STACK,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE + PUSHBUTTON "Stack", IDC_STACK_DSSLIVE,72,22,35,32,BS_MULTILINE | NOT WS_VISIBLE PUSHBUTTON "Stop",IDC_STOP,123,22,35,32,BS_MULTILINE | NOT WS_VISIBLE CTEXT "Setari",IDC_WARNINGS,383,71,76,16,NOT WS_VISIBLE | WS_BORDER LTEXT "Static",IDC_PROGRESS,166,24,286,22,NOT WS_VISIBLE | WS_BORDER diff --git a/DeepSkyStackerLive/DeepSkyStackerLiveRU.rc b/DeepSkyStackerLive/DeepSkyStackerLiveRU.rc index d31cfae1655ef99c8f30c13ae37470db985998bb..a87af44adc5eb49517fead67c0a74c0847238410 100644 GIT binary patch delta 152 zcmexziFw~;<_%AHloc2}8C)2g8R8j&8A2Ewfh=zz+XcuAX7B;Zg)z8p{>mfE#i%e@ zP+XE1MQXFU_-k&)_{q`CnwyQ3Q=Bx3FpNQm!JNTpGGl7(X05amcA)P6na-07vZOYD I%5AC!0C*}S;{X5v delta 94 zcmdmYnfc2l<_%AHCcF9aF*`GOZ)WF}@EJ9 wdvZdE!sZ0!6eo}dPM`(`9R_m-qsjWIwVSijO4uh)DYTlrAxmnrOFq+ej4tXFKcc~5>)IRMR(AOrva diff --git a/DeepSkyStackerLive/GraphView.cpp b/DeepSkyStackerLive/GraphView.cpp index 0bb77cfa0..6a19ca26b 100644 --- a/DeepSkyStackerLive/GraphView.cpp +++ b/DeepSkyStackerLive/GraphView.cpp @@ -2,10 +2,13 @@ // #include "stdafx.h" -#include "resource.h" -#include "DeepSkyStackerLive.h" -#include "DeepSkyStackerLiveDlg.h" #include "GraphView.h" +#include "ChartCtrl.h" +#include "ChartObject.h" +#include "ChartLegend.h" +#include "ChartAxis.h" +#include "ChartSerie.h" +#include "ChartPointsSerie.h" /* ------------------------------------------------------------------- */ // CGraphViewTab dialog @@ -446,3 +449,113 @@ void CGraphViewTab::ChangeImageInfo(LPCTSTR szFileName, STACKIMAGEINFO info) }; /* ------------------------------------------------------------------- */ + +BOOL CChartSeries::IsPointInSerie(double fX, double fY, CChartSerie* pSerie) +{ + BOOL bResult = FALSE; + + for (LONG i = (LONG)(pSerie->GetPointsCount()) - 1; i >= 0 && !bResult; i--) + { + if (fX == pSerie->GetXPointValue(i) && + fY == pSerie->GetYPointValue(i)) + bResult = TRUE; + }; + + return bResult; +} +void CChartSeries::Init(CChartCtrl& Chart, COLORREF crColor) +{ + m_pChart = &Chart; + + m_pMain = Chart.AddSerie(CChartSerie::stLineSerie); + m_pMain->SetVerticalAxis(false); + m_pMain->SetColor(crColor); + + m_pReference = Chart.AddSerie(CChartSerie::stPointsSerie); + m_pWarning = Chart.AddSerie(CChartSerie::stPointsSerie); + m_pOk = Chart.AddSerie(CChartSerie::stPointsSerie); + m_pWrong = Chart.AddSerie(CChartSerie::stPointsSerie); + + m_pReference->SetColor(RGB(0, 180, 0)); + m_pOk->SetColor(RGB(0, 255, 0)); + m_pWrong->SetColor(RGB(255, 0, 0)); + m_pWarning->SetColor(RGB(255, 190, 75)); + + CChartPointsSerie* pPointSerie; + + pPointSerie = dynamic_cast(m_pReference); + pPointSerie->SetVerticalAxis(false); + pPointSerie->SetPointSize(11, 11); + pPointSerie->SetPointType(CChartPointsSerie::ptRectangle); + + pPointSerie = dynamic_cast(m_pOk); + pPointSerie->SetVerticalAxis(false); + pPointSerie->SetPointSize(11, 11); + pPointSerie->SetPointType(CChartPointsSerie::ptEllipse); + + pPointSerie = dynamic_cast(m_pWrong); + pPointSerie->SetVerticalAxis(false); + pPointSerie->SetPointSize(11, 11); + pPointSerie->SetPointType(CChartPointsSerie::ptTriangle); + + pPointSerie = dynamic_cast(m_pWarning); + pPointSerie->SetVerticalAxis(false); + pPointSerie->SetPointSize(17, 17); + pPointSerie->SetPointType(CChartPointsSerie::ptEllipse); +} + +void CChartSeries::SetName(LPCTSTR szName) +{ + if (m_pMain) + m_pMain->SetName((LPCSTR)CT2CA(szName)); +} + +void CChartSeries::SetVisible(bool bShow) +{ + m_pMain->SetVisible(bShow); + m_pReference->SetVisible(bShow); + m_pOk->SetVisible(bShow); + m_pWrong->SetVisible(bShow); + m_pWarning->SetVisible(bShow); +} + +void CChartSeries::AddPoint(double fX, double fY) +{ + m_pMain->AddPoint(fX, fY); +} + +void CChartSeries::SetPoint(double fX, POINTTYPE ptType) +{ + // First search the point in the Main serie + BOOL bFound = FALSE; + double fY; + + for (LONG i = (LONG)(m_pMain->GetPointsCount()) - 1; i >= 0 && !bFound; i--) + { + if (m_pMain->GetXPointValue(i) == fX) + { + bFound = TRUE; + fY = m_pMain->GetYPointValue(i); + if (ptType == PT_REFERENCE) + { + if (!IsPointInSerie(fX, fY, m_pReference)) + m_pReference->AddPoint(fX, fY); + } + else if (ptType == PT_OK) + { + if (!IsPointInSerie(fX, fY, m_pOk)) + m_pOk->AddPoint(fX, fY); + } + else if (ptType == PT_WRONG) + { + if (!IsPointInSerie(fX, fY, m_pWrong)) + m_pWrong->AddPoint(fX, fY); + } + else if (ptType == PT_WARNING) + { + if (!IsPointInSerie(fX, fY, m_pWarning)) + m_pWarning->AddPoint(fX, fY); + }; + }; + }; +} \ No newline at end of file diff --git a/DeepSkyStackerLive/GraphView.h b/DeepSkyStackerLive/GraphView.h index 13f41b105..7e622c9a8 100644 --- a/DeepSkyStackerLive/GraphView.h +++ b/DeepSkyStackerLive/GraphView.h @@ -1,16 +1,8 @@ -#ifndef __GRAPHVIEWTAB_H__ -#define __GRAPHVIEWTAB_H__ - #pragma once - -#include "afxwin.h" -#include "label.h" -#include -#include "DSSProgress.h" -#include "DSSTools.h" -#include "BitmapExt.h" +#include "ControlPos.h" #include "ChartCtrl.h" -#include "ChartPointsSerie.h" +#include "Resource.h" +#include "LiveEngine.h" // CGraphViewTab dialog @@ -33,6 +25,7 @@ typedef enum tagCHARTTYPE CT_SKYBACKGROUND = 7 }CHARTTYPE; +class CChartCtrl; class CChartSeries { public : @@ -44,19 +37,7 @@ public : CChartSerie* m_pWarning; private : - BOOL IsPointInSerie(double fX, double fY, CChartSerie * pSerie) - { - BOOL bResult = FALSE; - - for (LONG i = (LONG)(pSerie->GetPointsCount())-1;i>=0 && !bResult;i--) - { - if (fX == pSerie->GetXPointValue(i) && - fY == pSerie->GetYPointValue(i)) - bResult = TRUE; - }; - - return bResult; - }; + BOOL IsPointInSerie(double fX, double fY, CChartSerie* pSerie); public : CChartSeries() @@ -73,102 +54,11 @@ public : { }; - void Init(CChartCtrl & Chart, COLORREF crColor) - { - m_pChart = &Chart; - - m_pMain = Chart.AddSerie(CChartSerie::stLineSerie); - m_pMain->SetVerticalAxis(false); - m_pMain->SetColor(crColor); - - m_pReference = Chart.AddSerie(CChartSerie::stPointsSerie); - m_pWarning = Chart.AddSerie(CChartSerie::stPointsSerie); - m_pOk = Chart.AddSerie(CChartSerie::stPointsSerie); - m_pWrong = Chart.AddSerie(CChartSerie::stPointsSerie); - - m_pReference->SetColor(RGB(0, 180, 0)); - m_pOk->SetColor(RGB(0, 255, 0)); - m_pWrong->SetColor(RGB(255, 0, 0)); - m_pWarning->SetColor(RGB(255, 190, 75)); - - CChartPointsSerie * pPointSerie; - - pPointSerie = dynamic_cast(m_pReference); - pPointSerie->SetVerticalAxis(false); - pPointSerie->SetPointSize(11, 11); - pPointSerie->SetPointType(CChartPointsSerie::ptRectangle); - - pPointSerie = dynamic_cast(m_pOk); - pPointSerie->SetVerticalAxis(false); - pPointSerie->SetPointSize(11, 11); - pPointSerie->SetPointType(CChartPointsSerie::ptEllipse); - - pPointSerie = dynamic_cast(m_pWrong); - pPointSerie->SetVerticalAxis(false); - pPointSerie->SetPointSize(11, 11); - pPointSerie->SetPointType(CChartPointsSerie::ptTriangle); - - pPointSerie = dynamic_cast(m_pWarning); - pPointSerie->SetVerticalAxis(false); - pPointSerie->SetPointSize(17, 17); - pPointSerie->SetPointType(CChartPointsSerie::ptEllipse); - }; - - void SetName(LPCTSTR szName) - { - if (m_pMain) - m_pMain->SetName((LPCSTR)CT2CA(szName)); - }; - - void SetVisible(bool bShow) - { - m_pMain->SetVisible(bShow); - m_pReference->SetVisible(bShow); - m_pOk->SetVisible(bShow); - m_pWrong->SetVisible(bShow); - m_pWarning->SetVisible(bShow); - }; - - void AddPoint(double fX, double fY) - { - m_pMain->AddPoint(fX, fY); - }; - - void SetPoint(double fX, POINTTYPE ptType) - { - // First search the point in the Main serie - BOOL bFound = FALSE; - double fY; - - for (LONG i = (LONG)(m_pMain->GetPointsCount())-1;i>=0 && !bFound;i--) - { - if (m_pMain->GetXPointValue(i) == fX) - { - bFound = TRUE; - fY = m_pMain->GetYPointValue(i); - if (ptType == PT_REFERENCE) - { - if (!IsPointInSerie(fX, fY, m_pReference)) - m_pReference->AddPoint(fX, fY); - } - else if (ptType == PT_OK) - { - if (!IsPointInSerie(fX, fY, m_pOk)) - m_pOk->AddPoint(fX, fY); - } - else if (ptType == PT_WRONG) - { - if (!IsPointInSerie(fX, fY, m_pWrong)) - m_pWrong->AddPoint(fX, fY); - } - else if (ptType == PT_WARNING) - { - if (!IsPointInSerie(fX, fY, m_pWarning)) - m_pWarning->AddPoint(fX, fY); - }; - }; - }; - }; + void Init(CChartCtrl& Chart, COLORREF crColor); + void SetName(LPCTSTR szName); + void SetVisible(bool bShow); + void AddPoint(double fX, double fY); + void SetPoint(double fX, POINTTYPE ptType); }; class CGraphViewTab : public CDialog @@ -230,6 +120,3 @@ public : void SetPoint(LPCTSTR szFileName, POINTTYPE ptType, CHARTTYPE ctType); void ChangeImageInfo(LPCTSTR szFileName, STACKIMAGEINFO info); }; - - -#endif diff --git a/DeepSkyStackerLive/ImageList.cpp b/DeepSkyStackerLive/ImageList.cpp index 77986b384..3a477d7cf 100644 --- a/DeepSkyStackerLive/ImageList.cpp +++ b/DeepSkyStackerLive/ImageList.cpp @@ -223,14 +223,14 @@ void CImageListTab::AddImage(LPCTSTR szImage) strText.Format(_T("%.2f"), lfi.m_fFWHM); m_ImageList.SetItemText(nItem, COLUMN_FWHM, (LPCTSTR)strText); - m_ImageList.SetItemText(nItem, COLUMN_FILETIME, bmpInfo.m_strDateTime); + m_ImageList.SetItemText(nItem, COLUMN_FILETIME, bmpInfo.m_strDateTime.toStdWString().c_str()); strText.Format(_T("%.2f %%"), lfi.m_SkyBackground.m_fLight*100.0); m_ImageList.SetItemText(nItem, COLUMN_SKYBACKGROUND, (LPCTSTR)strText); - strText = bmpInfo.m_strFileType; - if (bmpInfo.m_strModel.GetLength()) - strText += " "+bmpInfo.m_strModel; + strText = bmpInfo.m_strFileType.toStdWString().c_str(); + if (bmpInfo.m_strModel.length()) + strText += " " + CString(bmpInfo.m_strModel.toStdWString().c_str()); m_ImageList.SetItemText(nItem, COLUMN_INFO, strText); if (bmpInfo.m_CFAType == CFATYPE_NONE) diff --git a/DeepSkyStackerLive/ImageView.cpp b/DeepSkyStackerLive/ImageView.cpp index 431efd874..aae3f7fb5 100644 --- a/DeepSkyStackerLive/ImageView.cpp +++ b/DeepSkyStackerLive/ImageView.cpp @@ -2,11 +2,9 @@ // #include "stdafx.h" -#include "resource.h" -#include "DeepSkyStackerLive.h" -#include "DeepSkyStackerLiveDlg.h" #include "ImageView.h" #include "LiveSettings.h" +#include "DeepSkyStackerLiveDlg.h" /* ------------------------------------------------------------------- */ // CImageViewTab dialog @@ -32,7 +30,7 @@ CImageViewTab::~CImageViewTab() void CImageViewTab::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_FILENAME, m_FileName); + DDX_Control(pDX, IDC_FILENAME_DSSLIVE, m_FileName); DDX_Control(pDX, IDC_COPYTOCLIPBOARD, m_CopyToClipboard); DDX_Control(pDX, IDC_PICTURE, m_PictureStatic); DDX_Control(pDX, IDC_GAMMA, m_Gamma); @@ -46,7 +44,7 @@ BEGIN_MESSAGE_MAP(CImageViewTab, CDialog) ON_WM_SIZE() ON_NOTIFY(GC_PEGMOVE, IDC_GAMMA, OnChangeGamma) ON_NOTIFY(GC_PEGMOVED, IDC_GAMMA, OnChangeGamma) - ON_NOTIFY(NM_LINKCLICK, IDC_FILENAME, OnFileName) + ON_NOTIFY(NM_LINKCLICK, IDC_FILENAME_DSSLIVE, OnFileName) ON_NOTIFY(NM_LINKCLICK, IDC_COPYTOCLIPBOARD, OnCopyToClipboard) ON_BN_CLICKED(IDC_4CORNERS, OnBnClicked4corners) ON_WM_ERASEBKGND() @@ -76,7 +74,7 @@ BOOL CImageViewTab::OnInitDialog() m_Background.SetBkColor(RGB(224, 244, 252), RGB(138, 185, 242), CLabel::Gradient); m_ControlPos.AddControl(IDC_BACKGROUND, CP_RESIZE_HORIZONTAL); - m_ControlPos.AddControl(IDC_FILENAME, CP_RESIZE_HORIZONTAL); + m_ControlPos.AddControl(IDC_FILENAME_DSSLIVE, CP_RESIZE_HORIZONTAL); m_ControlPos.AddControl(IDC_PICTURE, CP_RESIZE_HORIZONTAL | CP_RESIZE_VERTICAL); m_ControlPos.AddControl(IDC_GAMMA, CP_MOVE_HORIZONTAL); m_ControlPos.AddControl(IDC_4CORNERS, CP_MOVE_HORIZONTAL); diff --git a/DeepSkyStackerLive/ImageView.h b/DeepSkyStackerLive/ImageView.h index bed00137f..b7ea6d4e6 100644 --- a/DeepSkyStackerLive/ImageView.h +++ b/DeepSkyStackerLive/ImageView.h @@ -1,22 +1,16 @@ -#ifndef __IMAGEVIEWTAB_H__ -#define __IMAGEVIEWTAB_H__ - #pragma once - -#include "afxwin.h" -#include "label.h" -#include -#include -#include -#include "DSSProgress.h" -#include "DSSTools.h" +#include "StackedSink.h" +#include "resource.h" +#include "gradientctrl.h" +#include "BtnST.h" +#include "ControlPos.h" +#include "Label.h" #include "BitmapExt.h" -#include "GradientCtrl.h" -// CImageViewTab dialog - -#include "StackedSink.h" +// CImageViewTab dialog +class C32BitsBitmap; +class CMemoryBitmap; class CImageViewTab : public CDialog { DECLARE_DYNAMIC(CImageViewTab) @@ -73,6 +67,3 @@ public : void OnSetFootprint(QPointF const& pt1, QPointF const& pt2, QPointF const& pt3, QPointF const& pt4); }; - - -#endif diff --git a/DeepSkyStackerLive/LiveEngine.cpp b/DeepSkyStackerLive/LiveEngine.cpp index 197060bce..248ccbd89 100644 --- a/DeepSkyStackerLive/LiveEngine.cpp +++ b/DeepSkyStackerLive/LiveEngine.cpp @@ -1,12 +1,10 @@ #include -#include "resource.h" #include "LiveEngine.h" -#include "RegisterEngine.h" +#include "resource.h" +#include "BitmapInfo.h" +#include "BitmapExt.h" #include "TIFFUtil.h" -#define _USE_MATH_DEFINES -#include - const DWORD WM_LE_MESSAGE = WM_USER+1; #ifndef M_PI @@ -276,17 +274,17 @@ BOOL CLiveEngine::LoadFile(LPCTSTR szFileName) if (GetPictureInfo(szFileName, bmpInfo) && bmpInfo.CanLoad()) { - CString strText; - CString strDescription; - BOOL bOverrideRAW = TRUE; + QString strText; + QString strDescription; + BOOL bOverrideRAW = TRUE; bmpInfo.GetDescription(strDescription); if (bmpInfo.m_lNrChannels==3) - strText.Format(IDS_LOADRGBLIGHT, bmpInfo.m_lBitPerChannel, (LPCTSTR)strDescription, szFileName); + strText = QCoreApplication::translate("LiveEngine", "Loading %1 bit/ch %2 light frame\n%3", "IDS_LOADRGBLIGHT").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(QString::fromWCharArray(szFileName)); else - strText.Format(IDS_LOADGRAYLIGHT, bmpInfo.m_lBitPerChannel, (LPCTSTR)strDescription, szFileName); + strText = QCoreApplication::translate("LiveEngine", "Loading %1 bits gray %2 light frame\n%3", "IDS_LOADGRAYLIGHT").arg(bmpInfo.m_lBitPerChannel).arg(strDescription).arg(QString::fromWCharArray(szFileName)); - Start2(QString::fromStdWString(strText.GetString()), 0); + Start2(strText, 0); CAllDepthBitmap adb; adb.SetDontUseAHD(TRUE); @@ -300,8 +298,8 @@ BOOL CLiveEngine::LoadFile(LPCTSTR szFileName) // Now register the image CLightFrameInfo lfi; - strText.Format(IDS_REGISTERINGNAME, (LPCTSTR)szFileName); - Start2(QString::fromStdWString(strText.GetString()), 0); + strText = QCoreApplication::translate("LiveEngine", "Registering %1", "IDS_REGISTERINGNAME").arg(QString::fromWCharArray(szFileName)); + Start2(strText, 0); lfi.SetBitmap(szFileName, FALSE, FALSE); lfi.SetProgress(this); lfi.RegisterPicture(adb.m_pBitmap.get()); @@ -319,19 +317,18 @@ BOOL CLiveEngine::LoadFile(LPCTSTR szFileName) _tsplitpath(szFileName, nullptr, nullptr, szName, szExt); strName.Format(_T("%s%s"), szName, szExt); - strText.Format(IDS_LOG_REGISTERRESULTS, (LPCTSTR)strName, lfi.m_vStars.size(), lfi.m_fFWHM, lfi.m_fOverallQuality); - PostToLog(QString::fromStdWString(strText.GetString()), true); + strText = QCoreApplication::translate("LiveEngine", "Image %1 registered: %2 star(s) detected - FWHM = %3 - Score = %4\n", "IDS_LOG_REGISTERRESULTS").arg(QString::fromWCharArray(strName).arg(lfi.m_vStars.size()).arg(lfi.m_fFWHM, 0, 'f', 2).arg(lfi.m_fOverallQuality, 0, 'f', 2)); + PostToLog(strText, true); CString strError; BOOL bWarning; CString strWarning; - bWarning = IsImageWarning1(szFileName, lfi.m_vStars.size(), lfi.m_fFWHM, lfi.m_fOverallQuality, lfi.m_SkyBackground.m_fLight*100.0, strWarning); PostChangeImageInfo(szFileName, II_DONTSTACK_NONE); if (bWarning) { - strText.Format(IDS_LOG_WARNING, (LPCTSTR)szFileName, (LPCTSTR) strWarning); - PostToLog(QString::fromStdWString(strText.GetString()), true, false, false, RGB(208, 127, 0)); + strText = QCoreApplication::translate("LiveEngine", "Warning: Image %1 -> %2\n", "IDS_LOG_WARNING").arg(QString::fromWCharArray(szFileName)).arg(QString::fromWCharArray(strWarning)); + PostToLog(strText, true, false, false, RGB(208, 127, 0)); PostWarning(strWarning); }; if (IsImageStackable1(szFileName, lfi.m_vStars.size(), lfi.m_fFWHM, lfi.m_fOverallQuality, lfi.m_SkyBackground.m_fLight*100.0, strError)) @@ -342,16 +339,16 @@ BOOL CLiveEngine::LoadFile(LPCTSTR szFileName) } else { - strText.Format(IDS_LOG_IMAGENOTSTACKABLE1, (LPCTSTR)szFileName, (LPCTSTR) strError); - PostToLog(QString::fromStdWString(strText.GetString()), true, true, false, RGB(255, 0, 0)); + strText = QCoreApplication::translate("LiveEngine", "Image %1 is not stackable (%2)\n", "IDS_LOG_IMAGENOTSTACKABLE1").arg(QString::fromWCharArray(szFileName)).arg(QString::fromWCharArray(strError)); + PostToLog(strText, true, true, false, RGB(255, 0, 0)); PostChangeImageStatus(szFileName, IS_NOTSTACKABLE); MoveImage(szFileName); }; } else { - strText.Format(IDS_LOG_ERRORLOADINGFILE, szFileName); - PostToLog(QString::fromStdWString(strText.GetString()), true, true, false, RGB(255, 0, 0)); + strText = QCoreApplication::translate("LiveEngine", "Error loading file %1\n", "IDS_LOG_ERRORLOADINGFILE").arg(QString::fromWCharArray(szFileName)); + PostToLog(strText, true, true, false, RGB(255, 0, 0)); MoveImage(szFileName); }; }; diff --git a/DeepSkyStackerLive/LiveEngine.h b/DeepSkyStackerLive/LiveEngine.h index ca4cbfea0..cd0561d5b 100644 --- a/DeepSkyStackerLive/LiveEngine.h +++ b/DeepSkyStackerLive/LiveEngine.h @@ -1,15 +1,13 @@ -#ifndef __LIVEENGINE_H__ -#define __LIVEENGINE_H__ - -#include -#include +#pragma once #include "DSSProgress.h" -#include "DSSTools.h" -#include "BitmapExt.h" #include "LiveSettings.h" #include "RegisterEngine.h" #include "RunningStackingEngine.h" +class CMemoryBitmap; +class C32BitsBitmap; +using namespace DSS; + /* ------------------------------------------------------------------- */ const DWORD WM_LIVEENGINE = WM_USER + 200; @@ -573,6 +571,3 @@ private : QString m_strLastOut[OT_MAX]; }; -/* ------------------------------------------------------------------- */ - -#endif // __LIVEENGINE_H__ diff --git a/DeepSkyStackerLive/LogTab.cpp b/DeepSkyStackerLive/LogTab.cpp index ac62cfacd..84eb30ef2 100644 --- a/DeepSkyStackerLive/LogTab.cpp +++ b/DeepSkyStackerLive/LogTab.cpp @@ -1,10 +1,6 @@ // ExplorerBar.cpp : implementation file // - #include "stdafx.h" -#include "resource.h" -#include "DeepSkyStackerLive.h" -#include "DeepSkyStackerLiveDlg.h" #include "LogTab.h" /* ------------------------------------------------------------------- */ diff --git a/DeepSkyStackerLive/LogTab.h b/DeepSkyStackerLive/LogTab.h index fa16bd7ba..db4ca143a 100644 --- a/DeepSkyStackerLive/LogTab.h +++ b/DeepSkyStackerLive/LogTab.h @@ -1,12 +1,6 @@ -#ifndef __LOGTAB_H__ -#define __LOGTAB_H__ - #pragma once - -#include "afxwin.h" -#include "label.h" -#include - +#include "resource.h" +#include "ControlPos.h" // CLogTab dialog @@ -45,5 +39,3 @@ protected : public : }; - -#endif \ No newline at end of file diff --git a/DeepSkyStackerLive/MainBoard.cpp b/DeepSkyStackerLive/MainBoard.cpp index 5a18d6a6c..6dc05c423 100644 --- a/DeepSkyStackerLive/MainBoard.cpp +++ b/DeepSkyStackerLive/MainBoard.cpp @@ -2,20 +2,12 @@ // #include "stdafx.h" -#include "resource.h" -#include - -#include "DeepSkyStackerLive.h" -#include "DeepSkyStackerLiveDlg.h" #include "MainBoard.h" -#include -#include "FolderDlg.h" -#include "RestartMonitoring.h" - -#include -#include -#include <..\SMTP\PJNSMTP.h> #include "FrameInfoSupport.h" +#include "DeepSkyStackerLiveDlg.h" +#include "RestartMonitoring.h" +#include "FolderDlg.h" +#include "PJNSMTP.h" const DWORD WM_FOLDERCHANGE = WM_USER+100; @@ -85,7 +77,7 @@ void CMainBoard::DoDataExchange(CDataExchange* pDX) DDX_Control(pDX, IDC_MONITOREDFOLDER, m_MonitoredFolder); DDX_Control(pDX, IDC_MONITOR, m_Monitor); - DDX_Control(pDX, IDC_STACK, m_Stack); + DDX_Control(pDX, IDC_STACK_DSSLIVE, m_Stack); DDX_Control(pDX, IDC_STOP, m_Stop); DDX_Control(pDX, IDC_STATS, m_Stats); } @@ -1092,9 +1084,9 @@ void CMainBoard::GetNewFilesInMonitoredFolder(std::vector & vFiles) if (bmpInfo.m_strFileType=="RAW") bAdd = m_LiveSettings.IsProcess_RAW(); - else if (bmpInfo.m_strFileType.Left(4)=="FITS") + else if (bmpInfo.m_strFileType.left(4)=="FITS") bAdd = m_LiveSettings.IsProcess_FITS(); - else if (bmpInfo.m_strFileType.Left(4)=="TIFF") + else if (bmpInfo.m_strFileType.left(4)=="TIFF") bAdd = m_LiveSettings.IsProcess_TIFF(); else bAdd = m_LiveSettings.IsProcess_Others(); @@ -1172,7 +1164,7 @@ LRESULT CMainBoard::OnFolderChange(WPARAM wParam, LPARAM lParam) vNewFiles.clear(); for (LONG i = 0;i - // CMainBoard dialog - class CMainBoard : public CDialog { DECLARE_DYNAMIC(CMainBoard) @@ -124,6 +117,3 @@ public : m_LiveEngine.PostSaveStackedImage(); }; }; - - -#endif \ No newline at end of file diff --git a/DeepSkyStackerLive/Settings.cpp b/DeepSkyStackerLive/Settings.cpp index 80f2f64ad..edc8f8d54 100644 --- a/DeepSkyStackerLive/Settings.cpp +++ b/DeepSkyStackerLive/Settings.cpp @@ -1,13 +1,10 @@ // ExplorerBar.cpp : implementation file // - #include "stdafx.h" +#include "Settings.h" #include "resource.h" -#include "DeepSkyStackerLive.h" #include "DeepSkyStackerLiveDlg.h" -#include "Settings.h" -#include "RegisterEngine.h" -#include +#include "FolderDlg.h" #include "EmailSettings.h" /* ------------------------------------------------------------------- */ diff --git a/DeepSkyStackerLive/Settings.h b/DeepSkyStackerLive/Settings.h index 035a9667d..3877f7298 100644 --- a/DeepSkyStackerLive/Settings.h +++ b/DeepSkyStackerLive/Settings.h @@ -1,17 +1,9 @@ -#ifndef __SETTINGSTAB_H__ -#define __SETTINGSTAB_H__ - #pragma once - -#include "afxwin.h" -#include "label.h" -#include -#include -#include "DSSProgress.h" -#include "DSSTools.h" -#include "BitmapExt.h" -#include "ListViewCtrlEx.h" +#include "ControlPos.h" #include "LiveSettings.h" +#include "Resource.h" +#include "Label.h" + // CSettingsTab dialog @@ -32,7 +24,7 @@ private : // Dialog Data - enum { IDD = IDD_SETTINGS }; + enum { IDD = IDD_SETTINGS_LIVE }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support @@ -119,6 +111,3 @@ public : m_Warn_ResetEmailCount.ShowWindow(SW_SHOW); }; }; - - -#endif \ No newline at end of file diff --git a/DeepSkyStackerLive/StackedSink.cpp b/DeepSkyStackerLive/StackedSink.cpp index 593849078..a37484932 100644 --- a/DeepSkyStackerLive/StackedSink.cpp +++ b/DeepSkyStackerLive/StackedSink.cpp @@ -1,12 +1,6 @@ #include -#include "resource.h" -#include -#include "BitmapExt.h" #include "StackedSink.h" - -#define _MATH_DEFINES_DEFINED -#include - +#include "resource.h" /* ------------------------------------------------------------------- */ diff --git a/DeepSkyStackerLive/StackedSink.h b/DeepSkyStackerLive/StackedSink.h index 549969864..3e4567d3b 100644 --- a/DeepSkyStackerLive/StackedSink.h +++ b/DeepSkyStackerLive/StackedSink.h @@ -3,8 +3,7 @@ /* ------------------------------------------------------------------- */ -#include "DSSProgress.h" -#include "DSSTools.h" +#include "WndImage.h" class CStackedSink : public CWndImageSink { diff --git a/DeepSkyStackerLive/resource.h b/DeepSkyStackerLive/resource.h index 996709dfd..7b31ad59f 100644 --- a/DeepSkyStackerLive/resource.h +++ b/DeepSkyStackerLive/resource.h @@ -13,11 +13,11 @@ #define IDB_HDRDOWN 131 #define IDD_IMAGELIST 131 #define IDD_GRAPHS 132 -#define IDD_SETTINGS 133 +#define IDD_SETTINGS_LIVE 133 #define IDD_RESTARTMONITORING 134 #define IDD_EMAILSETTINGS 135 #define IDD_MAINBOARDMINI 136 -#define IDB_BITMAP1 136 +//#define IDB_BITMAP1 136 #define IDB_4CORNERS 136 #define IDS_COLUMN_PATH 200 #define IDS_COLUMN_FILE 201 @@ -57,7 +57,7 @@ #define IDC_BUTTON2 1001 #define IDC_LOG 1001 #define IDC_CANCELCHANGES 1001 -#define IDC_STACK 1001 +#define IDC_STACK_DSSLIVE 1001 #define IDC_BUTTON3 1002 #define IDC_PAUSE 1002 #define IDC_PICTURE 1002 @@ -72,7 +72,7 @@ #define IDC_IMAGELIST 1009 #define IDC_LOGLIST 1010 #define IDC_WARNINGS 1011 -#define IDC_FILENAME 1012 +#define IDC_FILENAME_DSSLIVE 1012 #define IDC_GRAPH 1014 #define IDC_SCORE 1015 #define IDC_FWHM 1016 diff --git a/DeepSkyStackerLive/stdafx.h b/DeepSkyStackerLive/stdafx.h index 9fd70e1ae..d0efb74f3 100644 --- a/DeepSkyStackerLive/stdafx.h +++ b/DeepSkyStackerLive/stdafx.h @@ -1,58 +1,83 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#if !defined(AFX_STDAFX_H_) -#define AFX_STDAFX_H_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include -using std::min; -using std::max; - -// -// Want to support Windows XP and up -// -#define _WIN32_WINNT _WIN32_WINNT_WIN7 +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define _WIN32_WINNT _WIN32_WINNT_WIN7 // Want to support Windows XP and up // // Visual Leak Detector // #include +// Qt Files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Standard Libraries +#include +#include +#include +#include +#include +#include +#include +namespace fs = std::filesystem; + +using std::min; +using std::max; + +// Windows Files (eventaully to go!) #include #include // MFC core and standard components #include // MFC extensions #include // MFC support for Internet Explorer 4 Common Controls +#include #include +#include // MFC support for Windows Common Controls #include #include -#include -#include -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include - -#include - -#include -#include - -#include "DSSCommon.h" -#include "DSSMemory.h" -#include "Ztrace.h" - -//#define NOGDIPLUS -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#include - -#endif // !defined(AFX_STDAFX_H_) +#include +#include +using namespace Gdiplus; diff --git a/DeepSkyStackerTest/AvxAccumulateTest.cpp b/DeepSkyStackerTest/AvxAccumulateTest.cpp index 975198c27..4a945b564 100644 --- a/DeepSkyStackerTest/AvxAccumulateTest.cpp +++ b/DeepSkyStackerTest/AvxAccumulateTest.cpp @@ -1,5 +1,4 @@ #include "stdafx.h" -#include #include "catch.h" #include "../DeepSkyStacker/dssrect.h" @@ -10,6 +9,9 @@ #include "../DeepSkyStacker/avx_avg.h" #include "../DeepSkyStacker/TaskInfo.h" +#include "../DeepSkyStacker/EntropyInfo.h" +#include "../DeepSkyStacker/ColorBitmap.h" +#include "../DeepSkyStacker/MedianFilterEngine.h" TEST_CASE("AVX Accumulation FASTAVERAGE", "[AVX][Accumulation][FastAverage]") @@ -393,4 +395,4 @@ BACKGROUNDCALIBRATIONMODE GetBackgroundCalibrationMode() { return BCM_RGB; } BACKGROUNDCALIBRATIONINTERPOLATION GetBackgroundCalibrationInterpolation() { return BCI_RATIONAL; } RGBBACKGROUNDCALIBRATIONMETHOD GetRGBBackgroundCalibrationMethod() { return RBCM_MIDDLE; } -std::shared_ptr CColorMedianFilterEngineT::GetFilteredImage(int lFilterSize, ProgressBase* pProgress) const { return std::shared_ptr{}; } +//std::shared_ptr CColorMedianFilterEngineT::GetFilteredImage(int lFilterSize, ProgressBase* pProgress) const { return std::shared_ptr{}; } diff --git a/DeepSkyStackerTest/AvxCfaTest.cpp b/DeepSkyStackerTest/AvxCfaTest.cpp index 9e8c30a06..cc3c0d84c 100644 --- a/DeepSkyStackerTest/AvxCfaTest.cpp +++ b/DeepSkyStackerTest/AvxCfaTest.cpp @@ -1,6 +1,10 @@ #include "stdafx.h" #include "catch.h" #include "../DeepSkyStacker/avx_cfa.h" +#include "../DeepSkyStacker/GrayBitmap.h" +#include "../DeepSkyStacker/Multitask.h" +#include "../DeepSkyStacker/MultiBitmap.h" +#include "../DeepSkyStacker/MedianFilterEngine.h" TEST_CASE("AVX CFA", "[AVX][CFA]") { @@ -257,10 +261,10 @@ void CMultiBitmap::SetBitmapModel(const CMemoryBitmap*) {} bool CMultiBitmap::AddBitmap(CMemoryBitmap*, ProgressBase*) { return true; } std::shared_ptr CMultiBitmap::GetResult(ProgressBase*) { return std::shared_ptr{}; } -void CYMGToRGB(double, double, double, double, double&, double&, double&) {} +//void CYMGToRGB(double, double, double, double, double&, double&, double&) {} std::shared_ptr CreateBitmap(const CBitmapCharacteristics&) { return std::shared_ptr{}; } -std::shared_ptr CGrayMedianFilterEngineT::GetFilteredImage(int, class ProgressBase*) const { return std::shared_ptr{}; } - -std::shared_ptr CColorMedianFilterEngineT::GetFilteredImage(int, class ProgressBase*) const { return std::shared_ptr{}; } - -void CGrayBitmapT::RemoveHotPixels(class ProgressBase*) {} +// std::shared_ptr CGrayMedianFilterEngineT::GetFilteredImage(int, class ProgressBase*) const { return std::shared_ptr{}; } +// +// std::shared_ptr CColorMedianFilterEngineT::GetFilteredImage(int, class ProgressBase*) const { return std::shared_ptr{}; } +// +// void CGrayBitmapT::RemoveHotPixels(class ProgressBase*) {} diff --git a/DeepSkyStackerTest/AvxEntropyTest.cpp b/DeepSkyStackerTest/AvxEntropyTest.cpp index a98159a70..577adf54b 100644 --- a/DeepSkyStackerTest/AvxEntropyTest.cpp +++ b/DeepSkyStackerTest/AvxEntropyTest.cpp @@ -1,6 +1,9 @@ #include "stdafx.h" #include "catch.h" #include "../DeepSkyStacker/avx_entropy.h" +#include "../DeepSkyStacker/EntropyInfo.h" +#include "../DeepSkyStacker/ColorBitmap.h" +#include "../DeepSkyStacker/Multitask.h" std::tuple calcEntropy(const std::vector& incidences) { @@ -247,26 +250,26 @@ TEST_CASE("AVX Entropy", "[AVX][Entropy]") } int CMultitask::GetNrProcessors(bool) { return 1; } -void CEntropyInfo::InitSquareEntropies() -{ - const int yoff = m_lWindowSize == 10 ? 100 : 10; - const int xoff = m_lWindowSize == 10 ? 1 : 10; - m_lWindowSize = 10; - const int lSquareSize = m_lWindowSize * 2 + 1; - - m_lNrSquaresX = m_pBitmap->Width() / lSquareSize; - m_lNrSquaresY = m_pBitmap->Height() / lSquareSize; - - if (m_pBitmap->RealWidth() % lSquareSize) - m_lNrSquaresX++; - if (m_pBitmap->RealHeight() % lSquareSize) - m_lNrSquaresY++; - - m_vRedEntropies.resize(m_lNrSquaresX * m_lNrSquaresY); - m_vGreenEntropies.resize(m_lNrSquaresX * m_lNrSquaresY); - m_vBlueEntropies.resize(m_lNrSquaresX * m_lNrSquaresY); - - for (int y = 0; y < m_lNrSquaresY; ++y) - for (int x = 0; x < m_lNrSquaresX; ++x) - m_vRedEntropies[y * m_lNrSquaresX + x] = m_vGreenEntropies[y * m_lNrSquaresX + x] = m_vBlueEntropies[y * m_lNrSquaresX + x] = static_cast(y * yoff + x + xoff); -} +// void CEntropyInfo::InitSquareEntropies() +// { +// const int yoff = m_lWindowSize == 10 ? 100 : 10; +// const int xoff = m_lWindowSize == 10 ? 1 : 10; +// m_lWindowSize = 10; +// const int lSquareSize = m_lWindowSize * 2 + 1; +// +// m_lNrSquaresX = m_pBitmap->Width() / lSquareSize; +// m_lNrSquaresY = m_pBitmap->Height() / lSquareSize; +// +// if (m_pBitmap->RealWidth() % lSquareSize) +// m_lNrSquaresX++; +// if (m_pBitmap->RealHeight() % lSquareSize) +// m_lNrSquaresY++; +// +// m_vRedEntropies.resize(m_lNrSquaresX * m_lNrSquaresY); +// m_vGreenEntropies.resize(m_lNrSquaresX * m_lNrSquaresY); +// m_vBlueEntropies.resize(m_lNrSquaresX * m_lNrSquaresY); +// +// for (int y = 0; y < m_lNrSquaresY; ++y) +// for (int x = 0; x < m_lNrSquaresX; ++x) +// m_vRedEntropies[y * m_lNrSquaresX + x] = m_vGreenEntropies[y * m_lNrSquaresX + x] = m_vBlueEntropies[y * m_lNrSquaresX + x] = static_cast(y * yoff + x + xoff); +// } diff --git a/DeepSkyStackerTest/AvxHistogramTest.cpp b/DeepSkyStackerTest/AvxHistogramTest.cpp index 02bea88d2..2b7c6038b 100644 --- a/DeepSkyStackerTest/AvxHistogramTest.cpp +++ b/DeepSkyStackerTest/AvxHistogramTest.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "catch.h" #include "../DeepSkyStacker/avx_histogram.h" +#include "../DeepSkyStacker/MedianFilterEngine.h" TEST_CASE("AVX Histogram", "[AVX][Histogram]") { @@ -306,13 +307,20 @@ TEST_CASE("AVX Histogram", "[AVX][Histogram]") REQUIRE(memcmp(blueHisto.data(), expected.data(), 65536 * sizeof(int)) == 0); } } - -void CGrayBitmapT::RemoveHotPixels(class ProgressBase*) {} -std::shared_ptr CGrayMedianFilterEngineT::GetFilteredImage(int, class ProgressBase*) const { return std::shared_ptr{}; } -std::shared_ptr CColorMedianFilterEngineT::GetFilteredImage(int, class ProgressBase*) const { return std::shared_ptr{}; } - -void CGrayBitmapT::RemoveHotPixels(class ProgressBase*) {} -std::shared_ptr CGrayMedianFilterEngineT::GetFilteredImage(int, class ProgressBase*) const { return std::shared_ptr{}; } - -void CGrayBitmapT::RemoveHotPixels(class ProgressBase*) {} -std::shared_ptr CGrayMedianFilterEngineT::GetFilteredImage(int, class ProgressBase*) const { return std::shared_ptr{}; } +// +// namespace DSS { class ProgressBase; } +// void CGrayBitmapT::RemoveHotPixels(DSS::ProgressBase*) {} +// std::shared_ptr CGrayMedianFilterEngineT::GetFilteredImage(int, DSS::ProgressBase*) const { return std::shared_ptr{}; } +// std::shared_ptr CColorMedianFilterEngineT::GetFilteredImage(int, DSS::ProgressBase*) const { return std::shared_ptr{}; } +// +// void CGrayBitmapT::RemoveHotPixels(DSS::ProgressBase*) {} +// std::shared_ptr CGrayMedianFilterEngineT::GetFilteredImage(int, DSS::ProgressBase*) const { return std::shared_ptr{}; } +// std::shared_ptr CColorMedianFilterEngineT::GetFilteredImage(int, DSS::ProgressBase*) const { return std::shared_ptr{}; } +// +// void CGrayBitmapT::RemoveHotPixels(DSS::ProgressBase*) {} +// std::shared_ptr CGrayMedianFilterEngineT::GetFilteredImage(int, DSS::ProgressBase*) const { return std::shared_ptr{}; } +// std::shared_ptr CColorMedianFilterEngineT::GetFilteredImage(int, DSS::ProgressBase*) const { return std::shared_ptr{}; } +// +// void CGrayBitmapT::RemoveHotPixels(DSS::ProgressBase*) {} +// std::shared_ptr CGrayMedianFilterEngineT::GetFilteredImage(int, DSS::ProgressBase*) const { return std::shared_ptr{}; } +// std::shared_ptr CColorMedianFilterEngineT::GetFilteredImage(int, DSS::ProgressBase*) const { return std::shared_ptr{}; } diff --git a/DeepSkyStackerTest/AvxStackingTest.cpp b/DeepSkyStackerTest/AvxStackingTest.cpp index d5e6587e8..44c54747c 100644 --- a/DeepSkyStackerTest/AvxStackingTest.cpp +++ b/DeepSkyStackerTest/AvxStackingTest.cpp @@ -1,5 +1,4 @@ #include "stdafx.h" -#include #include "catch.h" #define UNIT_TESTS @@ -7,6 +6,12 @@ #include "AvxAccumulateTest.h" #include "../DeepSkyStacker/avx.h" #include "../DeepSkyStacker/avx_median.h" +#include "../DeepSkyStacker/GrayBitmap.h" +#include "../DeepSkyStacker/EntropyInfo.h" +#include "../DeepSkyStacker/TaskInfo.h" +#include "../DeepSkyStacker/PixelTransform.h" +#include "../DeepSkyStacker/avx_entropy.h" +#include "../DeepSkyStacker/BackgroundCalibration.h" TEST_CASE("AVX Stacking, no transform, no calib", "[AVX][Stacking][simple]") diff --git a/DeepSkyStackerTest/BitMapFillerTest.cpp b/DeepSkyStackerTest/BitMapFillerTest.cpp index 063986962..91490aff9 100644 --- a/DeepSkyStackerTest/BitMapFillerTest.cpp +++ b/DeepSkyStackerTest/BitMapFillerTest.cpp @@ -1,7 +1,9 @@ #include "stdafx.h" #include "catch.h" #include "../DeepSkyStacker/avx_bitmap_filler.h" -#include +#include "../DeepSkyStacker/ColorBitmap.h" +#include "../DeepSkyStacker/MedianFilterEngine.h" +#include "../DeepSkyStacker/DSSProgress.h" template void be2le(std::uint16_t(&out)[SZ], const std::uint16_t* pIn) diff --git a/DeepSkyStackerTest/DeepSkyStackerTest.vcxproj b/DeepSkyStackerTest/DeepSkyStackerTest.vcxproj index c57e61446..a27f035aa 100644 --- a/DeepSkyStackerTest/DeepSkyStackerTest.vcxproj +++ b/DeepSkyStackerTest/DeepSkyStackerTest.vcxproj @@ -117,10 +117,22 @@ + + + + + + + + + + + + @@ -138,7 +150,19 @@ + + + + + + + + + + + + diff --git a/DeepSkyStackerTest/DeepSkyStackerTest.vcxproj.filters b/DeepSkyStackerTest/DeepSkyStackerTest.vcxproj.filters index 47d88d36e..708c0962a 100644 --- a/DeepSkyStackerTest/DeepSkyStackerTest.vcxproj.filters +++ b/DeepSkyStackerTest/DeepSkyStackerTest.vcxproj.filters @@ -78,6 +78,42 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -92,5 +128,41 @@ Header Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + \ No newline at end of file diff --git a/DeepSkyStackerTest/OpenMpTest.cpp b/DeepSkyStackerTest/OpenMpTest.cpp index d9c7b328e..dcb5c1077 100644 --- a/DeepSkyStackerTest/OpenMpTest.cpp +++ b/DeepSkyStackerTest/OpenMpTest.cpp @@ -1,7 +1,9 @@ #include "stdafx.h" #include "catch.h" #include "../DeepSkyStacker/avx_bitmap_filler.h" -#include +#include "../DeepSkyStacker/GrayBitmap.h" +#include "../DeepSkyStacker/BitMapFiller.h" +#include "../DeepSkyStacker/MedianFilterEngine.h" TEST_CASE("OpenMP parallelization", "[OpenMP]") { diff --git a/DeepSkyStackerTest/PixelIteratorTest.cpp b/DeepSkyStackerTest/PixelIteratorTest.cpp index a58355bfa..b09728a8b 100644 --- a/DeepSkyStackerTest/PixelIteratorTest.cpp +++ b/DeepSkyStackerTest/PixelIteratorTest.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "catch.h" #include "../DeepSkyStacker/BitmapIterator.h" -#include +#include "../DeepSkyStacker/ColorBitmap.h" TEST_CASE("Gray Pixel Iterator", "[GrayPixelIterator]") diff --git a/DeepSkyStackerTest/stdafx.h b/DeepSkyStackerTest/stdafx.h index fefbb941b..c896908bc 100644 --- a/DeepSkyStackerTest/stdafx.h +++ b/DeepSkyStackerTest/stdafx.h @@ -1,10 +1,34 @@ #pragma once +#define NOMINMAX -#include -#include -#include +// Qt +#include #include #include +#include + +// Std +#include +#include +#include +#include +#include +#include +#include +#include + +using std::min; +using std::max; + +// Other (should it be in here? Maybe!) +#include + #include "../ZCLass/zdefs.h" #include "../ZCLass/Ztrace.h" #include "../ZCLass/zexcept.h" + + +// Windows (to go!) +#include +#include +#include \ No newline at end of file diff --git a/SMTP/resource.h b/SMTP/resource.h index 325b66a30..29d28522f 100644 --- a/SMTP/resource.h +++ b/SMTP/resource.h @@ -5,7 +5,7 @@ #define IDD_MAIN_DIALOG 102 #define IDR_MAINFRAME 128 #define IDD_CONFIGURATION 129 -#define IDD_PROGRESS 130 +//#define IDD_PROGRESS 130 #define IDS_PJNSMTP_UNEXPECTED_SMTP_LOGIN_RESPONSE 512 #define IDS_PJNSMTP_UNEXPECTED_EHLO_RESPONSE 516 #define IDS_PJNSMTP_UNEXPECTED_HELO_RESPONSE 517 diff --git a/Tools/ButtonToolbar.cpp b/Tools/ButtonToolbar.cpp index a4a470687..63f530888 100644 --- a/Tools/ButtonToolbar.cpp +++ b/Tools/ButtonToolbar.cpp @@ -13,9 +13,9 @@ Bitmap * GetBitmapFromIcon(int nBitmap, int nMask) Bitmap bmpMask(hMask, nullptr); pResult = bmp.Clone(0, 0, BUTTONTOOLBARSIZE, BUTTONTOOLBARSIZE, PixelFormat32bppARGB); - for (LONG i = 0;i -using namespace Gdiplus; - const LONG BUTTONTOOLBARSIZE = 48; /* ------------------------------------------------------------------- */ diff --git a/Tools/ControlPos.cpp b/Tools/ControlPos.cpp index 876c20ce9..685c00e18 100644 --- a/Tools/ControlPos.cpp +++ b/Tools/ControlPos.cpp @@ -10,7 +10,7 @@ // -------- ---------- ---- --------------------- // 1.01 07/11/2000 PRW Original creation. // -#include "StdAfx.h" +#include "stdafx.h" #include "ControlPos.h" #include diff --git a/Tools/CtrlCache.h b/Tools/CtrlCache.h index f3f3f1c69..b9cb628df 100644 --- a/Tools/CtrlCache.h +++ b/Tools/CtrlCache.h @@ -1,5 +1,5 @@ #pragma once -#include +#include class CWnd; class CCtrlCache diff --git a/Tools/Gradient.h b/Tools/Gradient.h index 30a3623f9..2073ffa32 100644 --- a/Tools/Gradient.h +++ b/Tools/Gradient.h @@ -1,15 +1,7 @@ // Gradient.h: interface for the CGradient class. // ////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_GRADIENT_H__B8518180_B289_11D4_A890_C3D6794EED5F__INCLUDED_) -#define AFX_GRADIENT_H__B8518180_B289_11D4_A890_C3D6794EED5F__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 - -#include class CPeg { @@ -168,5 +160,3 @@ class CGradient : public CObject int m_Quantization; InterpolationMethod m_InterpolationMethod; }; - -#endif // !defined(AFX_GRADIENT_H__B8518180_B289_11D4_A890_C3D6794EED5F__INCLUDED_) diff --git a/Tools/GradientCtrl.cpp b/Tools/GradientCtrl.cpp index 4a83216bd..b8cf2861e 100644 --- a/Tools/GradientCtrl.cpp +++ b/Tools/GradientCtrl.cpp @@ -1,6 +1,5 @@ // GradientCtrl.cpp : implementation file // - #include "stdafx.h" #include "GradientCtrl.h" #include "GradientCtrlImpl.h" diff --git a/Tools/Label.h b/Tools/Label.h index 1436fe7f3..7411b22d8 100644 --- a/Tools/Label.h +++ b/Tools/Label.h @@ -1,11 +1,4 @@ -#if !defined(AFX_LABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_) -#define AFX_LABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 -// Label.h : header file -// #define NM_LINKCLICK WM_APP + 0x200 @@ -107,10 +100,3 @@ class CLabel : public CStatic DECLARE_MESSAGE_MAP() }; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_LABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_) diff --git a/Tools/WndImage.cpp b/Tools/WndImage.cpp index 5988a5bbe..f9e69d8f9 100644 --- a/Tools/WndImage.cpp +++ b/Tools/WndImage.cpp @@ -140,9 +140,6 @@ END_MESSAGE_MAP() // OnPaint // ------------------------------------------------------------------ -#include -using namespace Gdiplus; - static Bitmap * GetBitmap(CRect & rcOut, HBITMAP hBitmap, CRect & rcSrc, CRect & rcDst, BOOL bInterpolate, Bitmap * pInBitmap = nullptr, bool bDarkMode=false) { Bitmap * pBitmap = new Bitmap(hBitmap, nullptr); diff --git a/Tools/WndImage.h b/Tools/WndImage.h index 169c1292c..640eb82bd 100644 --- a/Tools/WndImage.h +++ b/Tools/WndImage.h @@ -24,6 +24,7 @@ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 +#include #include "ButtonToolbar.h" diff --git a/Tools/cdxCRot90DC.cpp b/Tools/cdxCRot90DC.cpp index 011d650a2..040ea3b89 100644 --- a/Tools/cdxCRot90DC.cpp +++ b/Tools/cdxCRot90DC.cpp @@ -4,6 +4,7 @@ #include "stdafx.h" #include "cdxCRot90DC.h" +#include "Ztrace.h" ////////////////////////////////////////////////////////////////////// // cdxCRot90DC diff --git a/Tools/cdxCRotBevelLine.cpp b/Tools/cdxCRotBevelLine.cpp index 3fc72c4a4..8e63eb827 100644 --- a/Tools/cdxCRotBevelLine.cpp +++ b/Tools/cdxCRotBevelLine.cpp @@ -3,7 +3,7 @@ #include "stdafx.h" #include "cdxCRotBevelLine.h" -#include "cdxCRot90DC.h" +#include "cdxCRot90DC.h" ///////////////////////////////////////////////////////////////////////////// // cdxCRotBevelLine diff --git a/Tools/childprop.cpp b/Tools/childprop.cpp index c0739a0d4..3a80385a9 100644 --- a/Tools/childprop.cpp +++ b/Tools/childprop.cpp @@ -1,6 +1,5 @@ // childprop.cpp : implementation file // - #include #include "childprop.h" diff --git a/Tools/childprop.h b/Tools/childprop.h index fb4e0fa54..831a910c5 100644 --- a/Tools/childprop.h +++ b/Tools/childprop.h @@ -1,16 +1,4 @@ -#if !defined(AFX_CHILDPROP_H__INCLUDED_) -#define AFX_CHILDPROP_H__INCLUDED_ - -// childprop.h : header file -// - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 - -#include -#include -#include ///////////////////////////////////////////////////////////////////////////// // CChildPropertyPage @@ -50,5 +38,3 @@ class CChildPropertyPage : public CPropertyPage UINT m_nIDGroup; CArray m_arrPages; }; - -#endif // !defined(AFX_CHILDPROP_H__INCLUDED_) diff --git a/Tools/gradientctrl.h b/Tools/gradientctrl.h index 38420afe3..646533c48 100644 --- a/Tools/gradientctrl.h +++ b/Tools/gradientctrl.h @@ -1,12 +1,4 @@ -#if !defined(AFX_GRADIENTCTRL_H__BA457C5B_AA8B_4E1F_8399_57B9E3C1A406__INCLUDED_) -#define AFX_GRADIENTCTRL_H__BA457C5B_AA8B_4E1F_8399_57B9E3C1A406__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 -// GradientCtrl.h : header file -// - #include "Gradient.h" #define GCW_AUTO -1 @@ -132,10 +124,3 @@ class CGradientCtrl : public CWnd //}}AFX_MSG DECLARE_MESSAGE_MAP() }; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_GRADIENTCTRL_H__BA457C5B_AA8B_4E1F_8399_57B9E3C1A406__INCLUDED_)