1 //     ____   ______ __
2 //    / __ \ / ____// /
3 //   / /_/ // /    / /
4 //  / ____// /___ / /___   PixInsight Class Library
5 // /_/     \____//_____/   PCL 2.1.19
6 // ----------------------------------------------------------------------------
7 // Standard RAW_compat File Format Module Version 1.5.3
8 // ----------------------------------------------------------------------------
9 // RawInstance.h - Released 2020-01-14T11:57:23Z
10 // ----------------------------------------------------------------------------
11 // This file is part of the standard RAW_compat PixInsight module.
12 //
13 // Copyright (c) 2003-2020 Pleiades Astrophoto S.L. All Rights Reserved.
14 //
15 // Redistribution and use in both source and binary forms, with or without
16 // modification, is permitted provided that the following conditions are met:
17 //
18 // 1. All redistributions of source code must retain the above copyright
19 //    notice, this list of conditions and the following disclaimer.
20 //
21 // 2. All redistributions in binary form must reproduce the above copyright
22 //    notice, this list of conditions and the following disclaimer in the
23 //    documentation and/or other materials provided with the distribution.
24 //
25 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
26 //    of their contributors, may be used to endorse or promote products derived
27 //    from this software without specific prior written permission. For written
28 //    permission, please contact info@pixinsight.com.
29 //
30 // 4. All products derived from this software, in any form whatsoever, must
31 //    reproduce the following acknowledgment in the end-user documentation
32 //    and/or other materials provided with the product:
33 //
34 //    "This product is based on software from the PixInsight project, developed
35 //    by Pleiades Astrophoto and its contributors (http://pixinsight.com/)."
36 //
37 //    Alternatively, if that is where third-party acknowledgments normally
38 //    appear, this acknowledgment must be reproduced in the product itself.
39 //
40 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
41 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
42 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
44 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
46 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
47 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
48 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
50 // POSSIBILITY OF SUCH DAMAGE.
51 // ----------------------------------------------------------------------------
52 
53 #ifndef __RawInstance_h
54 #define __RawInstance_h
55 
56 #include <pcl/FileFormatImplementation.h>
57 
58 #include "RawPreferences.h"
59 
60 class LibRaw;
61 
62 #define RAW_DEFAULT_VERBOSITY 2
63 
64 namespace pcl
65 {
66 
67 // ----------------------------------------------------------------------------
68 
69 class RawFormat;
70 class RawProgress;
71 
72 class RawInstance : public FileFormatImplementation
73 {
74 public:
75 
76    RawInstance( const RawFormat* );
77 
78    virtual ~RawInstance() noexcept( false );
79 
80    ImageDescriptionArray Open( const String& filePath, const IsoString& hints ) override;
81    bool IsOpen() const override;
82    String FilePath() const override;
83    void Close() override;
84 
85    String ImageFormatInfo() const override;
86 
87    ICCProfile ReadICCProfile() override;
88 
89    // We synthesize critical FITS keywords: TIME-OBS, EXPTIME, FOCALLEN, APTDIA
90    FITSKeywordArray ReadFITSKeywords() override;
91 
92    PropertyDescriptionArray ImagePropertyDescriptions() override;
93    Variant ReadImageProperty( const IsoString& property ) override;
94 
95    void ReadImage( Image& ) override;
96    void ReadImage( DImage& ) override;
97    void ReadImage( UInt8Image& ) override;
98    void ReadImage( UInt16Image& ) override;
99    void ReadImage( UInt32Image& ) override;
100 
101    UInt8Image ReadThumbnail() override;
102 
103 private:
104 
105    RawPreferences           m_preferences;
106    int                      m_verbosity = RAW_DEFAULT_VERBOSITY;
107    String                   m_filePath;
108    AutoPointer<LibRaw>      m_raw;
109    AutoPointer<RawProgress> m_progress;
110 
111    String                   m_description;
112    String                   m_author;
113    IsoString                m_cameraManufacturer;
114    IsoString                m_cameraModel;
115    IsoString                m_cfaPattern;
116    IsoString                m_rawCFAPattern;
117    IsoString                m_cfaPatternName;
118    F32Matrix                m_sRGBConversionMatrix;
119    TimePoint                m_timestamp;
120    float                    m_exposure = 0;
121    int                      m_isoSpeed = 0;
122    float                    m_focalLength = 0;
123    float                    m_aperture = 0;
124 
125    String ExposureAsText() const;
126 
127    void CheckOpenStream( const String& ) const;
128 
129    static void CheckLibRawReturnCode( int );
130 
131    friend class RawReadHints;
132    friend class RawProgress;
133    friend class RawImageReader;
134 };
135 
136 // ----------------------------------------------------------------------------
137 
138 } // pcl
139 
140 #endif   // __RawInstance_h
141 
142 // ----------------------------------------------------------------------------
143 // EOF RawInstance.h - Released 2020-01-14T11:57:23Z
144