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 // RawFormat.cpp - 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 #include "RawFormat.h"
54 #include "RawInstance.h"
55 #include "RawPreferencesDialog.h"
56 
57 namespace pcl
58 {
59 
60 // ----------------------------------------------------------------------------
61 
Name() const62 IsoString RawFormat::Name() const
63 {
64    return "RAW_compat";
65 }
66 
67 // ----------------------------------------------------------------------------
68 
FileExtensions() const69 StringList RawFormat::FileExtensions() const
70 {
71    return StringList() << ".3fr"  // Hasselblad
72                        << ".ari"  // ARRIFLEX ARRIRAW format
73                        << ".arw"  // Sony RAW file
74                        << ".bay"  // Casio
75                        << ".crw"  // Canon photo RAW
76                        << ".cr2"  // Canon photo RAW
77                        << ".cap"  // Phase_One
78                        << ".dcs"  // Kodak Photo RAW
79                        << ".dcr"  // Kodak Photo RAW
80                        << ".dng"  // Adobe Digital Negative
81                        << ".drf"  // Kodak Photo RAW
82                        << ".eip"  // Phase_One
83                        << ".erf"  // Epson
84                        << ".fff"  // Imacon/Hasselblad RAW
85                        << ".iiq"  // Phase_One
86                        << ".k25"  // Kodak Photo RAW
87                        << ".kdc"  // Kodak Photo RAW
88                        << ".mdc"  // Minolta / Agfa
89                        << ".mef"  // Mamiya photo RAW
90                        << ".mos"  // CREO Photo RAW
91                        << ".mrw"  // Minolta/Konica photo RAW
92                        << ".nef"  // Nikon Electronic format
93                        << ".nrw"  // Nikon Electronic format
94                        << ".obm"  // Olympus Raw File
95                        << ".orf"  // Olympus Raw File
96                        << ".pef"  // Pentax photo RAW
97                        << ".ptx"  // Pentax photo RAW
98                        << ".pxn"  // Logitech Fotoman Pixtura
99                        << ".r3d"  // RED
100                        << ".raf"  // FUJI photo RAW
101                        << ".raw"  // Leica / Panasonic photo RAW
102                        << ".rwl"  // Leica
103                        << ".rw2"  // Panasonic photo RAW
104                        << ".rwz"  // Rawzor
105                        << ".sr2"  // Sony RAW file
106                        << ".srf"  // Sony RAW file
107                        << ".srw"  // Samsung
108                        << ".x3f"; // Sigma
109 }
110 
111 // ----------------------------------------------------------------------------
112 
Version() const113 uint32 RawFormat::Version() const
114 {
115    return 0x105;
116 }
117 
118 // ----------------------------------------------------------------------------
119 
Description() const120 String RawFormat::Description() const
121 {
122    return "Digital camera raw file format decoder based on LibRaw (compatibility version)";
123 }
124 
125 // ----------------------------------------------------------------------------
126 
Implementation() const127 String RawFormat::Implementation() const
128 {
129    return
130 
131    "<html>"
132    "<p>PixInsight Standard File Format Support Modules.</p>"
133 
134    "<p>This implementation of digital camera raw format decoding uses LibRaw version 0.19.5.</p>"
135 
136    "<p>LibRaw library:<br/>"
137    "Copyright (c) 2008-2020 LibRaw LLC (info@libraw.org)<br/>"
138    "The LibRaw library includes source code from:</p>"
139 
140    "<p>dcraw.c, Dave Coffin's raw photo decoder. Copyright (c) 1997-2016 by Dave Coffin</p>"
141 
142    "<p>PixInsight Class Library (PCL):<br/>"
143    "Copyright (c) 2003-2020 Pleiades Astrophoto</p>"
144 
145    "<p style=\"white-space:pre;\">"
146 "\n-------------------------------------------------------------------------------"
147 "\nRAW Format Hints              Description"
148 "\n============================  ================================================="
149 "\nraw                     (r )  Load a raw Bayer RGB image without interpolation,"
150 "\n                              no white balancing, no black point correction,"
151 "\n                              with unused frame areas cropped, no frame"
152 "\n                              rotation, no highlights clipping, and no noise"
153 "\n                              reduction."
154 "\n-------------------------------------------------------------------------------"
155 "\ncfa                     (r )  Load a monochrome raw CFA frame."
156 "\n-------------------------------------------------------------------------------"
157 "\nno-cfa                  (r )  Do not load a monochrome raw CFA frame."
158 "\n-------------------------------------------------------------------------------"
159 "\nbayer-drizzle           (r )  Load a raw Bayer RGB image without interpolation."
160 "\n-------------------------------------------------------------------------------"
161 "\nno-bayer-drizzle        (r )  Do not load a raw Bayer RGB image."
162 "\n-------------------------------------------------------------------------------"
163 "\nsuper-pixels            (r )  Use super-pixel interpolation. The image will"
164 "\n                              have 1/2 of its nominal dimensions. Only valid"
165 "\n                              for 2x2 Bayer CFA filters; ignored for X-Trans"
166 "\n                              sensors."
167 "\n-------------------------------------------------------------------------------"
168 "\nno-super-pixels         (r )  Do not use super-pixel interpolation."
169 "\n-------------------------------------------------------------------------------"
170 "\nrgb                     (r )  Load an RGB image with VNG interpolation, camera"
171 "\n                              white balance applied, black point correction"
172 "\n                              applied, automatic frame rotation applied, unused"
173 "\n                              frame areas cropped, and no noise reduction."
174 "\n-------------------------------------------------------------------------------"
175 "\npreview                 (r )  Load a half-size interpolated image suitable for"
176 "\n                              thumbnail previews."
177 "\n-------------------------------------------------------------------------------"
178 "\nbilinear                (r )  Use bilinear interpolation."
179 "\n-------------------------------------------------------------------------------"
180 "\nfast                    (r )  Use bilinear interpolation (same as bilinear)."
181 "\n-------------------------------------------------------------------------------"
182 "\nvng                     (r )  Use VNG interpolation."
183 "\n-------------------------------------------------------------------------------"
184 "\nppg                     (r )  Use PPG interpolation."
185 "\n-------------------------------------------------------------------------------"
186 "\nahd                     (r )  Use AHD interpolation."
187 "\n-------------------------------------------------------------------------------"
188 "\ndcb                     (r )  Use DCB interpolation."
189 "\n-------------------------------------------------------------------------------"
190 "\ndcb-iterations n        (r )  Apply n iterations of DCB interpolation, with n"
191 "\n                              in the range [1,5]."
192 "\n-------------------------------------------------------------------------------"
193 "\ndcb-refinement          (r )  Enable a refinement step for DCB interpolation."
194 "\n-------------------------------------------------------------------------------"
195 "\nno-dcb-refinement       (r )  Disable a refinement step for DCB interpolation."
196 "\n-------------------------------------------------------------------------------"
197 "\nhalf-size               (r )  Use half-size interpolation. 2x faster than"
198 "\n                              bilinear, the image will have 1/2 of its nominal"
199 "\n                              dimensions."
200 "\n-------------------------------------------------------------------------------"
201 "\ninterpolate-as-4-colors (r )  Interpolate RGGB as four colors."
202 "\n-------------------------------------------------------------------------------"
203 "\nno-interpolate-as-4-colors"
204 "\n                        (r )  Do not interpolate RGGB as four colors."
205 "\n-------------------------------------------------------------------------------"
206 "\nauto-white-balance      (r )  Calculate white balancing factors by averaging"
207 "\n                              the entire image."
208 "\n-------------------------------------------------------------------------------"
209 "\nno-auto-white-balance   (r )  Do not apply an automatic white balance."
210 "\n-------------------------------------------------------------------------------"
211 "\ncamera-white-balance    (r )  Use the white balance specified by the camera,"
212 "\n                              when available."
213 "\n-------------------------------------------------------------------------------"
214 "\nno-camera-white-balance (r )  Do not apply a camera white balance."
215 "\n-------------------------------------------------------------------------------"
216 "\nno-white-balance        (r )  Do not apply any white balance."
217 "\n-------------------------------------------------------------------------------"
218 "\ndaylight-white-balance  (r )  Apply daylight white balance factors."
219 "\n-------------------------------------------------------------------------------"
220 "\nauto-flip               (r )  Apply an automatic frame rotation based on"
221 "\n                              existing metadata."
222 "\n-------------------------------------------------------------------------------"
223 "\nno-auto-flip            (r )  Do not rotate frames."
224 "\n-------------------------------------------------------------------------------"
225 "\nauto-crop               (r )  Crop unused frame regions automatically."
226 "\n-------------------------------------------------------------------------------"
227 "\nno-auto-crop            (r )  Do not crop unused frame regions."
228 "\n-------------------------------------------------------------------------------"
229 "\nblack-point-correction  (r )  Apply a black point correction to remove darkness"
230 "\n                              level pedestals."
231 "\n-------------------------------------------------------------------------------"
232 "\nno-black-point-correction"
233 "\n                        (r )  Do not apply black point correction."
234 "\n-------------------------------------------------------------------------------"
235 "\nclip-highlights         (r )  Clip the highlights to solid white."
236 "\n-------------------------------------------------------------------------------"
237 "\nno-clip-highlights      (r )  Leave the highlights unclipped, resulting in"
238 "\n                              various shades of pink."
239 "\n-------------------------------------------------------------------------------"
240 "\nwavelet-noise-threshold n"
241 "\n                        (r )  Apply a wavelet-based noise reduction with"
242 "\n                              threshold n in the range [0,2000]."
243 "\n-------------------------------------------------------------------------------"
244 "\nno-wavelet-noise-reduction"
245 "\n                        (r )  Do not apply a wavelet-based noise reduction."
246 "\n-------------------------------------------------------------------------------"
247 "\nfbdd-noise-threshold n  (r )  Apply FBDD noise reduction with quality n in the"
248 "\n                              range [0,2], where 0=disabled, 1=normal, 2=high."
249 "\n-------------------------------------------------------------------------------"
250 "\nno-fbdd-noise-reduction (r )  Disable the FBDD noise reduction algorithm."
251 "\n-------------------------------------------------------------------------------"
252 "\nverbosity n             (r )  n is a verbosity level in the range [0,3] to"
253 "\n                              control the amount of generated messages"
254 "\n                              (default = 2)."
255 "\n-------------------------------------------------------------------------------"
256 "\n"
257    "</p>"
258    "</html>";
259 }
260 
261 // ----------------------------------------------------------------------------
262 
IconImageSVGFile() const263 String RawFormat::IconImageSVGFile() const
264 {
265    return "@module_icons_dir/RAW.svg";
266 }
267 
268 // ----------------------------------------------------------------------------
269 
CanWrite() const270 bool RawFormat::CanWrite() const
271 {
272    return false;
273 }
274 
275 // ----------------------------------------------------------------------------
276 
CanStore8Bit() const277 bool RawFormat::CanStore8Bit() const
278 {
279    return false;
280 }
281 
282 // ----------------------------------------------------------------------------
283 
CanStoreAlphaChannels() const284 bool RawFormat::CanStoreAlphaChannels() const
285 {
286    return false;
287 }
288 
289 // ----------------------------------------------------------------------------
290 
CanStoreResolution() const291 bool RawFormat::CanStoreResolution() const
292 {
293    return true;
294 }
295 
296 // ----------------------------------------------------------------------------
297 
CanStoreKeywords() const298 bool RawFormat::CanStoreKeywords() const
299 {
300    // We simulate some standard FITS header keywords from EXIF medatata:
301    // DATE-OBS, EXPTIME, FOCALLEN, APTDIA
302    return true;
303 }
304 
305 // ----------------------------------------------------------------------------
306 
CanStoreICCProfiles() const307 bool RawFormat::CanStoreICCProfiles() const
308 {
309    return true;
310 }
311 
312 // ----------------------------------------------------------------------------
313 
CanStoreThumbnails() const314 bool RawFormat::CanStoreThumbnails() const
315 {
316    return true;
317 }
318 
319 // ----------------------------------------------------------------------------
320 
CanStoreImageProperties() const321 bool RawFormat::CanStoreImageProperties() const
322 {
323    return true;
324 }
325 
326 // ----------------------------------------------------------------------------
327 
SupportsViewProperties() const328 bool RawFormat::SupportsViewProperties() const
329 {
330    return true;
331 }
332 
333 // ----------------------------------------------------------------------------
334 
CanEditPreferences() const335 bool RawFormat::CanEditPreferences() const
336 {
337    return true;
338 }
339 
340 // ----------------------------------------------------------------------------
341 
Create() const342 FileFormatImplementation* RawFormat::Create() const
343 {
344    return new RawInstance( this );
345 }
346 
347 // ----------------------------------------------------------------------------
348 
EditPreferences() const349 bool RawFormat::EditPreferences() const
350 {
351    RawPreferences myRawPreferences;
352    myRawPreferences.LoadFromSettings();
353 
354    RawPreferencesDialog d( myRawPreferences );
355    if ( d.Execute() == StdDialogCode::Ok )
356    {
357       myRawPreferences.SaveToSettings();
358       return true;
359    }
360 
361    return false;
362 }
363 
364 // ----------------------------------------------------------------------------
365 
366 } // pcl
367 
368 // ----------------------------------------------------------------------------
369 // EOF RawFormat.cpp - Released 2020-01-14T11:57:23Z
370