2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % H H A A LLLLL DDDD %
13 % Create Identity Hald CLUT Image Format %
20 % Copyright 1999-2011 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 "magick/studio.h"
43 #include "magick/blob.h"
44 #include "magick/blob-private.h"
45 #include "magick/cache.h"
46 #include "magick/colorspace.h"
47 #include "magick/exception.h"
48 #include "magick/exception-private.h"
49 #include "magick/image.h"
50 #include "magick/image-private.h"
51 #include "magick/list.h"
52 #include "magick/magick.h"
53 #include "magick/memory_.h"
54 #include "magick/module.h"
55 #include "magick/monitor.h"
56 #include "magick/monitor-private.h"
57 #include "magick/quantum-private.h"
58 #include "magick/static.h"
59 #include "magick/string_.h"
60 #include "magick/string-private.h"
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 % R e a d H A L D I m a g e %
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 % ReadHALDImage() creates a Hald color lookup table image and returns it. It
74 % allocates the memory necessary for the new Image structure and returns a
75 % pointer to the new image.
77 % The format of the ReadHALDImage method is:
79 % Image *ReadHALDImage(const ImageInfo *image_info,
80 % ExceptionInfo *exception)
82 % A description of each parameter follows:
84 % o image_info: the image info.
86 % o exception: return any errors or warnings in this structure.
89 static Image *ReadHALDImage(const ImageInfo *image_info,
90 ExceptionInfo *exception)
106 Create HALD color lookup table image.
108 assert(image_info != (const ImageInfo *) NULL);
109 assert(image_info->signature == MagickSignature);
110 if (image_info->debug != MagickFalse)
111 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
112 image_info->filename);
113 assert(exception != (ExceptionInfo *) NULL);
114 assert(exception->signature == MagickSignature);
115 image=AcquireImage(image_info);
117 if (*image_info->filename != '\0')
118 level=StringToUnsignedLong(image_info->filename);
122 cube_size=level*level;
123 image->columns=(size_t) (level*cube_size);
124 image->rows=(size_t) (level*cube_size);
125 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) level)
135 if (status == MagickFalse)
137 q=QueueAuthenticPixels(image,0,y,image->columns,(size_t) level,
139 if (q == (PixelPacket *) NULL)
144 blue=y/(ssize_t) level;
145 for (green=0; green < (ssize_t) cube_size; green++)
147 for (red=0; red < (ssize_t) cube_size; red++)
149 SetRedPixelComponent(q,ClampToQuantum(QuantumRange*red/
151 SetGreenPixelComponent(q,ClampToQuantum(QuantumRange*green/
153 SetBluePixelComponent(q,ClampToQuantum(QuantumRange*blue/
155 SetOpacityPixelComponent(q,OpaqueOpacity);
159 if (SyncAuthenticPixels(image,exception) == MagickFalse)
162 return(GetFirstImageInList(image));
166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
170 % R e g i s t e r H A L D I m a g e %
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176 % RegisterHALDImage() adds attributes for the Hald color lookup table image
177 % format to the list of supported formats. The attributes include the image
178 % format tag, a method to read and/or write the format, whether the format
179 % supports the saving of more than one frame to the same file or blob, whether
180 % the format supports native in-memory I/O, and a brief description of the
183 % The format of the RegisterHALDImage method is:
185 % size_t RegisterHALDImage(void)
188 ModuleExport size_t RegisterHALDImage(void)
193 entry=SetMagickInfo("HALD");
194 entry->decoder=(DecodeImageHandler *) ReadHALDImage;
195 entry->adjoin=MagickFalse;
196 entry->format_type=ImplicitFormatType;
197 entry->raw=MagickTrue;
198 entry->endian_support=MagickTrue;
199 entry->description=ConstantString("Identity Hald color lookup table image");
200 (void) RegisterMagickInfo(entry);
201 return(MagickImageCoderSignature);
205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
209 % U n r e g i s t e r H A L D I m a g e %
213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
215 % UnregisterHALDImage() removes format registrations made by the
216 % HALD module from the list of supported formats.
218 % The format of the UnregisterHALDImage method is:
220 % UnregisterHALDImage(void)
223 ModuleExport void UnregisterHALDImage(void)
225 (void) UnregisterMagickInfo("HALD");