cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % U U Y Y V V Y Y % |
| 7 | % U U Y Y V V Y Y % |
| 8 | % U U Y V V Y % |
| 9 | % U U Y V V Y % |
| 10 | % UUU Y V Y % |
| 11 | % % |
| 12 | % % |
| 13 | % Read/Write 16bit/pixel Interleaved YUV Image Format % |
| 14 | % % |
| 15 | % Software Design % |
cristy | de984cd | 2013-12-01 14:49:27 +0000 | [diff] [blame] | 16 | % Cristy % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 17 | % July 1992 % |
| 18 | % % |
| 19 | % % |
cristy | b56bb24 | 2014-11-25 17:12:48 +0000 | [diff] [blame] | 20 | % Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 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. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % |
| 37 | */ |
| 38 | |
| 39 | /* |
| 40 | Include declarations. |
| 41 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 42 | #include "MagickCore/studio.h" |
| 43 | #include "MagickCore/blob.h" |
| 44 | #include "MagickCore/blob-private.h" |
| 45 | #include "MagickCore/cache.h" |
| 46 | #include "MagickCore/color.h" |
| 47 | #include "MagickCore/colorspace.h" |
| 48 | #include "MagickCore/exception.h" |
| 49 | #include "MagickCore/exception-private.h" |
| 50 | #include "MagickCore/image.h" |
| 51 | #include "MagickCore/image-private.h" |
| 52 | #include "MagickCore/list.h" |
| 53 | #include "MagickCore/magick.h" |
| 54 | #include "MagickCore/memory_.h" |
| 55 | #include "MagickCore/monitor.h" |
| 56 | #include "MagickCore/monitor-private.h" |
| 57 | #include "MagickCore/pixel-accessor.h" |
| 58 | #include "MagickCore/quantum-private.h" |
| 59 | #include "MagickCore/static.h" |
| 60 | #include "MagickCore/string_.h" |
| 61 | #include "MagickCore/module.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 62 | |
| 63 | /* |
| 64 | Forward declarations. |
| 65 | */ |
| 66 | static MagickBooleanType |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 67 | WriteUYVYImage(const ImageInfo *,Image *,ExceptionInfo *); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 68 | |
| 69 | /* |
| 70 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 71 | % % |
| 72 | % % |
| 73 | % % |
| 74 | % R e a d U Y V Y I m a g e % |
| 75 | % % |
| 76 | % % |
| 77 | % % |
| 78 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 79 | % |
| 80 | % ReadUYVYImage() reads an image in the UYVY format and returns it. It |
| 81 | % allocates the memory necessary for the new Image structure and returns a |
| 82 | % pointer to the new image. |
| 83 | % |
| 84 | % The format of the ReadUYVYImage method is: |
| 85 | % |
| 86 | % Image *ReadUYVYImage(const ImageInfo *image_info, |
| 87 | % ExceptionInfo *exception) |
| 88 | % |
| 89 | % A description of each parameter follows: |
| 90 | % |
| 91 | % o image_info: the image info. |
| 92 | % |
| 93 | % o exception: return any errors or warnings in this structure. |
| 94 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 95 | */ |
| 96 | static Image *ReadUYVYImage(const ImageInfo *image_info, |
| 97 | ExceptionInfo *exception) |
| 98 | { |
| 99 | Image |
| 100 | *image; |
| 101 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 102 | MagickBooleanType |
| 103 | status; |
| 104 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 105 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 106 | x; |
| 107 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 108 | register Quantum |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 109 | *q; |
| 110 | |
cristy | c6da28e | 2011-04-28 01:41:35 +0000 | [diff] [blame] | 111 | ssize_t |
| 112 | y; |
| 113 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 114 | unsigned char |
| 115 | u, |
| 116 | v, |
| 117 | y1, |
| 118 | y2; |
| 119 | |
| 120 | /* |
| 121 | Open image file. |
| 122 | */ |
| 123 | assert(image_info != (const ImageInfo *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 124 | assert(image_info->signature == MagickCoreSignature); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 125 | if (image_info->debug != MagickFalse) |
| 126 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 127 | image_info->filename); |
| 128 | assert(exception != (ExceptionInfo *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 129 | assert(exception->signature == MagickCoreSignature); |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 130 | image=AcquireImage(image_info,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 131 | if ((image->columns == 0) || (image->rows == 0)) |
| 132 | ThrowReaderException(OptionError,"MustSpecifyImageSize"); |
| 133 | if ((image->columns % 2) != 0) |
| 134 | image->columns++; |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 135 | (void) CopyMagickString(image->filename,image_info->filename,MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 136 | status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); |
| 137 | if (status == MagickFalse) |
| 138 | return((Image *) NULL); |
cristy | d429702 | 2010-09-16 22:59:09 +0000 | [diff] [blame] | 139 | if (DiscardBlobBytes(image,image->offset) == MagickFalse) |
| 140 | ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", |
| 141 | image->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 142 | image->depth=8; |
| 143 | if (image_info->ping != MagickFalse) |
| 144 | { |
| 145 | (void) CloseBlob(image); |
| 146 | return(GetFirstImageInList(image)); |
| 147 | } |
cristy | acabb84 | 2014-12-14 23:36:33 +0000 | [diff] [blame] | 148 | status=SetImageExtent(image,image->columns,image->rows,exception); |
| 149 | if (status == MagickFalse) |
| 150 | return(DestroyImageList(image)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 151 | /* |
| 152 | Accumulate UYVY, then unpack into two pixels. |
| 153 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 154 | for (y=0; y < (ssize_t) image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 155 | { |
| 156 | q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 157 | if (q == (Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 158 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 159 | for (x=0; x < (ssize_t) (image->columns >> 1); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 160 | { |
| 161 | u=(unsigned char) ReadBlobByte(image); |
| 162 | y1=(unsigned char) ReadBlobByte(image); |
| 163 | v=(unsigned char) ReadBlobByte(image); |
| 164 | y2=(unsigned char) ReadBlobByte(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 165 | SetPixelRed(image,ScaleCharToQuantum(y1),q); |
| 166 | SetPixelGreen(image,ScaleCharToQuantum(u),q); |
| 167 | SetPixelBlue(image,ScaleCharToQuantum(v),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 168 | q+=GetPixelChannels(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 169 | SetPixelRed(image,ScaleCharToQuantum(y2),q); |
| 170 | SetPixelGreen(image,ScaleCharToQuantum(u),q); |
| 171 | SetPixelBlue(image,ScaleCharToQuantum(v),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 172 | q+=GetPixelChannels(image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 173 | } |
| 174 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
| 175 | break; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 176 | status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, |
cristy | c6da28e | 2011-04-28 01:41:35 +0000 | [diff] [blame] | 177 | image->rows); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 178 | if (status == MagickFalse) |
| 179 | break; |
| 180 | } |
cristy | e2c4f18 | 2012-05-12 14:11:53 +0000 | [diff] [blame] | 181 | SetImageColorspace(image,YCbCrColorspace,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 182 | if (EOFBlob(image) != MagickFalse) |
| 183 | ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", |
| 184 | image->filename); |
| 185 | (void) CloseBlob(image); |
| 186 | return(GetFirstImageInList(image)); |
| 187 | } |
| 188 | |
| 189 | /* |
| 190 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 191 | % % |
| 192 | % % |
| 193 | % % |
| 194 | % R e g i s t e r U Y V Y I m a g e % |
| 195 | % % |
| 196 | % % |
| 197 | % % |
| 198 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 199 | % |
| 200 | % RegisterUYVYImage() adds attributes for the UYVY image format to |
| 201 | % the list of supported formats. The attributes include the image format |
| 202 | % tag, a method to read and/or write the format, whether the format |
| 203 | % supports the saving of more than one frame to the same file or blob, |
| 204 | % whether the format supports native in-memory I/O, and a brief |
| 205 | % description of the format. |
| 206 | % |
| 207 | % The format of the RegisterUYVYImage method is: |
| 208 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 209 | % size_t RegisterUYVYImage(void) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 210 | % |
| 211 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 212 | ModuleExport size_t RegisterUYVYImage(void) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 213 | { |
| 214 | MagickInfo |
| 215 | *entry; |
| 216 | |
dirk | 06b627a | 2015-04-06 18:59:17 +0000 | [diff] [blame] | 217 | entry=AcquireMagickInfo("UYVY","PAL","16bit/pixel interleaved YUV"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 218 | entry->decoder=(DecodeImageHandler *) ReadUYVYImage; |
| 219 | entry->encoder=(EncodeImageHandler *) WriteUYVYImage; |
dirk | 08e9a11 | 2015-02-22 01:51:41 +0000 | [diff] [blame] | 220 | entry->flags^=CoderAdjoinFlag; |
| 221 | entry->flags|=CoderRawSupportFlag; |
| 222 | entry->flags|=CoderEndianSupportFlag; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 223 | (void) RegisterMagickInfo(entry); |
dirk | 06b627a | 2015-04-06 18:59:17 +0000 | [diff] [blame] | 224 | entry=AcquireMagickInfo("UYVY","UYVY","16bit/pixel interleaved YUV"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 225 | entry->decoder=(DecodeImageHandler *) ReadUYVYImage; |
| 226 | entry->encoder=(EncodeImageHandler *) WriteUYVYImage; |
dirk | 08e9a11 | 2015-02-22 01:51:41 +0000 | [diff] [blame] | 227 | entry->flags^=CoderAdjoinFlag; |
| 228 | entry->flags|=CoderRawSupportFlag; |
| 229 | entry->flags|=CoderEndianSupportFlag; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 230 | (void) RegisterMagickInfo(entry); |
| 231 | return(MagickImageCoderSignature); |
| 232 | } |
| 233 | |
| 234 | /* |
| 235 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 236 | % % |
| 237 | % % |
| 238 | % % |
| 239 | % U n r e g i s t e r U Y V Y I m a g e % |
| 240 | % % |
| 241 | % % |
| 242 | % % |
| 243 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 244 | % |
| 245 | % UnregisterUYVYImage() removes format registrations made by the |
| 246 | % UYVY module from the list of supported formats. |
| 247 | % |
| 248 | % The format of the UnregisterUYVYImage method is: |
| 249 | % |
| 250 | % UnregisterUYVYImage(void) |
| 251 | % |
| 252 | */ |
| 253 | ModuleExport void UnregisterUYVYImage(void) |
| 254 | { |
| 255 | (void) UnregisterMagickInfo("PAL"); |
| 256 | (void) UnregisterMagickInfo("UYVY"); |
| 257 | } |
| 258 | |
| 259 | /* |
| 260 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 261 | % % |
| 262 | % % |
| 263 | % % |
| 264 | % W r i t e U Y V Y I m a g e % |
| 265 | % % |
| 266 | % % |
| 267 | % % |
| 268 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 269 | % |
| 270 | % WriteUYVYImage() writes an image to a file in the digital UYVY |
| 271 | % format. This format, used by AccomWSD, is not dramatically higher quality |
| 272 | % than the 12bit/pixel YUV format, but has better locality. |
| 273 | % |
| 274 | % The format of the WriteUYVYImage method is: |
| 275 | % |
| 276 | % MagickBooleanType WriteUYVYImage(const ImageInfo *image_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 277 | % Image *image,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 278 | % |
| 279 | % A description of each parameter follows. |
| 280 | % |
| 281 | % o image_info: the image info. |
| 282 | % |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 283 | % o image: The image. Implicit assumption: number of columns is even. |
| 284 | % |
| 285 | % o exception: return any errors or warnings in this structure. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 286 | % |
| 287 | */ |
| 288 | static MagickBooleanType WriteUYVYImage(const ImageInfo *image_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 289 | Image *image,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 290 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 291 | PixelInfo |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 292 | pixel; |
| 293 | |
| 294 | Image |
| 295 | *uyvy_image; |
| 296 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 297 | MagickBooleanType |
| 298 | full, |
| 299 | status; |
| 300 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 301 | register const Quantum |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 302 | *p; |
| 303 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 304 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 305 | x; |
| 306 | |
cristy | c6da28e | 2011-04-28 01:41:35 +0000 | [diff] [blame] | 307 | ssize_t |
| 308 | y; |
| 309 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 310 | /* |
| 311 | Open output image file. |
| 312 | */ |
| 313 | assert(image_info != (const ImageInfo *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 314 | assert(image_info->signature == MagickCoreSignature); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 315 | assert(image != (Image *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 316 | assert(image->signature == MagickCoreSignature); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 317 | if (image->debug != MagickFalse) |
| 318 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 319 | if ((image->columns % 2) != 0) |
| 320 | image->columns++; |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 321 | assert(exception != (ExceptionInfo *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 322 | assert(exception->signature == MagickCoreSignature); |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 323 | status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 324 | if (status == MagickFalse) |
| 325 | return(status); |
| 326 | /* |
| 327 | Accumulate two pixels, then output. |
| 328 | */ |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 329 | uyvy_image=CloneImage(image,0,0,MagickTrue,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 330 | if (uyvy_image == (Image *) NULL) |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 331 | return(MagickFalse); |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 332 | (void) TransformImageColorspace(uyvy_image,YCbCrColorspace,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 333 | full=MagickFalse; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 334 | (void) ResetMagickMemory(&pixel,0,sizeof(PixelInfo)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 335 | for (y=0; y < (ssize_t) image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 336 | { |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 337 | p=GetVirtualPixels(uyvy_image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 338 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 339 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 340 | for (x=0; x < (ssize_t) image->columns; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 341 | { |
| 342 | if (full != MagickFalse) |
| 343 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 344 | pixel.green=(pixel.green+GetPixelGreen(uyvy_image,p))/2; |
| 345 | pixel.blue=(pixel.blue+GetPixelBlue(uyvy_image,p))/2; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 346 | (void) WriteBlobByte(image,ScaleQuantumToChar((Quantum) pixel.green)); |
| 347 | (void) WriteBlobByte(image,ScaleQuantumToChar((Quantum) pixel.red)); |
| 348 | (void) WriteBlobByte(image,ScaleQuantumToChar((Quantum) pixel.blue)); |
cristy | c6da28e | 2011-04-28 01:41:35 +0000 | [diff] [blame] | 349 | (void) WriteBlobByte(image,ScaleQuantumToChar( |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 350 | GetPixelRed(uyvy_image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 351 | } |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 352 | pixel.red=(double) GetPixelRed(uyvy_image,p); |
| 353 | pixel.green=(double) GetPixelGreen(uyvy_image,p); |
| 354 | pixel.blue=(double) GetPixelBlue(uyvy_image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 355 | full=full == MagickFalse ? MagickTrue : MagickFalse; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 356 | p+=GetPixelChannels(uyvy_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 357 | } |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 358 | status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, |
cristy | c6da28e | 2011-04-28 01:41:35 +0000 | [diff] [blame] | 359 | image->rows); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 360 | if (status == MagickFalse) |
| 361 | break; |
| 362 | } |
| 363 | uyvy_image=DestroyImage(uyvy_image); |
| 364 | (void) CloseBlob(image); |
| 365 | return(MagickTrue); |
| 366 | } |