1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %                                                                             %
4 %                                                                             %
5 %                                                                             %
6 %                            DDDD   N   N   GGGG                              %
7 %                            D   D  NN  N  GS                                 %
8 %                            D   D  N N N  G  GG                              %
9 %                            D   D  N  NN  G   G                              %
10 %                            DDDD   N   N   GGGG                              %
11 %                                                                             %
12 %                                                                             %
13 %                  Read the Digital Negative Image Format                     %
14 %                                                                             %
15 %                              Software Design                                %
16 %                                   Cristy                                    %
17 %                                 July 1999                                   %
18 %                                                                             %
19 %                                                                             %
20 %  Copyright 1999-2021 ImageMagick Studio LLC, a non-profit organization      %
21 %  dedicated to making software imaging solutions freely available.           %
22 %                                                                             %
23 %  You may not use this file except in compliance with the License.  You may  %
24 %  obtain a copy of the License at                                            %
25 %                                                                             %
26 %    https://imagemagick.org/script/license.php                               %
27 %                                                                             %
28 %  Unless required by applicable law or agreed to in writing, software        %
29 %  distributed under the License is distributed on an "AS IS" BASIS,          %
30 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
31 %  See the License for the specific language governing permissions and        %
32 %  limitations under the License.                                             %
33 %                                                                             %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %
37 */
38 /*
39   Include declarations.
40 */
41 #include "MagickCore/studio.h"
42 #include "MagickCore/blob.h"
43 #include "MagickCore/blob-private.h"
44 #include "MagickCore/constitute.h"
45 #include "MagickCore/delegate.h"
46 #include "MagickCore/exception.h"
47 #include "MagickCore/exception-private.h"
48 #include "MagickCore/geometry.h"
49 #include "MagickCore/image.h"
50 #include "MagickCore/image-private.h"
51 #include "MagickCore/layer.h"
52 #include "MagickCore/list.h"
53 #include "MagickCore/log.h"
54 #include "MagickCore/magick.h"
55 #include "MagickCore/memory_.h"
56 #include "MagickCore/monitor.h"
57 #include "MagickCore/monitor-private.h"
58 #include "MagickCore/opencl.h"
59 #include "MagickCore/option.h"
60 #include "MagickCore/pixel-accessor.h"
61 #include "MagickCore/profile.h"
62 #include "MagickCore/property.h"
63 #include "MagickCore/quantum-private.h"
64 #include "MagickCore/resource_.h"
65 #include "MagickCore/static.h"
66 #include "MagickCore/string_.h"
67 #include "MagickCore/string-private.h"
68 #include "MagickCore/module.h"
69 #include "MagickCore/transform.h"
70 #include "MagickCore/utility.h"
71 #include "MagickCore/xml-tree.h"
72 #include "MagickCore/xml-tree-private.h"
73 #if defined(MAGICKCORE_RAW_R_DELEGATE)
74 #include <libraw.h>
75 #endif
76 
77 /*
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 %                                                                             %
80 %                                                                             %
81 %                                                                             %
82 %   R e a d D N G I m a g e                                                   %
83 %                                                                             %
84 %                                                                             %
85 %                                                                             %
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87 %
88 %  ReadDNGImage() reads an binary file in the Digital Negative format and
89 %  returns it.  It allocates the memory necessary for the new Image structure
90 %  and returns a pointer to the new image.
91 %
92 %  The format of the ReadDNGImage method is:
93 %
94 %      Image *ReadDNGImage(const ImageInfo *image_info,
95 %        ExceptionInfo *exception)
96 %
97 %  A description of each parameter follows:
98 %
99 %    o image_info: the image info.
100 %
101 %    o exception: return any errors or warnings in this structure.
102 %
103 */
104 
105 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(MAGICKCORE_OPENCL_SUPPORT)
InitializeDcrawOpenCL(ExceptionInfo * exception)106 static void InitializeDcrawOpenCL(ExceptionInfo *exception)
107 {
108   MagickBooleanType
109     opencl_disabled;
110 
111   MagickCLDevice
112     *devices;
113 
114   size_t
115     length;
116 
117   ssize_t
118     i;
119 
120   (void) SetEnvironmentVariable("DCR_CL_PLATFORM",NULL);
121   (void) SetEnvironmentVariable("DCR_CL_DEVICE",NULL);
122   (void) SetEnvironmentVariable("DCR_CL_DISABLED",NULL);
123   if (GetOpenCLEnabled() == MagickFalse)
124     {
125       (void) SetEnvironmentVariable("DCR_CL_DISABLED","1");
126       return;
127     }
128   devices=GetOpenCLDevices(&length,exception);
129   if (devices == (MagickCLDevice *) NULL)
130     return;
131   for (i=0; i < (ssize_t) length; i++)
132   {
133     const char
134       *name;
135 
136     MagickCLDevice
137       device;
138 
139     device=devices[i];
140     if (GetOpenCLDeviceEnabled(device) == MagickFalse)
141       continue;
142     name=GetOpenCLDeviceVendorName(device);
143     if (name != (const char *) NULL)
144       (void) SetEnvironmentVariable("DCR_CL_PLATFORM",name);
145     name=GetOpenCLDeviceName(device);
146     if (name != (const char *) NULL)
147       (void) SetEnvironmentVariable("DCR_CL_DEVICE",name);
148     return;
149   }
150 }
151 #else
InitializeDcrawOpenCL(ExceptionInfo * magick_unused (exception))152 static void InitializeDcrawOpenCL(ExceptionInfo *magick_unused(exception))
153 {
154   magick_unreferenced(exception);
155 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
156   (void) SetEnvironmentVariable("DCR_CL_DISABLED","1");
157 #endif
158 }
159 #endif
160 
161 #if defined(MAGICKCORE_RAW_R_DELEGATE)
SetDNGProperties(Image * image,const libraw_data_t * raw_info,ExceptionInfo * exception)162 static void SetDNGProperties(Image *image,const libraw_data_t *raw_info,
163   ExceptionInfo *exception)
164 {
165   char
166     timestamp[MagickTimeExtent];
167 
168   (void) SetImageProperty(image,"dng:make",raw_info->idata.make,exception);
169   (void) SetImageProperty(image,"dng:camera.model.name",raw_info->idata.model,
170     exception);
171   (void) FormatMagickTime(raw_info->other.timestamp,sizeof(timestamp),timestamp);
172   (void) SetImageProperty(image,"dng:create.date",timestamp,exception);
173   (void) FormatImageProperty(image,"dng:iso.setting","%0.1f",
174     raw_info->other.iso_speed);
175 #if LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0,18)
176   (void) SetImageProperty(image,"dng:software",raw_info->idata.software,
177     exception);
178   if (*raw_info->shootinginfo.BodySerial != '\0')
179     (void) SetImageProperty(image,"dng:serial.number",
180       raw_info->shootinginfo.BodySerial,exception);
181   (void) FormatImageProperty(image,"dng:exposure.time","1/%0.1f",
182     PerceptibleReciprocal(raw_info->other.shutter));
183   (void) FormatImageProperty(image,"dng:f.number","%0.1f",
184     raw_info->other.aperture);
185   (void) FormatImageProperty(image,"dng:max.aperture.value","%0.1f",
186     raw_info->lens.EXIF_MaxAp);
187   (void) FormatImageProperty(image,"dng:ocal.length","%0.1f",
188     raw_info->other.focal_len);
189   (void) FormatImageProperty(image,"dng:wb.rb.levels","%f %f %f %f",
190     raw_info->color.cam_mul[0],raw_info->color.cam_mul[2],
191     raw_info->color.cam_mul[1],raw_info->color.cam_mul[3]);
192   (void) SetImageProperty(image,"dng:lens.type",
193     raw_info->lens.makernotes.LensFeatures_suf,exception);
194   (void) FormatImageProperty(image,"dng:lens","%0.1f-%0.1fmm f/%0.1f-%0.1f",
195     raw_info->lens.makernotes.MinFocal,raw_info->lens.makernotes.MaxFocal,
196     raw_info->lens.makernotes.MaxAp4MinFocal,
197     raw_info->lens.makernotes.MaxAp4MaxFocal);
198   (void) FormatImageProperty(image,"dng:lens.f.stops","%0.2f",
199     raw_info->lens.makernotes.LensFStops);
200   (void) FormatImageProperty(image,"dng:min.focal.length","%0.1f mm",
201     raw_info->lens.makernotes.MinFocal);
202   (void) FormatImageProperty(image,"dng:max.focal.length","%0.1f mm",
203     raw_info->lens.makernotes.MaxFocal);
204   (void) FormatImageProperty(image,"dng:max.aperture.at.min.focal","%0.1f",
205     raw_info->lens.makernotes.MaxAp4MinFocal);
206   (void) FormatImageProperty(image,"dng:max.aperture.at.max.focal","%0.1f",
207     raw_info->lens.makernotes.MaxAp4MaxFocal);
208   (void) FormatImageProperty(image,"dng:focal.length.in.35mm.format","%d mm",
209     raw_info->lens.FocalLengthIn35mmFormat);
210 #endif
211 }
212 #endif
213 
InvokeDNGDelegate(const ImageInfo * image_info,Image * image,ExceptionInfo * exception)214 static Image *InvokeDNGDelegate(const ImageInfo *image_info,Image *image,
215   ExceptionInfo *exception)
216 {
217   ExceptionInfo
218     *sans_exception;
219 
220   ImageInfo
221     *read_info;
222 
223   /*
224     Convert DNG to PPM with delegate.
225   */
226   (void) DestroyImageList(image);
227   InitializeDcrawOpenCL(exception);
228   image=AcquireImage(image_info,exception);
229   read_info=CloneImageInfo(image_info);
230   SetImageInfoBlob(read_info,(void *) NULL,0);
231   (void) InvokeDelegate(read_info,image,"dng:decode",(char *) NULL,exception);
232   image=DestroyImage(image);
233   (void) FormatLocaleString(read_info->filename,MagickPathExtent,"%s.png",
234     read_info->unique);
235   sans_exception=AcquireExceptionInfo();
236   image=ReadImage(read_info,sans_exception);
237   sans_exception=DestroyExceptionInfo(sans_exception);
238   if (image == (Image *) NULL)
239     {
240       (void) FormatLocaleString(read_info->filename,MagickPathExtent,"%s.ppm",
241         read_info->unique);
242       image=ReadImage(read_info,exception);
243     }
244   (void) RelinquishUniqueFileResource(read_info->filename);
245   if (image != (Image *) NULL)
246     {
247       char
248         filename[MagickPathExtent],
249         *xml;
250 
251       ExceptionInfo
252         *sans;
253 
254       (void) CopyMagickString(image->magick,read_info->magick,
255         MagickPathExtent);
256       (void) FormatLocaleString(filename,MagickPathExtent,"%s.ufraw",
257         read_info->unique);
258       sans=AcquireExceptionInfo();
259       xml=FileToString(filename,MagickPathExtent,sans);
260       (void) RelinquishUniqueFileResource(filename);
261       if (xml != (char *) NULL)
262         {
263           XMLTreeInfo
264             *ufraw;
265 
266           /*
267             Inject.
268           */
269           ufraw=NewXMLTree(xml,sans);
270           if (ufraw != (XMLTreeInfo *) NULL)
271             {
272               char
273                 *content,
274                 property[MagickPathExtent];
275 
276               const char
277                 *tag;
278 
279               XMLTreeInfo
280                 *next;
281 
282               if (image->properties == (void *) NULL)
283                 image->properties=NewSplayTree(CompareSplayTreeString,
284                   RelinquishMagickMemory,RelinquishMagickMemory);
285               next=GetXMLTreeChild(ufraw,(const char *) NULL);
286               while (next != (XMLTreeInfo *) NULL)
287               {
288                 tag=GetXMLTreeTag(next);
289                 if (tag == (char *) NULL)
290                   tag="unknown";
291                 (void) FormatLocaleString(property,MagickPathExtent,"dng:%s",
292                   tag);
293                 content=ConstantString(GetXMLTreeContent(next));
294                 StripString(content);
295                 if ((LocaleCompare(tag,"log") != 0) &&
296                     (LocaleCompare(tag,"InputFilename") != 0) &&
297                     (LocaleCompare(tag,"OutputFilename") != 0) &&
298                     (LocaleCompare(tag,"OutputType") != 0) &&
299                     (strlen(content) != 0))
300                   (void) AddValueToSplayTree((SplayTreeInfo *)
301                     image->properties,ConstantString(property),content);
302                 next=GetXMLTreeSibling(next);
303               }
304               ufraw=DestroyXMLTree(ufraw);
305             }
306           xml=DestroyString(xml);
307         }
308       sans=DestroyExceptionInfo(sans);
309     }
310   read_info=DestroyImageInfo(read_info);
311   return(image);
312 }
313 
314 #if defined(MAGICKCORE_RAW_R_DELEGATE)
SetLibRawParams(const ImageInfo * image_info,Image * image,libraw_data_t * raw_info)315 static void SetLibRawParams(const ImageInfo *image_info,Image *image,
316   libraw_data_t *raw_info)
317 {
318   const char
319     *option;
320 
321   raw_info->params.output_bps=16;
322   option=GetImageOption(image_info,"dng:use-camera-wb");
323   if (option == (const char *) NULL)
324     option=GetImageOption(image_info,"dng:use_camera_wb");
325   if (option != (const char *) NULL)
326     raw_info->params.use_camera_wb=IsStringTrue(option);
327   option=GetImageOption(image_info,"dng:use-auto-wb");
328   if (option == (const char *) NULL)
329     option=GetImageOption(image_info,"dng:use_auto_wb");
330   if (option != (const char *) NULL)
331     raw_info->params.use_auto_wb=IsStringTrue(option);
332   option=GetImageOption(image_info,"dng:no-auto-bright");
333   if (option == (const char *) NULL)
334     option=GetImageOption(image_info,"dng:no_auto_bright");
335   if (option != (const char *) NULL)
336     raw_info->params.no_auto_bright=IsStringTrue(option);
337   option=GetImageOption(image_info,"dng:output-color");
338   if (option == (const char *) NULL)
339     option=GetImageOption(image_info,"dng:output_color");
340   if (option != (const char *) NULL)
341     {
342       raw_info->params.output_color=StringToInteger(option);
343       if (raw_info->params.output_color == 5)
344         image->colorspace=XYZColorspace;
345     }
346 }
347 #endif
348 
ReadDNGImage(const ImageInfo * image_info,ExceptionInfo * exception)349 static Image *ReadDNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
350 {
351   Image
352     *image;
353 
354   MagickBooleanType
355     status;
356 
357   /*
358     Open image file.
359   */
360   assert(image_info != (const ImageInfo *) NULL);
361   assert(image_info->signature == MagickCoreSignature);
362   if (image_info->debug != MagickFalse)
363     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
364       image_info->filename);
365   assert(exception != (ExceptionInfo *) NULL);
366   assert(exception->signature == MagickCoreSignature);
367   image=AcquireImage(image_info,exception);
368   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
369   if (status == MagickFalse)
370     {
371       image=DestroyImageList(image);
372       return((Image *) NULL);
373     }
374   (void) CloseBlob(image);
375   if (LocaleCompare(image_info->magick,"DCRAW") == 0)
376     return(InvokeDNGDelegate(image_info,image,exception));
377 #if defined(MAGICKCORE_RAW_R_DELEGATE)
378   {
379     int
380       errcode;
381 
382     libraw_data_t
383       *raw_info;
384 
385     libraw_processed_image_t
386       *raw_image;
387 
388     ssize_t
389       y;
390 
391     StringInfo
392       *profile;
393 
394     unsigned short
395       *p;
396 
397     errcode=0;
398     raw_info=libraw_init(0);
399     if (raw_info == (libraw_data_t *) NULL)
400       {
401         (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
402           libraw_strerror(errcode),"`%s'",image->filename);
403         libraw_close(raw_info);
404         return(DestroyImageList(image));
405       }
406 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_MSC_VER) && (_MSC_VER > 1310)
407     {
408       wchar_t
409         fileName[MagickPathExtent];
410 
411       MultiByteToWideChar(CP_UTF8,0,image->filename,-1,fileName,
412         MagickPathExtent);
413       errcode=libraw_open_wfile(raw_info,fileName);
414     }
415 #else
416     errcode=libraw_open_file(raw_info,image->filename);
417 #endif
418     if (errcode != LIBRAW_SUCCESS)
419       {
420         (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
421           libraw_strerror(errcode),"`%s'",image->filename);
422         libraw_close(raw_info);
423         return(DestroyImageList(image));
424       }
425     image->columns=raw_info->sizes.width;
426     image->rows=raw_info->sizes.height;
427     image->page.width=raw_info->sizes.raw_width;
428     image->page.height=raw_info->sizes.raw_height;
429     image->page.x=raw_info->sizes.left_margin;
430     image->page.y=raw_info->sizes.top_margin;
431     if (image_info->ping != MagickFalse)
432       {
433         libraw_close(raw_info);
434         return(image);
435       }
436     status=SetImageExtent(image,image->columns,image->rows,exception);
437     if (status == MagickFalse)
438       {
439         libraw_close(raw_info);
440         return(image);
441       }
442     errcode=libraw_unpack(raw_info);
443     if (errcode != LIBRAW_SUCCESS)
444       {
445         (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
446           libraw_strerror(errcode),"`%s'",image->filename);
447         libraw_close(raw_info);
448         return(DestroyImageList(image));
449       }
450     SetLibRawParams(image_info,image,raw_info);
451     errcode=libraw_dcraw_process(raw_info);
452     if (errcode != LIBRAW_SUCCESS)
453       {
454         (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
455           libraw_strerror(errcode),"`%s'",image->filename);
456         libraw_close(raw_info);
457         return(DestroyImageList(image));
458       }
459     raw_image=libraw_dcraw_make_mem_image(raw_info,&errcode);
460     if ((errcode != LIBRAW_SUCCESS) ||
461         (raw_image == (libraw_processed_image_t *) NULL) ||
462         (raw_image->type != LIBRAW_IMAGE_BITMAP) || (raw_image->bits != 16) ||
463         (raw_image->colors < 3) || (raw_image->colors > 4))
464       {
465         if (raw_image != (libraw_processed_image_t *) NULL)
466           libraw_dcraw_clear_mem(raw_image);
467         (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
468           libraw_strerror(errcode),"`%s'",image->filename);
469         libraw_close(raw_info);
470         return(DestroyImageList(image));
471       }
472     image->columns=raw_image->width;
473     image->rows=raw_image->height;
474     image->depth=raw_image->bits;
475     status=SetImageExtent(image,image->columns,image->rows,exception);
476     if (status == MagickFalse)
477       {
478         libraw_dcraw_clear_mem(raw_image);
479         libraw_close(raw_info);
480         return(DestroyImageList(image));
481       }
482     p=(unsigned short *) raw_image->data;
483     for (y=0; y < (ssize_t) image->rows; y++)
484     {
485       Quantum
486         *q;
487 
488       ssize_t
489         x;
490 
491       q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
492       if (q == (Quantum *) NULL)
493         break;
494       for (x=0; x < (ssize_t) image->columns; x++)
495       {
496         SetPixelRed(image,ScaleShortToQuantum(*p++),q);
497         SetPixelGreen(image,ScaleShortToQuantum(*p++),q);
498         SetPixelBlue(image,ScaleShortToQuantum(*p++),q);
499         if (raw_image->colors > 3)
500           SetPixelAlpha(image,ScaleShortToQuantum(*p++),q);
501         q+=GetPixelChannels(image);
502       }
503       if (SyncAuthenticPixels(image,exception) == MagickFalse)
504         break;
505       if (image->previous == (Image *) NULL)
506         {
507           status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
508             image->rows);
509           if (status == MagickFalse)
510             break;
511         }
512     }
513     libraw_dcraw_clear_mem(raw_image);
514     /*
515       Set DNG image metadata.
516     */
517     if (raw_info->color.profile != NULL)
518       {
519         profile=BlobToStringInfo(raw_info->color.profile,
520           raw_info->color.profile_length);
521         if (profile != (StringInfo *) NULL)
522           {
523             SetImageProfile(image,"ICC",profile,exception);
524             profile=DestroyStringInfo(profile);
525           }
526       }
527 #if LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0,18)
528     if (raw_info->idata.xmpdata != NULL)
529       {
530         profile=BlobToStringInfo(raw_info->idata.xmpdata,
531           raw_info->idata.xmplen);
532         if (profile != (StringInfo *) NULL)
533           {
534             SetImageProfile(image,"XMP",profile,exception);
535             profile=DestroyStringInfo(profile);
536           }
537       }
538 #endif
539     SetDNGProperties(image,raw_info,exception);
540     libraw_close(raw_info);
541     return(image);
542   }
543 #else
544   return(InvokeDNGDelegate(image_info,image,exception));
545 #endif
546 }
547 
548 /*
549 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
550 %                                                                             %
551 %                                                                             %
552 %                                                                             %
553 %   R e g i s t e r D N G I m a g e                                           %
554 %                                                                             %
555 %                                                                             %
556 %                                                                             %
557 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
558 %
559 %  RegisterDNGImage() adds attributes for the DNG image format to
560 %  the list of supported formats.  The attributes include the image format
561 %  tag, a method to read and/or write the format, whether the format
562 %  supports the saving of more than one frame to the same file or blob,
563 %  whether the format supports native in-memory I/O, and a brief
564 %  description of the format.
565 %
566 %  The format of the RegisterDNGImage method is:
567 %
568 %      size_t RegisterDNGImage(void)
569 %
570 */
RegisterDNGImage(void)571 ModuleExport size_t RegisterDNGImage(void)
572 {
573   MagickInfo
574     *entry;
575 
576   entry=AcquireMagickInfo("DNG","3FR","Hasselblad CFV/H3D39II");
577   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
578   entry->flags|=CoderDecoderSeekableStreamFlag;
579   entry->flags^=CoderBlobSupportFlag;
580   entry->format_type=ExplicitFormatType;
581   (void) RegisterMagickInfo(entry);
582   entry=AcquireMagickInfo("DNG","ARW","Sony Alpha Raw Image Format");
583   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
584   entry->flags|=CoderDecoderSeekableStreamFlag;
585   entry->flags^=CoderBlobSupportFlag;
586   entry->format_type=ExplicitFormatType;
587   (void) RegisterMagickInfo(entry);
588   entry=AcquireMagickInfo("DNG","DNG","Digital Negative");
589   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
590   entry->flags|=CoderDecoderSeekableStreamFlag;
591   entry->flags^=CoderBlobSupportFlag;
592   entry->format_type=ExplicitFormatType;
593   (void) RegisterMagickInfo(entry);
594   entry=AcquireMagickInfo("DNG","CR2","Canon Digital Camera Raw Image Format");
595   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
596   entry->flags|=CoderDecoderSeekableStreamFlag;
597   entry->flags^=CoderBlobSupportFlag;
598   entry->format_type=ExplicitFormatType;
599   (void) RegisterMagickInfo(entry);
600   entry=AcquireMagickInfo("DNG","CR3","Canon Digital Camera Raw Image Format");
601   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
602   entry->flags|=CoderDecoderSeekableStreamFlag;
603   entry->flags^=CoderBlobSupportFlag;
604   entry->format_type=ExplicitFormatType;
605   (void) RegisterMagickInfo(entry);
606   entry=AcquireMagickInfo("DNG","CRW","Canon Digital Camera Raw Image Format");
607   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
608   entry->flags|=CoderDecoderSeekableStreamFlag;
609   entry->flags^=CoderBlobSupportFlag;
610   entry->format_type=ExplicitFormatType;
611   (void) RegisterMagickInfo(entry);
612   entry=AcquireMagickInfo("DNG","DCR","Kodak Digital Camera Raw Image File");
613   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
614   entry->flags|=CoderDecoderSeekableStreamFlag;
615   entry->flags^=CoderBlobSupportFlag;
616   entry->format_type=ExplicitFormatType;
617   (void) RegisterMagickInfo(entry);
618   entry=AcquireMagickInfo("DNG","DCRAW","Raw Photo Decoder (dcraw)");
619   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
620   entry->flags|=CoderDecoderSeekableStreamFlag;
621   entry->flags^=CoderBlobSupportFlag;
622   entry->format_type=ExplicitFormatType;
623   (void) RegisterMagickInfo(entry);
624   entry=AcquireMagickInfo("DNG","ERF","Epson RAW Format");
625   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
626   entry->flags|=CoderDecoderSeekableStreamFlag;
627   entry->flags^=CoderBlobSupportFlag;
628   entry->format_type=ExplicitFormatType;
629   (void) RegisterMagickInfo(entry);
630   entry=AcquireMagickInfo("DNG","IIQ","Phase One Raw Image Format");
631   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
632   entry->flags|=CoderDecoderSeekableStreamFlag;
633   entry->flags^=CoderBlobSupportFlag;
634   entry->format_type=ExplicitFormatType;
635   (void) RegisterMagickInfo(entry);
636   entry=AcquireMagickInfo("DNG","KDC","Kodak Digital Camera Raw Image Format");
637   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
638   entry->flags|=CoderDecoderSeekableStreamFlag;
639   entry->flags^=CoderBlobSupportFlag;
640   entry->format_type=ExplicitFormatType;
641   (void) RegisterMagickInfo(entry);
642   entry=AcquireMagickInfo("DNG","K25","Kodak Digital Camera Raw Image Format");
643   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
644   entry->flags|=CoderDecoderSeekableStreamFlag;
645   entry->flags^=CoderBlobSupportFlag;
646   entry->format_type=ExplicitFormatType;
647   (void) RegisterMagickInfo(entry);
648   entry=AcquireMagickInfo("DNG","MEF","Mamiya Raw Image File");
649   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
650   entry->flags|=CoderDecoderSeekableStreamFlag;
651   entry->flags^=CoderBlobSupportFlag;
652   entry->format_type=ExplicitFormatType;
653   (void) RegisterMagickInfo(entry);
654   entry=AcquireMagickInfo("DNG","MRW","Sony (Minolta) Raw Image File");
655   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
656   entry->flags|=CoderDecoderSeekableStreamFlag;
657   entry->flags^=CoderBlobSupportFlag;
658   entry->format_type=ExplicitFormatType;
659   (void) RegisterMagickInfo(entry);
660   entry=AcquireMagickInfo("DNG","NEF",
661     "Nikon Digital SLR Camera Raw Image File");
662   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
663   entry->flags|=CoderDecoderSeekableStreamFlag;
664   entry->flags^=CoderBlobSupportFlag;
665   entry->format_type=ExplicitFormatType;
666   (void) RegisterMagickInfo(entry);
667   entry=AcquireMagickInfo("DNG","NRW",
668     "Nikon Digital SLR Camera Raw Image File");
669   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
670   entry->flags|=CoderDecoderSeekableStreamFlag;
671   entry->flags^=CoderBlobSupportFlag;
672   entry->format_type=ExplicitFormatType;
673   (void) RegisterMagickInfo(entry);
674   entry=AcquireMagickInfo("DNG","ORF","Olympus Digital Camera Raw Image File");
675   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
676   entry->flags|=CoderDecoderSeekableStreamFlag;
677   entry->flags^=CoderBlobSupportFlag;
678   entry->format_type=ExplicitFormatType;
679   (void) RegisterMagickInfo(entry);
680   entry=AcquireMagickInfo("DNG","PEF","Pentax Electronic File");
681   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
682   entry->flags|=CoderDecoderSeekableStreamFlag;
683   entry->flags^=CoderBlobSupportFlag;
684   entry->format_type=ExplicitFormatType;
685   (void) RegisterMagickInfo(entry);
686   entry=AcquireMagickInfo("DNG","RAF","Fuji CCD-RAW Graphic File");
687   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
688   entry->flags|=CoderDecoderSeekableStreamFlag;
689   entry->flags^=CoderBlobSupportFlag;
690   entry->format_type=ExplicitFormatType;
691   (void) RegisterMagickInfo(entry);
692   entry=AcquireMagickInfo("DNG","RAW","Raw");
693   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
694   entry->flags|=CoderDecoderSeekableStreamFlag;
695   entry->flags^=CoderBlobSupportFlag;
696   entry->format_type=ExplicitFormatType;
697   (void) RegisterMagickInfo(entry);
698   entry=AcquireMagickInfo("DNG","RMF","Raw Media Format");
699   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
700   entry->flags|=CoderDecoderSeekableStreamFlag;
701   entry->flags^=CoderBlobSupportFlag;
702   entry->format_type=ExplicitFormatType;
703   (void) RegisterMagickInfo(entry);
704   entry=AcquireMagickInfo("DNG","RW2","Panasonic Lumix Raw Image");
705   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
706   entry->flags|=CoderDecoderSeekableStreamFlag;
707   entry->flags^=CoderBlobSupportFlag;
708   entry->format_type=ExplicitFormatType;
709   (void) RegisterMagickInfo(entry);
710   entry=AcquireMagickInfo("DNG","SRF","Sony Raw Format");
711   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
712   entry->flags|=CoderDecoderSeekableStreamFlag;
713   entry->flags^=CoderBlobSupportFlag;
714   entry->format_type=ExplicitFormatType;
715   (void) RegisterMagickInfo(entry);
716   entry=AcquireMagickInfo("DNG","SR2","Sony Raw Format 2");
717   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
718   entry->flags|=CoderDecoderSeekableStreamFlag;
719   entry->flags^=CoderBlobSupportFlag;
720   entry->format_type=ExplicitFormatType;
721   (void) RegisterMagickInfo(entry);
722   entry=AcquireMagickInfo("DNG","X3F","Sigma Camera RAW Picture File");
723   entry->decoder=(DecodeImageHandler *) ReadDNGImage;
724   entry->flags|=CoderDecoderSeekableStreamFlag;
725   entry->flags^=CoderBlobSupportFlag;
726   entry->format_type=ExplicitFormatType;
727   (void) RegisterMagickInfo(entry);
728   return(MagickImageCoderSignature);
729 }
730 
731 /*
732 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
733 %                                                                             %
734 %                                                                             %
735 %                                                                             %
736 %   U n r e g i s t e r D N G I m a g e                                       %
737 %                                                                             %
738 %                                                                             %
739 %                                                                             %
740 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
741 %
742 %  UnregisterDNGImage() removes format registrations made by the
743 %  BIM module from the list of supported formats.
744 %
745 %  The format of the UnregisterBIMImage method is:
746 %
747 %      UnregisterDNGImage(void)
748 %
749 */
UnregisterDNGImage(void)750 ModuleExport void UnregisterDNGImage(void)
751 {
752   (void) UnregisterMagickInfo("X3F");
753   (void) UnregisterMagickInfo("SR2");
754   (void) UnregisterMagickInfo("SRF");
755   (void) UnregisterMagickInfo("RW2");
756   (void) UnregisterMagickInfo("RMF");
757   (void) UnregisterMagickInfo("RAF");
758   (void) UnregisterMagickInfo("PEF");
759   (void) UnregisterMagickInfo("ORF");
760   (void) UnregisterMagickInfo("NRW");
761   (void) UnregisterMagickInfo("NEF");
762   (void) UnregisterMagickInfo("MRW");
763   (void) UnregisterMagickInfo("MEF");
764   (void) UnregisterMagickInfo("K25");
765   (void) UnregisterMagickInfo("KDC");
766   (void) UnregisterMagickInfo("IIQ");
767   (void) UnregisterMagickInfo("ERF");
768   (void) UnregisterMagickInfo("DCR");
769   (void) UnregisterMagickInfo("CRW");
770   (void) UnregisterMagickInfo("CR3");
771   (void) UnregisterMagickInfo("CR2");
772   (void) UnregisterMagickInfo("DNG");
773   (void) UnregisterMagickInfo("ARW");
774   (void) UnregisterMagickInfo("3FR");
775 }
776