~ubuntu-branches/ubuntu/oneiric/imagemagick/oneiric-updates

« back to all changes in this revision

Viewing changes to coders/cin.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-06-15 11:05:28 UTC
  • mfrom: (6.2.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110615110528-08jgo07a4846xh8d
Tags: 8:6.6.0.4-3ubuntu1
* Resynchronise with Debian (LP: #797595).  Remaining changes:
  - Make ufraw-batch (universe) a suggestion instead of a recommendation.
  - Make debian/rules install target depend on check; they cannot reliably
    be run in parallel.
  - Don't set MAKEFLAGS in debian/rules; just pass it to the build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
    sign,
82
82
    sense;
83
83
 
84
 
  size_t
 
84
  unsigned long
85
85
    line_pad,
86
86
    channel_pad;
87
87
 
91
91
 
92
92
typedef struct _CINFileInfo
93
93
{
94
 
  size_t
 
94
  unsigned long
95
95
    magic,
96
96
    image_offset,
97
97
    generic_length,
115
115
    offset,
116
116
    reserve1;
117
117
 
118
 
  size_t
 
118
  unsigned long
119
119
    prefix,
120
120
    count;
121
121
 
122
122
  char
123
123
    format[32];
124
124
 
125
 
  size_t
 
125
  unsigned long
126
126
    frame_position;
127
127
 
128
128
  float
141
141
    bits_per_pixel,
142
142
    reserve;
143
143
 
144
 
  size_t
 
144
  unsigned long
145
145
    pixels_per_line,
146
146
    lines_per_image;
147
147
 
175
175
 
176
176
typedef struct _CINOriginationInfo
177
177
{
178
 
  ssize_t
 
178
  long
179
179
    x_offset,
180
180
    y_offset;
181
181
 
291
291
%
292
292
*/
293
293
 
294
 
static size_t GetBytesPerRow(size_t columns,
295
 
  size_t samples_per_pixel,size_t bits_per_pixel,
 
294
static size_t GetBytesPerRow(unsigned long columns,
 
295
  unsigned long samples_per_pixel,unsigned long bits_per_pixel,
296
296
  MagickBooleanType pad)
297
297
{
298
298
  size_t
361
361
{
362
362
  union
363
363
  {
364
 
    size_t
 
364
    unsigned long
365
365
      unsigned_value;
366
366
 
367
367
    double
390
390
  Image
391
391
    *image;
392
392
 
393
 
  ssize_t
 
393
  long
394
394
    y;
395
395
 
396
396
  MagickBooleanType
405
405
  QuantumType
406
406
    quantum_type;
407
407
 
408
 
  register ssize_t
 
408
  register long
409
409
    i;
410
410
 
411
411
  register PixelPacket
420
420
  unsigned char
421
421
    *pixels;
422
422
 
423
 
  size_t
 
423
  unsigned long
424
424
    lsb_first;
425
425
 
426
426
  /*
581
581
  /*
582
582
    Image origination information.
583
583
  */
584
 
  cin.origination.x_offset=(ssize_t) ReadBlobLong(image);
585
 
  offset+=4;
586
 
  if ((size_t) cin.origination.x_offset != ~0UL)
587
 
    (void) FormatImageProperty(image,"cin:origination.x_offset","%.20g",
588
 
      (double) cin.origination.x_offset);
589
 
  cin.origination.y_offset=(ssize_t) ReadBlobLong(image);
590
 
  offset+=4;
591
 
  if ((size_t) cin.origination.y_offset != ~0UL)
592
 
    (void) FormatImageProperty(image,"cin:origination.y_offset","%.20g",
593
 
      (double) cin.origination.y_offset);
 
584
  cin.origination.x_offset=(long) ReadBlobLong(image);
 
585
  offset+=4;
 
586
  if ((unsigned long) cin.origination.x_offset != ~0UL)
 
587
    (void) FormatImageProperty(image,"cin:origination.x_offset","%ld",
 
588
      cin.origination.x_offset);
 
589
  cin.origination.y_offset=(long) ReadBlobLong(image);
 
590
  offset+=4;
 
591
  if ((unsigned long) cin.origination.y_offset != ~0UL)
 
592
    (void) FormatImageProperty(image,"cin:origination.y_offset","%ld",
 
593
      cin.origination.y_offset);
594
594
  offset+=ReadBlob(image,sizeof(cin.origination.filename),(unsigned char *)
595
595
    cin.origination.filename);
596
596
  (void) SetImageProperty(image,"cin:origination.filename",
631
631
      */
632
632
      cin.film.id=ReadBlobByte(image);
633
633
      offset++;
634
 
      if (((size_t) cin.film.id) != ~0UL)
 
634
      if ((unsigned long) cin.film.id != ~0UL)
635
635
        (void) FormatImageProperty(image,"cin:film.id","%d",cin.film.id);
636
636
      cin.film.type=ReadBlobByte(image);
637
637
      offset++;
638
 
      if (((size_t) cin.film.type) != ~0UL)
 
638
      if ((unsigned long) cin.film.type != ~0UL)
639
639
        (void) FormatImageProperty(image,"cin:film.type","%d",cin.film.type);
640
640
      cin.film.offset=ReadBlobByte(image);
641
641
      offset++;
642
 
      if (((size_t) cin.film.offset) != ~0UL)
 
642
      if ((unsigned long) cin.film.offset != ~0UL)
643
643
        (void) FormatImageProperty(image,"cin:film.offset","%d",
644
644
          cin.film.offset);
645
645
      cin.film.reserve1=ReadBlobByte(image);
647
647
      cin.film.prefix=ReadBlobLong(image);
648
648
      offset+=4;
649
649
      if (cin.film.prefix != ~0UL)
650
 
        (void) FormatImageProperty(image,"cin:film.prefix","%.20g",(double)
 
650
        (void) FormatImageProperty(image,"cin:film.prefix","%lu",
651
651
          cin.film.prefix);
652
652
      cin.film.count=ReadBlobLong(image);
653
653
      offset+=4;
657
657
      cin.film.frame_position=ReadBlobLong(image);
658
658
      offset+=4;
659
659
      if (cin.film.frame_position != ~0UL)
660
 
        (void) FormatImageProperty(image,"cin:film.frame_position","%.20g",
661
 
          (double) cin.film.frame_position);
 
660
        (void) FormatImageProperty(image,"cin:film.frame_position","%lu",
 
661
          cin.film.frame_position);
662
662
      cin.film.frame_rate=ReadBlobFloat(image);
663
663
      offset+=4;
664
664
      if (IsFloatDefined(cin.film.frame_rate) != MagickFalse)
687
687
      (void) SetImageProfile(image,"cin:user.data",profile);
688
688
      profile=DestroyStringInfo(profile);
689
689
    }
690
 
  for ( ; offset < (ssize_t) cin.file.image_offset; offset++)
 
690
  for ( ; offset < (long) cin.file.image_offset; offset++)
691
691
    (void) ReadBlobByte(image);
692
692
  image->depth=cin.image.channel[0].bits_per_pixel;
693
693
  image->columns=cin.image.channel[0].pixels_per_line;
714
714
      quantum_type=GrayQuantum;
715
715
      length=GetBytesPerRow(image->columns,1,image->depth,MagickTrue);
716
716
    }
717
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
717
  for (y=0; y < (long) image->rows; y++)
718
718
  {
719
719
    q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
720
720
    if (q == (PixelPacket *) NULL)
728
728
      break;
729
729
    if (image->previous == (Image *) NULL)
730
730
      {
731
 
        status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
732
 
                image->rows);
 
731
        status=SetImageProgress(image,LoadImageTag,y,image->rows);
733
732
        if (status == MagickFalse)
734
733
          break;
735
734
      }
763
762
%
764
763
%  The format of the RegisterCINImage method is:
765
764
%
766
 
%      size_t RegisterCINImage(void)
 
765
%      unsigned long RegisterCINImage(void)
767
766
%
768
767
*/
769
 
ModuleExport size_t RegisterCINImage(void)
 
768
ModuleExport unsigned long RegisterCINImage(void)
770
769
{
771
770
  MagickInfo
772
771
    *entry;
853
852
  const StringInfo
854
853
    *profile;
855
854
 
856
 
  ssize_t
 
855
  long
857
856
    y;
858
857
 
859
858
  MagickBooleanType
871
870
  register const PixelPacket
872
871
    *p;
873
872
 
874
 
  register ssize_t
 
873
  register long
875
874
    i;
876
875
 
877
876
  size_t
909
908
  (void) ResetMagickMemory(&cin,0,sizeof(cin));
910
909
  offset=0;
911
910
  cin.file.magic=0x802A5FD7UL;
912
 
  offset+=WriteBlobLong(image,(unsigned int) cin.file.magic);
 
911
  offset+=WriteBlobLong(image,cin.file.magic);
913
912
  cin.file.image_offset=0x800;
914
913
  profile=GetImageProfile(image,"cin:user.data");
915
914
  if (profile != (StringInfo *) NULL)
916
915
    {
917
 
      cin.file.image_offset+=(size_t) GetStringInfoLength(profile);
 
916
      cin.file.image_offset+=(unsigned long) GetStringInfoLength(profile);
918
917
      cin.file.image_offset=(((cin.file.image_offset+0x2000-1)/0x2000)*0x2000);
919
918
    }
920
 
  offset+=WriteBlobLong(image,(unsigned int) cin.file.image_offset);
 
919
  offset+=WriteBlobLong(image,cin.file.image_offset);
921
920
  cin.file.generic_length=0x400;
922
 
  offset+=WriteBlobLong(image,(unsigned int) cin.file.generic_length);
 
921
  offset+=WriteBlobLong(image,cin.file.generic_length);
923
922
  cin.file.industry_length=0x400;
924
 
  offset+=WriteBlobLong(image,(unsigned int) cin.file.industry_length);
 
923
  offset+=WriteBlobLong(image,cin.file.industry_length);
925
924
  cin.file.user_length=0x00;
926
925
  if (profile != (StringInfo *) NULL)
927
926
    {
928
 
      cin.file.user_length+=(size_t) GetStringInfoLength(profile);
 
927
      cin.file.user_length+=(unsigned long) GetStringInfoLength(profile);
929
928
      cin.file.user_length=(((cin.file.user_length+0x2000-1)/0x2000)*0x2000);
930
929
    }
931
 
  offset+=WriteBlobLong(image,(unsigned int) cin.file.user_length);
 
930
  offset+=WriteBlobLong(image,cin.file.user_length);
932
931
  cin.file.file_size=4*image->columns*image->rows+0x2000;
933
 
  offset+=WriteBlobLong(image,(unsigned int) cin.file.file_size);
 
932
  offset+=WriteBlobLong(image,cin.file.file_size);
934
933
  (void) CopyMagickString(cin.file.version,"V4.5",sizeof(cin.file.version));
935
934
  offset+=WriteBlob(image,sizeof(cin.file.version),(unsigned char *)
936
935
    cin.file.version);
974
973
    offset+=WriteBlobByte(image,cin.image.channel[0].bits_per_pixel);
975
974
    offset+=WriteBlobByte(image,cin.image.channel[0].reserve);
976
975
    cin.image.channel[i].pixels_per_line=image->columns;
977
 
    offset+=WriteBlobLong(image,(unsigned int)
978
 
      cin.image.channel[0].pixels_per_line);
 
976
    offset+=WriteBlobLong(image,cin.image.channel[0].pixels_per_line);
979
977
    cin.image.channel[i].lines_per_image=image->rows;
980
 
    offset+=WriteBlobLong(image,(unsigned int)
981
 
      cin.image.channel[0].lines_per_image);
 
978
    offset+=WriteBlobLong(image,cin.image.channel[0].lines_per_image);
982
979
    cin.image.channel[i].min_data=0;
983
980
    offset+=WriteBlobFloat(image,cin.image.channel[0].min_data);
984
981
    cin.image.channel[i].min_quantity=0.0;
1009
1006
  */
1010
1007
  cin.data_format.interleave=0; /* pixel interleave (rgbrgbr...) */
1011
1008
  offset+=WriteBlobByte(image,cin.data_format.interleave);
1012
 
  cin.data_format.packing=5; /* packing ssize_tword (32bit) boundaries */
 
1009
  cin.data_format.packing=5; /* packing longword (32bit) boundaries */
1013
1010
  offset+=WriteBlobByte(image,cin.data_format.packing);
1014
1011
  cin.data_format.sign=0; /* unsigned data */
1015
1012
  offset+=WriteBlobByte(image,cin.data_format.sign);
1016
1013
  cin.data_format.sense=0; /* image sense: positive image */
1017
1014
  offset+=WriteBlobByte(image,cin.data_format.sense);
1018
1015
  cin.data_format.line_pad=0;
1019
 
  offset+=WriteBlobLong(image,(unsigned int) cin.data_format.line_pad);
 
1016
  offset+=WriteBlobLong(image,cin.data_format.line_pad);
1020
1017
  cin.data_format.channel_pad=0;
1021
 
  offset+=WriteBlobLong(image,(unsigned int) cin.data_format.channel_pad);
 
1018
  offset+=WriteBlobLong(image,cin.data_format.channel_pad);
1022
1019
  offset+=WriteBlob(image,sizeof(cin.data_format.reserve),(unsigned char *)
1023
1020
    cin.data_format.reserve);
1024
1021
  /*
1028
1025
  value=GetCINProperty(image_info,image,"cin:origination.x_offset");
1029
1026
  if (value != (const char *) NULL)
1030
1027
    cin.origination.x_offset=StringToLong(value);
1031
 
  offset+=WriteBlobLong(image,(unsigned int) cin.origination.x_offset);
 
1028
  offset+=WriteBlobLong(image,(unsigned long) cin.origination.x_offset);
1032
1029
  cin.origination.y_offset=0UL;
1033
1030
  value=GetCINProperty(image_info,image,"cin:origination.y_offset");
1034
1031
  if (value != (const char *) NULL)
1035
1032
    cin.origination.y_offset=StringToLong(value);
1036
 
  offset+=WriteBlobLong(image,(unsigned int) cin.origination.y_offset);
 
1033
  offset+=WriteBlobLong(image,(unsigned long) cin.origination.y_offset);
1037
1034
  value=GetCINProperty(image_info,image,"cin:origination.filename");
1038
1035
  if (value != (const char *) NULL)
1039
1036
    (void) CopyMagickString(cin.origination.filename,value,
1107
1104
  value=GetCINProperty(image_info,image,"cin:film.prefix");
1108
1105
  if (value != (const char *) NULL)
1109
1106
    cin.film.prefix=StringToUnsignedLong(value);
1110
 
  offset+=WriteBlobLong(image,(unsigned int) cin.film.prefix);
 
1107
  offset+=WriteBlobLong(image,cin.film.prefix);
1111
1108
  cin.film.count=0UL;
1112
1109
  value=GetCINProperty(image_info,image,"cin:film.count");
1113
1110
  if (value != (const char *) NULL)
1114
1111
    cin.film.count=StringToUnsignedLong(value);
1115
 
  offset+=WriteBlobLong(image,(unsigned int) cin.film.count);
 
1112
  offset+=WriteBlobLong(image,cin.film.count);
1116
1113
  value=GetCINProperty(image_info,image,"cin:film.format");
1117
1114
  if (value != (const char *) NULL)
1118
1115
    (void) CopyMagickString(cin.film.format,value,sizeof(cin.film.format));
1122
1119
  value=GetCINProperty(image_info,image,"cin:film.frame_position");
1123
1120
  if (value != (const char *) NULL)
1124
1121
    cin.film.frame_position=StringToUnsignedLong(value);
1125
 
  offset+=WriteBlobLong(image,(unsigned int) cin.film.frame_position);
 
1122
  offset+=WriteBlobLong(image,cin.film.frame_position);
1126
1123
  cin.film.frame_rate=0.0f;
1127
1124
  value=GetCINProperty(image_info,image,"cin:film.frame_rate");
1128
1125
  if (value != (const char *) NULL)
1162
1159
      quantum_type=GrayQuantum;
1163
1160
      length=GetBytesPerRow(image->columns,3,image->depth,MagickTrue);
1164
1161
    }
1165
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
1162
  for (y=0; y < (long) image->rows; y++)
1166
1163
  {
1167
1164
    p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
1168
1165
    if (p == (const PixelPacket *) NULL)
1172
1169
    count=WriteBlob(image,length,pixels);
1173
1170
    if (count != (ssize_t) length)
1174
1171
      break;
1175
 
    status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1176
 
                image->rows);
 
1172
    status=SetImageProgress(image,SaveImageTag,y,image->rows);
1177
1173
    if (status == MagickFalse)
1178
1174
      break;
1179
1175
  }