~ubuntu-branches/ubuntu/intrepid/graphicsmagick/intrepid

« back to all changes in this revision

Viewing changes to coders/xc.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2006-05-06 16:28:08 UTC
  • Revision ID: james.westby@ubuntu.com-20060506162808-vt2ni3r5nytcszms
Tags: upstream-1.1.7
ImportĀ upstreamĀ versionĀ 1.1.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
% Copyright (C) 2003 GraphicsMagick Group
 
3
% Copyright (C) 2002 ImageMagick Studio
 
4
% Copyright 1991-1999 E. I. du Pont de Nemours and Company
 
5
%
 
6
% This program is covered by multiple licenses, which are described in
 
7
% Copyright.txt. You should have received a copy of Copyright.txt with this
 
8
% package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
 
9
%
 
10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
11
%                                                                             %
 
12
%                                                                             %
 
13
%                                                                             %
 
14
%                               X   X   CCCC                                  %
 
15
%                                X X   C                                      %
 
16
%                                 X    C                                      %
 
17
%                                X X   C                                      %
 
18
%                               X   X   CCCC                                  %
 
19
%                                                                             %
 
20
%                                                                             %
 
21
%                        Read Constant Color Image.                           %
 
22
%                                                                             %
 
23
%                                                                             %
 
24
%                              Software Design                                %
 
25
%                                John Cristy                                  %
 
26
%                                 July 1992                                   %
 
27
%                                                                             %
 
28
%                                                                             %
 
29
%                                                                             %
 
30
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
31
%
 
32
%
 
33
*/
 
34
 
 
35
/*
 
36
  Include declarations.
 
37
*/
 
38
#include "magick/studio.h"
 
39
#include "magick/blob.h"
 
40
#include "magick/color.h"
 
41
#include "magick/composite.h"
 
42
#include "magick/magick.h"
 
43
#include "magick/utility.h"
 
44
 
 
45
/*
 
46
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
47
%                                                                             %
 
48
%                                                                             %
 
49
%                                                                             %
 
50
%   R e a d X C I m a g e                                                     %
 
51
%                                                                             %
 
52
%                                                                             %
 
53
%                                                                             %
 
54
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
55
%
 
56
%  Method ReadXCImage creates a constant image and initializes it to the
 
57
%  X server color as specified by the filename.  It allocates the memory
 
58
%  necessary for the new Image structure and returns a pointer to the new
 
59
%  image.
 
60
%
 
61
%  The format of the ReadXCImage method is:
 
62
%
 
63
%      Image *ReadXCImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
64
%
 
65
%  A description of each parameter follows:
 
66
%
 
67
%    o image:  Method ReadXCImage returns a pointer to the image after
 
68
%      creating it. A null image is returned if there is a memory shortage
 
69
%      or if the image cannot be read.
 
70
%
 
71
%    o image_info: Specifies a pointer to a ImageInfo structure.
 
72
%
 
73
%    o exception: return any errors or warnings in this structure.
 
74
%
 
75
%
 
76
*/
 
77
static Image *ReadXCImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
78
{
 
79
  Image
 
80
    *image;
 
81
 
 
82
  unsigned int
 
83
    status;
 
84
 
 
85
  /*
 
86
    Initialize Image structure.
 
87
  */
 
88
  assert(image_info != (const ImageInfo *) NULL);
 
89
  assert(image_info->signature == MagickSignature);
 
90
  assert(exception != (ExceptionInfo *) NULL);
 
91
  assert(exception->signature == MagickSignature);
 
92
  image=AllocateImage(image_info);
 
93
  if (image->columns == 0)
 
94
    image->columns=1;
 
95
  if (image->rows == 0)
 
96
    image->rows=1;
 
97
  (void) strncpy(image->filename,image_info->filename,MaxTextExtent-1);
 
98
  status=QueryColorDatabase((char *) image_info->filename,
 
99
    &image->background_color,exception);
 
100
  if (status == False)
 
101
    {
 
102
      DestroyImage(image);
 
103
      return((Image *) NULL);
 
104
    }
 
105
  if (!AllocateImageColormap(image,1))
 
106
    ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
 
107
  image->colormap[0]=image->background_color;
 
108
  /*
 
109
    Initialize image pixels to the value of image->background_color
 
110
  */
 
111
  SetImage(image,image->background_color.opacity);
 
112
  return(image);
 
113
}
 
114
 
 
115
/*
 
116
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
117
%                                                                             %
 
118
%                                                                             %
 
119
%                                                                             %
 
120
%   R e g i s t e r X C I m a g e                                             %
 
121
%                                                                             %
 
122
%                                                                             %
 
123
%                                                                             %
 
124
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
125
%
 
126
%  Method RegisterXCImage adds attributes for the XC image format to
 
127
%  the list of supported formats.  The attributes include the image format
 
128
%  tag, a method to read and/or write the format, whether the format
 
129
%  supports the saving of more than one frame to the same file or blob,
 
130
%  whether the format supports native in-memory I/O, and a brief
 
131
%  description of the format.
 
132
%
 
133
%  The format of the RegisterXCImage method is:
 
134
%
 
135
%      RegisterXCImage(void)
 
136
%
 
137
*/
 
138
ModuleExport void RegisterXCImage(void)
 
139
{
 
140
  MagickInfo
 
141
    *entry;
 
142
 
 
143
  entry=SetMagickInfo("XC");
 
144
  entry->decoder=(DecoderHandler) ReadXCImage;
 
145
  entry->adjoin=False;
 
146
  entry->raw=True;
 
147
  entry->description=AcquireString("Constant image uniform color");
 
148
  entry->module=AcquireString("XC");
 
149
  (void) RegisterMagickInfo(entry);
 
150
}
 
151
 
 
152
/*
 
153
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
154
%                                                                             %
 
155
%                                                                             %
 
156
%                                                                             %
 
157
%   U n r e g i s t e r X C I m a g e                                         %
 
158
%                                                                             %
 
159
%                                                                             %
 
160
%                                                                             %
 
161
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
162
%
 
163
%  Method UnregisterXCImage removes format registrations made by the
 
164
%  XC module from the list of supported formats.
 
165
%
 
166
%  The format of the UnregisterXCImage method is:
 
167
%
 
168
%      UnregisterXCImage(void)
 
169
%
 
170
*/
 
171
ModuleExport void UnregisterXCImage(void)
 
172
{
 
173
  (void) UnregisterMagickInfo("XC");
 
174
}