Powered by Pair ImageMagick logo
Image Magick
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

ImageMagick-6.1.1/coders/matte.c

Go to the documentation of this file.
00001 /* 00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00003 % % 00004 % % 00005 % % 00006 % M M AAA TTTTT TTTTT EEEEE % 00007 % MM MM A A T T E % 00008 % M M M AAAAA T T EEE % 00009 % M M A A T T E % 00010 % M M A A T T EEEEE % 00011 % % 00012 % % 00013 % Write Matte Channel To MIFF File. % 00014 % % 00015 % Software Design % 00016 % John Cristy % 00017 % July 1992 % 00018 % % 00019 % % 00020 % Copyright 1999-2004 ImageMagick Studio LLC, a non-profit organization % 00021 % dedicated to making software imaging solutions freely available. % 00022 % % 00023 % You may not use this file except in compliance with the License. You may % 00024 % obtain a copy of the License at % 00025 % % 00026 % http://www.imagemagick.org/www/Copyright.html % 00027 % % 00028 % Unless required by applicable law or agreed to in writing, software % 00029 % distributed under the License is distributed on an "AS IS" BASIS, % 00030 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 00031 % See the License for the specific language governing permissions and % 00032 % limitations under the License. % 00033 % % 00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00035 % 00036 % 00037 */ 00038 00039 /* 00040 Include declarations. 00041 */ 00042 #include "magick/studio.h" 00043 #include "magick/blob.h" 00044 #include "magick/blob_private.h" 00045 #include "magick/constitute.h" 00046 #include "magick/error.h" 00047 #include "magick/error_private.h" 00048 #include "magick/image_private.h" 00049 #include "magick/magick.h" 00050 #include "magick/memory_.h" 00051 #include "magick/monitor.h" 00052 #include "magick/static.h" 00053 #include "magick/string_.h" 00054 00055 /* 00056 Forward declarations. 00057 */ 00058 static MagickBooleanType 00059 WriteMATTEImage(const ImageInfo *,Image *); 00060 00061 /* 00062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00063 % % 00064 % % 00065 % % 00066 % R e g i s t e r M A T T E I m a g e % 00067 % % 00068 % % 00069 % % 00070 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00071 % 00072 % RegisterMATTEImage() adds attributes for the MATTE image format to 00073 % the list of supported formats. The attributes include the image format 00074 % tag, a method to read and/or write the format, whether the format 00075 % supports the saving of more than one frame to the same file or blob, 00076 % whether the format supports native in-memory I/O, and a brief 00077 % description of the format. 00078 % 00079 % The format of the RegisterMATTEImage method is: 00080 % 00081 % RegisterMATTEImage(void) 00082 % 00083 */ 00084 ModuleExport void RegisterMATTEImage(void) 00085 { 00086 MagickInfo 00087 *entry; 00088 00089 entry=SetMagickInfo("MATTE"); 00090 entry->encoder=(EncoderHandler *) WriteMATTEImage; 00091 entry->description=AcquireString("MATTE format"); 00092 entry->module=AcquireString("MATTE"); 00093 (void) RegisterMagickInfo(entry); 00094 } 00095 00096 /* 00097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00098 % % 00099 % % 00100 % % 00101 % U n r e g i s t e r M A T T E I m a g e % 00102 % % 00103 % % 00104 % % 00105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00106 % 00107 % UnregisterMATTEImage() removes format registrations made by the 00108 % MATTE module from the list of supported formats. 00109 % 00110 % The format of the UnregisterMATTEImage method is: 00111 % 00112 % UnregisterMATTEImage(void) 00113 % 00114 */ 00115 ModuleExport void UnregisterMATTEImage(void) 00116 { 00117 (void) UnregisterMagickInfo("MATTE"); 00118 } 00119 00120 /* 00121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00122 % % 00123 % % 00124 % % 00125 % W r i t e M A T T E I m a g e % 00126 % % 00127 % % 00128 % % 00129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00130 % 00131 % Function WriteMATTEImage() writes an image of matte bytes to a file. It 00132 % consists of data from the matte component of the image [0..255]. 00133 % 00134 % The format of the WriteMATTEImage method is: 00135 % 00136 % MagickBooleanType WriteMATTEImage(const ImageInfo *image_info, 00137 % Image *image) 00138 % 00139 % A description of each parameter follows. 00140 % 00141 % o image_info: The image info. 00142 % 00143 % o image: The image. 00144 % 00145 % 00146 */ 00147 static MagickBooleanType WriteMATTEImage(const ImageInfo *image_info, 00148 Image *image) 00149 { 00150 Image 00151 *matte_image; 00152 00153 long 00154 y; 00155 00156 MagickBooleanType 00157 status; 00158 00159 register const PixelPacket 00160 *p; 00161 00162 register long 00163 x; 00164 00165 register PixelPacket 00166 *q; 00167 00168 if (image->matte == MagickFalse) 00169 ThrowWriterException(CoderError,"ImageDoesNotHaveAMatteChannel"); 00170 matte_image= 00171 CloneImage(image,image->columns,image->rows,MagickTrue,&image->exception); 00172 if (matte_image == (Image *) NULL) 00173 return(MagickFalse); 00174 (void) SetImageType(matte_image,TrueColorType); 00175 matte_image->matte=MagickFalse; 00176 /* 00177 Convert image to matte pixels. 00178 */ 00179 for (y=0; y < (long) image->rows; y++) 00180 { 00181 p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception); 00182 q=SetImagePixels(matte_image,0,y,matte_image->columns,1); 00183 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL)) 00184 break; 00185 for (x=0; x < (long) image->columns; x++) 00186 { 00187 q->red=p->opacity; 00188 q->green=p->opacity; 00189 q->blue=p->opacity; 00190 q->opacity=OpaqueOpacity; 00191 p++; 00192 q++; 00193 } 00194 if (SyncImagePixels(matte_image) == MagickFalse) 00195 break; 00196 if (image->previous == (Image *) NULL) 00197 if ((image->progress_monitor != (MagickProgressMonitor) NULL) && 00198 (QuantumTick(y,image->rows) != MagickFalse)) 00199 { 00200 status=image->progress_monitor(SaveImageTag,y,image->rows, 00201 image->client_data); 00202 if (status == MagickFalse) 00203 break; 00204 } 00205 } 00206 (void) FormatMagickString(matte_image->filename,MaxTextExtent, 00207 "MIFF:%s",image->filename); 00208 status=WriteImage(image_info,matte_image); 00209 matte_image=DestroyImage(matte_image); 00210 return(status); 00211 }

Generated on Mon Oct 25 13:40:38 2004 for ImageMagick by doxygen 1.3.7
ImageMagick Copyright © 2004, ImageMagick Studio LLC