Menu

[d59cce]: / coders / yuv.c  Maximize  Restore  History

Download this file

757 lines (727 with data), 25.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
/*
% Copyright (C) 2003-2020 GraphicsMagick Group
% Copyright (C) 2002 ImageMagick Studio
% Copyright 1991-1999 E. I. du Pont de Nemours and Company
%
% This program is covered by multiple licenses, which are described in
% Copyright.txt. You should have received a copy of Copyright.txt with this
% package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% Y Y U U V V %
% Y Y U U V V %
% Y U U V V %
% Y U U V V %
% Y UUU V %
% %
% %
% Read/Write Raw CCIR 601 4:1:1 or 4:2:2 Image Format. %
% %
% %
% Software Design %
% John Cristy %
% July 1992 %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
*/
/*
Include declarations.
*/
#include "magick/studio.h"
#include "magick/blob.h"
#include "magick/pixel_cache.h"
#include "magick/magick.h"
#include "magick/monitor.h"
#include "magick/resize.h"
#include "magick/utility.h"
/*
Forward declarations.
*/
static unsigned int
WriteYUVImage(const ImageInfo *,Image *);
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d Y U V I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method ReadYUVImage reads an image with digital YUV (CCIR 601 4:1:1, plane
% or partition interlaced, or 4:2:2 plane, partition interlaced or
% noninterlaced) bytes and returns it. It allocates the memory necessary
% for the new Image structure and returns a pointer to the new image.
%
% The format of the ReadYUVImage method is:
%
% Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: Method ReadYUVImage returns a pointer to the image after
% reading. A null image is returned if there is a memory shortage or
% if the image cannot be read.
%
% o image_info: Specifies a pointer to a ImageInfo structure.
%
% o exception: return any errors or warnings in this structure.
%
%
*/
#define ThrowYUVReaderException(code_,reason_,image_) \
{ \
MagickFreeResourceLimitedMemory(scanline); \
DestroyImage(chroma_image); \
DestroyImage(resize_image); \
ThrowReaderException(code_,reason_,image_); \
}
static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
Image
*chroma_image = (Image *) NULL,
*image,
*resize_image = (Image *) NULL;
long
horizontal_factor,
vertical_factor,
y;
register const PixelPacket
*r;
register long
x;
register PixelPacket
*q,
*chroma_pixels;
register long
i;
register unsigned char
*p;
size_t
count;
unsigned char
*scanline = (unsigned char *) NULL;
MagickPassFail
status;
InterlaceType
interlace;
/*
Allocate image structure.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
status=MagickPass;
image=AllocateImage(image_info);
if ((image->columns == 0) || (image->rows == 0))
ThrowYUVReaderException(OptionError,MustSpecifyImageSize,image);
image->depth=8;
interlace=image_info->interlace;
horizontal_factor=2;
vertical_factor=2;
if (image_info->sampling_factor != (char *) NULL)
{
long
factors;
factors=sscanf(image_info->sampling_factor,"%ldx%ld",&horizontal_factor,
&vertical_factor);
if (factors != 2)
vertical_factor=horizontal_factor;
if ((horizontal_factor != 1) && (horizontal_factor != 2) &&
(vertical_factor != 1) && (vertical_factor != 2))
ThrowYUVReaderException(OptionError,UnsupportedSamplingFactor,
image);
}
if ((interlace == UndefinedInterlace) ||
((interlace == NoInterlace) && (vertical_factor == 2)))
{
interlace=NoInterlace; /* CCIR 4:2:2 */
if (vertical_factor == 2)
interlace=PlaneInterlace; /* CCIR 4:1:1 */
}
if (interlace != PartitionInterlace)
{
/*
Open image file.
*/
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFail)
ThrowYUVReaderException(FileOpenError,UnableToOpenFile,image);
for (i=0; i < image->offset; i++)
{
if (EOF == ReadBlobByte(image))
ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
image->filename);
}
}
/*
Allocate memory for a scanline.
*/
if (interlace == NoInterlace)
scanline=MagickAllocateResourceLimitedMemory(unsigned char *,MagickArraySize(2,image->columns)+2);
else
scanline=MagickAllocateResourceLimitedMemory(unsigned char *,image->columns);
if (scanline == (unsigned char *) NULL)
ThrowYUVReaderException(ResourceLimitError,MemoryAllocationFailed,image);
do
{
chroma_image=CloneImage(image,image->columns/horizontal_factor,
image->rows/vertical_factor,True,exception);
if (chroma_image == (Image *) NULL)
ThrowYUVReaderException(ResourceLimitError,MemoryAllocationFailed,image);
/*
Convert raster image to pixel packets.
*/
if (image_info->ping && (image_info->subrange != 0))
if (image->scene >= (image_info->subimage+image_info->subrange-1))
break;
if (interlace == PartitionInterlace)
{
AppendImageFormat("Y",image->filename);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == False)
ThrowYUVReaderException(FileOpenError,UnableToOpenFile,image);
}
for (y=0; y < (long) image->rows; y++)
{
if (interlace == NoInterlace)
{
if ((y > 0) || (image->previous == (Image *) NULL))
(void) ReadBlob(image,(size_t)2*image->columns,scanline);
p=scanline;
q=SetImagePixels(image,0,y,image->columns,1);
if (q == (PixelPacket *) NULL)
{
status=MagickFail;
break;
}
chroma_pixels=SetImagePixels(chroma_image,0,y,chroma_image->columns,1);
if (chroma_pixels == (PixelPacket *) NULL)
{
status=MagickFail;
break;
}
for (x=0; x < (long) image->columns; x+=2)
{
chroma_pixels->red=0;
chroma_pixels->green=ScaleCharToQuantum(*p++); /* U (Cb) */
q->red=ScaleCharToQuantum(*p++); /* Y */
q->green=0;
q->blue=0;
q++;
q->green=0;
q->blue=0;
chroma_pixels->blue=ScaleCharToQuantum(*p++); /* V (Cr) */
q->red=ScaleCharToQuantum(*p++); /* Y */
chroma_pixels++;
q++;
}
}
else
{
if ((y > 0) || (image->previous == (Image *) NULL))
(void) ReadBlob(image,image->columns,scanline);
p=scanline;
q=SetImagePixels(image,0,y,image->columns,1);
if (q == (PixelPacket *) NULL)
{
status=MagickFail;
break;
}
for (x=0; x < (long) image->columns; x++)
{
q->red=ScaleCharToQuantum(*p++);
q->green=0;
q->blue=0;
q++;
}
}
if (!SyncImagePixels(image))
{
status=MagickFail;
break;
}
if (interlace == NoInterlace)
if (!SyncImagePixels(chroma_image))
{
status=MagickFail;
break;
}
if (image->previous == (Image *) NULL)
if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
image->filename,
image->columns,image->rows))
{
status=MagickFail;
break;
}
}
if (status == MagickFail)
break;
if (interlace == PartitionInterlace)
{
CloseBlob(image);
AppendImageFormat("U",image->filename);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == False)
ThrowYUVReaderException(FileOpenError,UnableToOpenFile,image);
}
if (interlace != NoInterlace)
{
for (y=0; y < (long) chroma_image->rows; y++)
{
(void) ReadBlob(image,chroma_image->columns,scanline);
p=scanline;
q=SetImagePixels(chroma_image,0,y,chroma_image->columns,1);
if (q == (PixelPacket *) NULL)
{
status=MagickFail;
break;
}
for (x=0; x < (long) chroma_image->columns; x++)
{
q->red=0;
q->green=ScaleCharToQuantum(*p++);
q->blue=0;
q++;
}
if (!SyncImagePixels(chroma_image))
{
status=MagickFail;
break;
}
}
if (status ==MagickFail)
break;
if (interlace == PartitionInterlace)
{
CloseBlob(image);
AppendImageFormat("V",image->filename);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == False)
ThrowYUVReaderException(FileOpenError,UnableToOpenFile,image);
}
for (y=0; y < (long) chroma_image->rows; y++)
{
(void) ReadBlob(image,chroma_image->columns,scanline);
p=scanline;
q=GetImagePixels(chroma_image,0,y,chroma_image->columns,1);
if (q == (PixelPacket *) NULL)
{
status=MagickFail;
break;
}
for (x=0; x < (long) chroma_image->columns; x++)
{
q->blue=ScaleCharToQuantum(*p++);
q++;
}
if (!SyncImagePixels(chroma_image))
{
status=MagickFail;
break;
}
}
if (status == MagickFail)
break;
}
/*
Scale image.
*/
resize_image=ResizeImage(chroma_image,image->columns,image->rows,
TriangleFilter,1.0,exception);
DestroyImage(chroma_image);
chroma_image=(Image *) NULL;
if (resize_image == (Image *) NULL)
ThrowYUVReaderException(ResourceLimitError,MemoryAllocationFailed,image);
for (y=0; y < (long) image->rows; y++)
{
q=GetImagePixels(image,0,y,image->columns,1);
r=AcquireImagePixels(resize_image,0,y,resize_image->columns,1,
&resize_image->exception);
if ((q == (PixelPacket *) NULL) || (r == (const PixelPacket *) NULL))
{
status=MagickFail;
break;
}
for (x=0; x < (long) image->columns; x++)
{
q->green=r->green;
q->blue=r->blue;
r++;
q++;
}
if (!SyncImagePixels(image))
{
status=MagickFail;
break;
}
}
DestroyImage(resize_image);
resize_image=(Image *) NULL;
if (status == MagickFail)
break;
image->colorspace=YCbCrColorspace;
(void) TransformColorspace(image,RGBColorspace);
if (interlace == PartitionInterlace)
(void) strlcpy(image->filename,image_info->filename,MaxTextExtent);
if (EOFBlob(image))
{
ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
image->filename);
break;
}
StopTimer(&image->timer);
/*
Proceed to next image.
*/
if (image_info->subrange != 0)
if (image->scene >= (image_info->subimage+image_info->subrange-1))
break;
if (interlace == NoInterlace)
count=ReadBlob(image, (size_t)2*image->columns,(char *) scanline);
else
count=ReadBlob(image,image->columns,(char *) scanline);
if (count != 0)
{
/*
Allocate next image structure.
*/
AllocateNextImage(image_info,image);
if (image->next == (Image *) NULL)
{
DestroyImageList(image);
MagickFreeResourceLimitedMemory(scanline);
return((Image *) NULL);
}
image=SyncNextImageInList(image);
if (!MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),
exception,LoadImagesText,
image->filename))
break;
}
} while (count != 0);
MagickFreeResourceLimitedMemory(scanline);
while (image->previous != (Image *) NULL)
image=image->previous;
CloseBlob(image);
return(image);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e g i s t e r Y U V I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method RegisterYUVImage adds attributes for the YUV image format to
% the list of supported formats. The attributes include the image format
% tag, a method to read and/or write the format, whether the format
% supports the saving of more than one frame to the same file or blob,
% whether the format supports native in-memory I/O, and a brief
% description of the format.
%
% The format of the RegisterYUVImage method is:
%
% RegisterYUVImage(void)
%
*/
ModuleExport void RegisterYUVImage(void)
{
MagickInfo
*entry;
entry=SetMagickInfo("YUV");
entry->decoder=(DecoderHandler) ReadYUVImage;
entry->encoder=(EncoderHandler) WriteYUVImage;
entry->adjoin=False;
entry->raw=True;
entry->description="CCIR 601 4:1:1 or 4:2:2 (8-bit only)";
entry->module="YUV";
(void) RegisterMagickInfo(entry);
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% U n r e g i s t e r Y U V I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method UnregisterYUVImage removes format registrations made by the
% YUV module from the list of supported formats.
%
% The format of the UnregisterYUVImage method is:
%
% UnregisterYUVImage(void)
%
*/
ModuleExport void UnregisterYUVImage(void)
{
(void) UnregisterMagickInfo("YUV");
}
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% W r i t e Y U V I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method WriteYUVImage writes an image to a file in the digital YUV
% (CCIR 601 4:1:1, plane or partition interlaced, or 4:2:2 plane, partition
% interlaced or noninterlaced) bytes and returns it.
%
% The format of the WriteYUVImage method is:
%
% unsigned int WriteYUVImage(const ImageInfo *image_info,Image *image)
%
% A description of each parameter follows.
%
% o status: Method WriteYUVImage return True if the image is written.
% False is returned is there is a memory shortage or if the image file
% fails to write.
%
% o image_info: Specifies a pointer to a ImageInfo structure.
%
% o image: A pointer to an Image structure.
%
%
*/
static unsigned int WriteYUVImage(const ImageInfo *image_info,Image *image)
{
Image
*chroma_image,
*yuv_image;
InterlaceType
interlace;
long
horizontal_factor,
vertical_factor,
y;
register const PixelPacket
*p,
*s;
register long
x;
unsigned int
status;
unsigned long
scene,
height,
width;
size_t
image_list_length;
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
image_list_length=GetImageListLength(image);
interlace=image_info->interlace;
horizontal_factor=2;
vertical_factor=2;
if (image_info->sampling_factor != (char *) NULL)
{
long
factors;
factors=sscanf(image_info->sampling_factor,"%ldx%ld",&horizontal_factor,
&vertical_factor);
if (factors != 2)
vertical_factor=horizontal_factor;
if ((horizontal_factor != 1) && (horizontal_factor != 2) &&
(vertical_factor != 1) && (vertical_factor != 2))
ThrowWriterException(OptionError,UnsupportedSamplingFactor,
image);
}
if ((interlace == UndefinedInterlace) ||
((interlace == NoInterlace) && (vertical_factor == 2)))
{
interlace=NoInterlace; /* CCIR 4:2:2 */
if (vertical_factor == 2)
interlace=PlaneInterlace; /* CCIR 4:1:1 */
}
if (interlace != PartitionInterlace)
{
/*
Open output image file.
*/
status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
if (status == False)
ThrowWriterException(FileOpenError,UnableToOpenFile,image);
}
else
{
AppendImageFormat("Y",image->filename);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
if (status == False)
ThrowWriterException(FileOpenError,UnableToOpenFile,image);
}
scene=0;
do
{
/*
Sample image to an even width and height, if necessary.
*/
image->depth=8;
(void) TransformColorspace(image,RGBColorspace);
width=image->columns+(image->columns & (horizontal_factor-1));
height=image->rows+(image->rows & (vertical_factor-1));
yuv_image=ResizeImage(image,width,height,TriangleFilter,1.0,
&image->exception);
if (yuv_image == (Image *) NULL)
ThrowWriterException2(ResourceLimitError,image->exception.reason,image);
(void) TransformColorspace(yuv_image,YCbCrColorspace);
/*
Downsample image.
*/
chroma_image=ResizeImage(image,width/horizontal_factor,
height/vertical_factor,TriangleFilter,1.0,&image->exception);
if (chroma_image == (Image *) NULL)
ThrowWriterException2(ResourceLimitError,image->exception.reason,image);
(void) TransformColorspace(chroma_image,YCbCrColorspace);
if (interlace == NoInterlace)
{
/*
Write noninterlaced YUV.
*/
for (y=0; y < (long) yuv_image->rows; y++)
{
p=AcquireImagePixels(yuv_image,0,y,yuv_image->columns,1,
&yuv_image->exception);
if (p == (const PixelPacket *) NULL)
break;
s=AcquireImagePixels(chroma_image,0,y,chroma_image->columns,1,
&chroma_image->exception);
if (s == (const PixelPacket *) NULL)
break;
for (x=0; x < (long) yuv_image->columns; )
{
(void) WriteBlobByte(image,ScaleQuantumToChar(s->green));
(void) WriteBlobByte(image,ScaleQuantumToChar(p->red));
p++;
(void) WriteBlobByte(image,ScaleQuantumToChar(s->blue));
(void) WriteBlobByte(image,ScaleQuantumToChar(p->red));
p++;
s++;
x++;
x++;
}
if (image->previous == (Image *) NULL)
if (QuantumTick(y,image->rows))
if (!MagickMonitorFormatted(y,image->rows,&image->exception,
SaveImageText,image->filename,
image->columns,image->rows))
break;
}
DestroyImage(yuv_image);
}
else
{
/*
Initialize Y channel.
*/
for (y=0; y < (long) yuv_image->rows; y++)
{
p=AcquireImagePixels(yuv_image,0,y,yuv_image->columns,1,
&yuv_image->exception);
if (p == (const PixelPacket *) NULL)
break;
for (x=0; x < (long) yuv_image->columns; x++)
{
(void) WriteBlobByte(image,ScaleQuantumToChar(p->red));
p++;
}
if (image->previous == (Image *) NULL)
if (QuantumTick(y,image->rows))
if (!MagickMonitorFormatted(y,image->rows,&image->exception,
SaveImageText,image->filename,
image->columns,image->rows))
break;
}
DestroyImage(yuv_image);
/*
Initialize U channel.
*/
if (interlace == PartitionInterlace)
{
CloseBlob(image);
AppendImageFormat("U",image->filename);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,
&image->exception);
if (status == False)
ThrowWriterException(FileOpenError,UnableToOpenFile,image);
}
for (y=0; y < (long) chroma_image->rows; y++)
{
p=AcquireImagePixels(chroma_image,0,y,chroma_image->columns,1,
&chroma_image->exception);
if (p == (const PixelPacket *) NULL)
break;
for (x=0; x < (long) chroma_image->columns; x++)
{
(void) WriteBlobByte(image,ScaleQuantumToChar(p->green));
p++;
}
}
/*
Initialize V channel.
*/
if (interlace == PartitionInterlace)
{
CloseBlob(image);
AppendImageFormat("V",image->filename);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,
&image->exception);
if (status == False)
ThrowWriterException(FileOpenError,UnableToOpenFile,image);
}
for (y=0; y < (long) chroma_image->rows; y++)
{
p=AcquireImagePixels(chroma_image,0,y,chroma_image->columns,1,
&chroma_image->exception);
if (p == (const PixelPacket *) NULL)
break;
for (x=0; x < (long) chroma_image->columns; x++)
{
(void) WriteBlobByte(image,ScaleQuantumToChar(p->blue));
p++;
}
}
}
DestroyImage(chroma_image);
if (interlace == PartitionInterlace)
(void) strlcpy(image->filename,image_info->filename,MaxTextExtent);
if (image->next == (Image *) NULL)
break;
image=SyncNextImageInList(image);
status=MagickMonitorFormatted(scene++,image_list_length,
&image->exception,SaveImagesText,
image->filename);
if (status == False)
break;
} while (image_info->adjoin);
if (image_info->adjoin)
while (image->previous != (Image *) NULL)
image=image->previous;
CloseBlob(image);
return(True);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.