2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read ZX-Spectrum SCREEN$ 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/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);
160 count=ReadBlob(image,768,(unsigned char *) zxattr);
161 for(zonenr=0;zonenr<3;zonenr++)
163 for(zoneline=0;zoneline<8;zoneline++)
165 for(octetline=0;octetline<8;octetline++)
167 for(octetnr=(zoneline*32);octetnr<((zoneline*32)+32);octetnr++)
169 octet_val = zxscr[octetnr+(256*octetline)+(zonenr*2048)];
170 attr_nr = zxattr[octetnr+(256*zonenr)];
172 pix = (((8*octetnr)-(256*zoneline)));
173 piy = ((octetline+(8*zoneline)+(zonenr*64)));
206 ink = (attrbin[0]+(2*attrbin[1])+(4*attrbin[2]));
207 paper = (attrbin[3]+(2*attrbin[4])+(4*attrbin[5]));
210 if(bright) { ink=ink+8; paper=paper+8; }
214 q=QueueAuthenticPixels(image,pix,piy,1,1,exception);
218 q->red=ScaleCharToQuantum(colour_palette[3*ink]);
219 q->green=ScaleCharToQuantum(colour_palette[1+(3*ink)]);
220 q->blue=ScaleCharToQuantum(colour_palette[2+(3*ink)]);
222 q->red=ScaleCharToQuantum(colour_palette[3*paper]);
223 q->green=ScaleCharToQuantum(colour_palette[1+(3*paper)]);
224 q->blue=ScaleCharToQuantum(colour_palette[2+(3*paper)]);
233 (void) CloseBlob(image);
234 return(GetFirstImageInList(image));
238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
242 % R e g i s t e r S C R I m a g e %
246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
248 % RegisterSCRImage() adds attributes for the SCR image format to
249 % the list of supported formats. The attributes include the image format
250 % tag, a method to read and/or write the format, whether the format
251 % supports the saving of more than one frame to the same file or blob,
252 % whether the format supports native in-memory I/O, and a brief
253 % description of the format.
255 % The format of the RegisterSCRImage method is:
257 % size_t RegisterSCRImage(void)
260 ModuleExport size_t RegisterSCRImage(void)
265 entry=SetMagickInfo("SCR");
266 entry->decoder=(DecodeImageHandler *) ReadSCRImage;
267 entry->adjoin=MagickFalse;
268 entry->description=ConstantString("ZX-Spectrum SCREEN$");
269 entry->module=ConstantString("SCR");
270 (void) RegisterMagickInfo(entry);
271 return(MagickImageCoderSignature);
275 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
279 % U n r e g i s t e r S C R I m a g e %
283 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
285 % UnregisterSCRImage() removes format registrations made by the
286 % SCR module from the list of supported formats.
288 % The format of the UnregisterSCRImage method is:
290 % UnregisterSCRImage(void)
293 ModuleExport void UnregisterSCRImage(void)
295 (void) UnregisterMagickInfo("SCR");