2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read ZX-Spectrum SCREEN$ Format %
20 % Copyright 1999-2010 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/exception.h"
47 #include "magick/exception-private.h"
48 #include "magick/image.h"
49 #include "magick/image-private.h"
50 #include "magick/list.h"
51 #include "magick/magick.h"
52 #include "magick/memory_.h"
53 #include "magick/monitor.h"
54 #include "magick/monitor-private.h"
55 #include "magick/quantum-private.h"
56 #include "magick/static.h"
57 #include "magick/string_.h"
58 #include "magick/module.h"
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 % R e a d S C R I m a g e %
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 % ReadSCRImage() reads a Scitex image file and returns it. It allocates
72 % the memory necessary for the new Image structure and returns a pointer to
75 % The format of the ReadSCRImage method is:
77 % Image *ReadSCRImage(const ImageInfo *image_info,ExceptionInfo *exception)
79 % A description of each parameter follows:
81 % o image_info: the image info.
83 % o exception: return any errors or warnings in this structure.
86 static Image *ReadSCRImage(const ImageInfo *image_info,ExceptionInfo *exception)
108 unsigned char colour_palette[] = {
142 assert(image_info != (const ImageInfo *) NULL);
143 assert(image_info->signature == MagickSignature);
144 if (image_info->debug != MagickFalse)
145 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
146 image_info->filename);
147 assert(exception != (ExceptionInfo *) NULL);
148 assert(exception->signature == MagickSignature);
149 image=AcquireImage(image_info);
150 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
151 if (status == MagickFalse)
153 image=DestroyImageList(image);
154 return((Image *) NULL);
156 image->columns = 256;
158 count=ReadBlob(image,6144,(unsigned char *) zxscr);
159 count=ReadBlob(image,768,(unsigned char *) zxattr);
160 for(zonenr=0;zonenr<3;zonenr++)
162 for(zoneline=0;zoneline<8;zoneline++)
164 for(octetline=0;octetline<8;octetline++)
166 for(octetnr=(zoneline*32);octetnr<((zoneline*32)+32);octetnr++)
168 octet_val = zxscr[octetnr+(256*octetline)+(zonenr*2048)];
169 attr_nr = zxattr[octetnr+(256*zonenr)];
171 pix = (((8*octetnr)-(256*zoneline)));
172 piy = ((octetline+(8*zoneline)+(zonenr*64)));
205 ink = (attrbin[0]+(2*attrbin[1])+(4*attrbin[2]));
206 paper = (attrbin[3]+(2*attrbin[4])+(4*attrbin[5]));
209 if(bright) { ink=ink+8; paper=paper+8; }
213 q=QueueAuthenticPixels(image,pix,piy,1,1,exception);
217 q->red=ScaleCharToQuantum(colour_palette[3*ink]);
218 q->green=ScaleCharToQuantum(colour_palette[1+(3*ink)]);
219 q->blue=ScaleCharToQuantum(colour_palette[2+(3*ink)]);
221 q->red=ScaleCharToQuantum(colour_palette[3*paper]);
222 q->green=ScaleCharToQuantum(colour_palette[1+(3*paper)]);
223 q->blue=ScaleCharToQuantum(colour_palette[2+(3*paper)]);
232 (void) CloseBlob(image);
233 return(GetFirstImageInList(image));
237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
241 % R e g i s t e r S C R I m a g e %
245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
247 % RegisterSCRImage() adds attributes for the SCR image format to
248 % the list of supported formats. The attributes include the image format
249 % tag, a method to read and/or write the format, whether the format
250 % supports the saving of more than one frame to the same file or blob,
251 % whether the format supports native in-memory I/O, and a brief
252 % description of the format.
254 % The format of the RegisterSCRImage method is:
256 % unsigned long RegisterSCRImage(void)
259 ModuleExport unsigned long RegisterSCRImage(void)
264 entry=SetMagickInfo("SCR");
265 entry->decoder=(DecodeImageHandler *) ReadSCRImage;
266 entry->adjoin=MagickFalse;
267 entry->description=ConstantString("ZX-Spectrum SCREEN$");
268 entry->module=ConstantString("SCR");
269 (void) RegisterMagickInfo(entry);
270 return(MagickImageCoderSignature);
274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278 % U n r e g i s t e r S C R I m a g e %
282 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
284 % UnregisterSCRImage() removes format registrations made by the
285 % SCR module from the list of supported formats.
287 % The format of the UnregisterSCRImage method is:
289 % UnregisterSCRImage(void)
292 ModuleExport void UnregisterSCRImage(void)
294 (void) UnregisterMagickInfo("SCR");