2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % H H A A LLLLL DDDD %
13 % Create Identity Hald CLUT Image Format %
20 % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
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. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 #include "MagickCore/studio.h"
43 #include "MagickCore/blob.h"
44 #include "MagickCore/blob-private.h"
45 #include "MagickCore/cache.h"
46 #include "MagickCore/colorspace.h"
47 #include "MagickCore/exception.h"
48 #include "MagickCore/exception-private.h"
49 #include "MagickCore/image.h"
50 #include "MagickCore/image-private.h"
51 #include "MagickCore/list.h"
52 #include "MagickCore/magick.h"
53 #include "MagickCore/memory_.h"
54 #include "MagickCore/module.h"
55 #include "MagickCore/monitor.h"
56 #include "MagickCore/monitor-private.h"
57 #include "MagickCore/pixel-accessor.h"
58 #include "MagickCore/quantum-private.h"
59 #include "MagickCore/resource_.h"
60 #include "MagickCore/static.h"
61 #include "MagickCore/string_.h"
62 #include "MagickCore/string-private.h"
63 #include "MagickCore/thread-private.h"
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 % R e a d H A L D I m a g e %
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 % ReadHALDImage() creates a Hald color lookup table image and returns it. It
77 % allocates the memory necessary for the new Image structure and returns a
78 % pointer to the new image.
80 % The format of the ReadHALDImage method is:
82 % Image *ReadHALDImage(const ImageInfo *image_info,
83 % ExceptionInfo *exception)
85 % A description of each parameter follows:
87 % o image_info: the image info.
89 % o exception: return any errors or warnings in this structure.
92 static Image *ReadHALDImage(const ImageInfo *image_info,
93 ExceptionInfo *exception)
109 Create HALD color lookup table image.
111 assert(image_info != (const ImageInfo *) NULL);
112 assert(image_info->signature == MagickSignature);
113 if (image_info->debug != MagickFalse)
114 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
115 image_info->filename);
116 assert(exception != (ExceptionInfo *) NULL);
117 assert(exception->signature == MagickSignature);
118 image=AcquireImage(image_info,exception);
120 if (*image_info->filename != '\0')
121 level=StringToUnsignedLong(image_info->filename);
125 cube_size=level*level;
126 image->columns=(size_t) (level*cube_size);
127 image->rows=(size_t) (level*cube_size);
128 #if defined(MAGICKCORE_OPENMP_SUPPORT)
129 #pragma omp parallel for schedule(static,8) shared(status) \
130 dynamic_number_threads(image,image->columns,image->rows,1)
132 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) level)
142 if (status == MagickFalse)
144 q=QueueAuthenticPixels(image,0,y,image->columns,(size_t) level,
146 if (q == (Quantum *) NULL)
151 blue=y/(ssize_t) level;
152 for (green=0; green < (ssize_t) cube_size; green++)
154 for (red=0; red < (ssize_t) cube_size; red++)
156 SetPixelRed(image,ClampToQuantum(QuantumRange*red/(cube_size-1.0)),q);
157 SetPixelGreen(image,ClampToQuantum(QuantumRange*green/(cube_size-1.0)),
159 SetPixelBlue(image,ClampToQuantum(QuantumRange*blue/(cube_size-1.0)),q);
160 SetPixelAlpha(image,OpaqueAlpha,q);
161 q+=GetPixelChannels(image);
164 if (SyncAuthenticPixels(image,exception) == MagickFalse)
167 return(GetFirstImageInList(image));
171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175 % R e g i s t e r H A L D I m a g e %
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
181 % RegisterHALDImage() adds attributes for the Hald color lookup table image
182 % format to the list of supported formats. The attributes include the image
183 % format tag, a method to read and/or write the format, whether the format
184 % supports the saving of more than one frame to the same file or blob, whether
185 % the format supports native in-memory I/O, and a brief description of the
188 % The format of the RegisterHALDImage method is:
190 % size_t RegisterHALDImage(void)
193 ModuleExport size_t RegisterHALDImage(void)
198 entry=SetMagickInfo("HALD");
199 entry->decoder=(DecodeImageHandler *) ReadHALDImage;
200 entry->adjoin=MagickFalse;
201 entry->format_type=ImplicitFormatType;
202 entry->raw=MagickTrue;
203 entry->endian_support=MagickTrue;
204 entry->description=ConstantString("Identity Hald color lookup table image");
205 (void) RegisterMagickInfo(entry);
206 return(MagickImageCoderSignature);
210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
214 % U n r e g i s t e r H A L D I m a g e %
218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220 % UnregisterHALDImage() removes format registrations made by the
221 % HALD module from the list of supported formats.
223 % The format of the UnregisterHALDImage method is:
225 % UnregisterHALDImage(void)
228 ModuleExport void UnregisterHALDImage(void)
230 (void) UnregisterMagickInfo("HALD");