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

« back to all changes in this revision

Viewing changes to coders/xcf.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:
107
107
 
108
108
typedef struct
109
109
{
110
 
  size_t
 
110
  unsigned long
111
111
    width,
112
112
    height,
113
113
    image_type,
131
131
  unsigned int
132
132
    active;
133
133
 
134
 
  size_t
 
134
  unsigned long
135
135
    width,
136
136
    height,
137
137
    type,
148
148
    offset_x,
149
149
    offset_y;
150
150
 
151
 
  size_t
 
151
  unsigned long
152
152
    mode,
153
153
    tattoo;
154
154
 
231
231
  ImageMagick compositing operators
232
232
*/
233
233
static CompositeOperator GIMPBlendModeToCompositeOperator(
234
 
  size_t blendMode)
 
234
  unsigned long blendMode)
235
235
{
236
236
  switch ( blendMode )
237
237
  {
272
272
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
273
273
%
274
274
%  ReadBlobStringWithLongSize reads characters from a blob or file
275
 
%  starting with a ssize_t length byte and then characters to that length
 
275
%  starting with a long length byte and then characters to that length
276
276
%
277
277
%  The format of the ReadBlobStringWithLongSize method is:
278
278
%
301
301
  MagickOffsetType
302
302
    offset;
303
303
 
304
 
  register ssize_t
 
304
  register long
305
305
    i;
306
306
 
307
 
  size_t
 
307
  unsigned long
308
308
    length;
309
309
 
310
310
  assert(image != (Image *) NULL);
313
313
  if (image->debug != MagickFalse)
314
314
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
315
315
  length=ReadBlobMSBLong(image);
316
 
  for (i=0; i < (ssize_t) MagickMin(length,max-1); i++)
 
316
  for (i=0; i < (long) MagickMin(length,max-1); i++)
317
317
  {
318
318
    c=ReadBlobByte(image);
319
319
    if (c == EOF)
334
334
  ExceptionInfo
335
335
    *exception;
336
336
 
337
 
  ssize_t
 
337
  long
338
338
    y;
339
339
 
340
 
  register ssize_t
 
340
  register long
341
341
    x;
342
342
 
343
343
  register PixelPacket
364
364
    ThrowBinaryException(CorruptImageError,"NotEnoughPixelData",
365
365
      image->filename);
366
366
  exception=(&image->exception);
367
 
  for (y=0; y < (ssize_t) tile_image->rows; y++)
 
367
  for (y=0; y < (long) tile_image->rows; y++)
368
368
  {
369
369
    q=QueueAuthenticPixels(tile_image,0,y,tile_image->columns,1,exception);
370
370
    if (q == (PixelPacket *) NULL)
371
371
      break;
372
372
    if (inDocInfo->image_type == GIMP_GRAY)
373
373
      {
374
 
        for (x=0; x < (ssize_t) tile_image->columns; x++)
 
374
        for (x=0; x < (long) tile_image->columns; x++)
375
375
        {
376
376
          q->red=ScaleCharToQuantum(*graydata);
377
377
          q->green=q->red;
378
378
          q->blue=q->red;
379
 
          q->opacity=ScaleCharToQuantum((unsigned char) (255-
380
 
            inLayerInfo->opacity));
 
379
          q->opacity=ScaleCharToQuantum(255-inLayerInfo->opacity);
381
380
          graydata++;
382
381
          q++;
383
382
        }
385
384
    else
386
385
      if (inDocInfo->image_type == GIMP_RGB)
387
386
        {
388
 
          for (x=0; x < (ssize_t) tile_image->columns; x++)
 
387
          for (x=0; x < (long) tile_image->columns; x++)
389
388
          {
390
389
            q->red=ScaleCharToQuantum(xcfdata->red);
391
390
            q->green=ScaleCharToQuantum(xcfdata->green);
392
391
            q->blue=ScaleCharToQuantum(xcfdata->blue);
393
392
            q->opacity=(Quantum) (xcfdata->opacity == 0U ? TransparentOpacity :
394
 
              ScaleCharToQuantum((unsigned char) (255-inLayerInfo->opacity)));
 
393
              ScaleCharToQuantum(255-inLayerInfo->opacity));
395
394
            xcfdata++;
396
395
            q++;
397
396
          }
409
408
  ExceptionInfo
410
409
    *exception;
411
410
 
412
 
  ssize_t
 
411
  long
413
412
    i,
414
413
    j;
415
414
 
442
441
  count=ReadBlob(image, (size_t) data_length, xcfdata);
443
442
  xcfdatalimit = xcfodata+count-1;
444
443
  exception=(&image->exception);
445
 
  for (i=0; i < (ssize_t) bytes_per_pixel; i++)
 
444
  for (i=0; i < (long) bytes_per_pixel; i++)
446
445
  {
447
446
    q=GetAuthenticPixels(tile_image,0,0,tile_image->columns,tile_image->rows,exception);
448
447
    size=(MagickOffsetType) tile_image->rows*tile_image->columns;
479
478
                    {
480
479
                      q->green=ScaleCharToQuantum(data);
481
480
                      q->blue=ScaleCharToQuantum(data);
482
 
                      q->opacity=ScaleCharToQuantum((unsigned char) (255-
483
 
                        inLayerInfo->opacity));
 
481
                      q->opacity=ScaleCharToQuantum(255-inLayerInfo->opacity);
484
482
                    }
485
483
                  else
486
484
                    {
487
485
                      q->green= q->red;
488
486
                      q->blue= q->red;
489
 
                      q->opacity=ScaleCharToQuantum((unsigned char) (255-
490
 
                        inLayerInfo->opacity));
 
487
                      q->opacity=ScaleCharToQuantum(255-inLayerInfo->opacity);
491
488
                    }
492
489
                  break;
493
490
                }
504
501
                case 3:
505
502
                {
506
503
                  q->opacity=(Quantum) (data == 0 ? TransparentOpacity :
507
 
                    ScaleCharToQuantum((unsigned char) (255-
508
 
                    inLayerInfo->opacity)));
 
504
                    ScaleCharToQuantum(255-inLayerInfo->opacity));
509
505
                  break;
510
506
                }
511
507
              }
528
524
            if (xcfdata > xcfdatalimit)
529
525
              goto bogus_rle;
530
526
            pixel=(*xcfdata++);
531
 
            for (j= 0; j < (ssize_t) length; j++)
 
527
            for (j= 0; j < (long) length; j++)
532
528
            {
533
529
              data=pixel;
534
530
              switch (i)
540
536
                    {
541
537
                      q->green=ScaleCharToQuantum(data);
542
538
                      q->blue=ScaleCharToQuantum(data);
543
 
                      q->opacity=ScaleCharToQuantum((unsigned char) (255-
544
 
                        inLayerInfo->opacity));
 
539
                      q->opacity=ScaleCharToQuantum(255-inLayerInfo->opacity);
545
540
                    }
546
541
                  else
547
542
                    {
548
543
                      q->green=q->red;
549
544
                      q->blue=q->red;
550
 
                      q->opacity=ScaleCharToQuantum((unsigned char) (255-
551
 
                        inLayerInfo->opacity));
 
545
                      q->opacity=ScaleCharToQuantum(255-inLayerInfo->opacity);
552
546
                    }
553
547
                  break;
554
548
                }
565
559
                case 3:
566
560
                {
567
561
                  q->opacity=(Quantum) (data == 0 ? TransparentOpacity :
568
 
                    ScaleCharToQuantum((unsigned char) (255-
569
 
                    inLayerInfo->opacity)));
 
562
                    ScaleCharToQuantum(255-inLayerInfo->opacity));
570
563
                  break;
571
564
                }
572
565
              }
607
600
    offset,
608
601
    offset2;
609
602
 
610
 
  register ssize_t
 
603
  register long
611
604
    i;
612
605
 
613
 
  size_t
 
606
  unsigned long
614
607
    width,
615
608
    height,
616
609
    ntiles,
636
629
  ntile_rows=(height+TILE_HEIGHT-1)/TILE_HEIGHT;
637
630
  ntile_cols=(width+TILE_WIDTH-1)/TILE_WIDTH;
638
631
  ntiles=ntile_rows*ntile_cols;
639
 
  for (i = 0; i < (ssize_t) ntiles; i++)
 
632
  for (i = 0; i < (long) ntiles; i++)
640
633
  {
641
634
    status=MagickFalse;
642
635
    if (offset == 0)
658
651
      /* allocate the image for the tile
659
652
        NOTE: the last tile in a row or column may not be a full tile!
660
653
      */
661
 
      tile_image_width=(size_t) (destLeft == (int) ntile_cols-1 ?
 
654
      tile_image_width=(unsigned long) (destLeft == (int) ntile_cols-1 ?
662
655
        (int) width % TILE_WIDTH : TILE_WIDTH);
663
656
      if (tile_image_width == 0) tile_image_width=TILE_WIDTH;
664
 
      tile_image_height = (size_t) (destTop == (int) ntile_rows-1 ?
 
657
      tile_image_height = (unsigned long) (destTop == (int) ntile_rows-1 ?
665
658
        (int) height % TILE_HEIGHT : TILE_HEIGHT);
666
659
      if (tile_image_height == 0) tile_image_height=TILE_HEIGHT;
667
660
      tile_image=CloneImage(inLayerInfo->image,tile_image_width,
721
714
    offset,
722
715
    junk;
723
716
 
724
 
  size_t
 
717
  unsigned long
725
718
    width,
726
719
    height,
727
720
    bytes_per_pixel;
765
758
static MagickBooleanType ReadOneLayer(Image* image,XCFDocInfo* inDocInfo,
766
759
  XCFLayerInfo *outLayer )
767
760
{
768
 
  ssize_t
 
761
  long
769
762
    i;
770
763
 
771
764
  MagickOffsetType
774
767
  unsigned int
775
768
    foundPropEnd = 0;
776
769
 
777
 
  size_t
 
770
  unsigned long
778
771
    hierarchy_offset,
779
772
    layer_mask_offset;
780
773
 
795
788
  foundPropEnd = 0;
796
789
  while ( (foundPropEnd == MagickFalse) && (EOFBlob(image) == MagickFalse) ) {
797
790
  PropType    prop_type = (PropType) ReadBlobMSBLong(image);
798
 
  size_t  prop_size = ReadBlobMSBLong(image);
 
791
  unsigned long  prop_size = ReadBlobMSBLong(image);
799
792
    switch (prop_type)
800
793
    {
801
794
    case PROP_END:
829
822
      outLayer->show_mask = ReadBlobMSBLong(image);
830
823
      break;
831
824
    case PROP_OFFSETS:
832
 
      outLayer->offset_x = (ssize_t) ReadBlobMSBLong(image);
833
 
      outLayer->offset_y = (ssize_t) ReadBlobMSBLong(image);
 
825
      outLayer->offset_x = (long) ReadBlobMSBLong(image);
 
826
      outLayer->offset_y = (long) ReadBlobMSBLong(image);
834
827
      break;
835
828
    case PROP_MODE:
836
829
      outLayer->mode = ReadBlobMSBLong(image);
840
833
      break;
841
834
     case PROP_PARASITES:
842
835
     {
843
 
        for (i=0; i < (ssize_t) prop_size; i++ )
 
836
        for (i=0; i < (long) prop_size; i++ )
844
837
          (void) ReadBlobByte(image);
845
838
 
846
839
        /*
847
 
       ssize_t base = info->cp;
 
840
       long base = info->cp;
848
841
       GimpParasite *p;
849
842
       while (info->cp - base < prop_size)
850
843
       {
873
866
        if (!amount)
874
867
          ThrowBinaryException(CorruptImageError,"CorruptImage",
875
868
            image->filename);
876
 
        prop_size -= (size_t) MagickMin(16, (size_t) amount);
 
869
        prop_size -= (unsigned long) MagickMin(16, (size_t) amount);
877
870
        }
878
871
      }
879
872
      break;
987
980
  MagickOffsetType
988
981
    offset;
989
982
 
990
 
  register ssize_t
 
983
  register long
991
984
    i;
992
985
 
993
986
  size_t
996
989
  ssize_t
997
990
    count;
998
991
 
999
 
  size_t
 
992
  unsigned long
1000
993
    image_type;
1001
994
 
1002
995
  XCFDocInfo
1055
1048
  while ((foundPropEnd == MagickFalse) && (EOFBlob(image) == MagickFalse))
1056
1049
  {
1057
1050
    PropType prop_type = (PropType) ReadBlobMSBLong(image);
1058
 
    size_t prop_size = ReadBlobMSBLong(image);
 
1051
    unsigned long prop_size = ReadBlobMSBLong(image);
1059
1052
 
1060
1053
    switch (prop_type)
1061
1054
    {
1067
1060
        /* Cannot rely on prop_size here--the value is set incorrectly
1068
1061
           by some Gimp versions.
1069
1062
        */
1070
 
        size_t num_colours = ReadBlobMSBLong(image);
1071
 
        for (i=0; i < (ssize_t) (3L*num_colours); i++ )
 
1063
        unsigned long num_colours = ReadBlobMSBLong(image);
 
1064
        for (i=0; i < (long) (3L*num_colours); i++ )
1072
1065
          (void) ReadBlobByte(image);
1073
1066
    /*
1074
1067
      if (info->file_version == 0)
1115
1108
      case PROP_GUIDES:
1116
1109
      {
1117
1110
         /* just skip it - we don't care about guides */
1118
 
        for (i=0; i < (ssize_t) prop_size; i++ )
 
1111
        for (i=0; i < (long) prop_size; i++ )
1119
1112
          if (ReadBlobByte(image) == EOF)
1120
1113
            ThrowFileException(exception,CorruptImageError,
1121
1114
              "UnexpectedEndOfFile",image->filename);
1149
1142
    case PROP_TATTOO:
1150
1143
      {
1151
1144
        /* we need to read it, even if we ignore it */
1152
 
        /*size_t  tattoo_state = */ (void) ReadBlobMSBLong(image);
 
1145
        /*unsigned long  tattoo_state = */ (void) ReadBlobMSBLong(image);
1153
1146
      }
1154
1147
      break;
1155
1148
 
1156
1149
    case PROP_PARASITES:
1157
1150
      {
1158
1151
        /* BOGUS: we may need these for IPTC stuff */
1159
 
        for (i=0; i < (ssize_t) prop_size; i++ )
 
1152
        for (i=0; i < (long) prop_size; i++ )
1160
1153
          if (ReadBlobByte(image) == EOF)
1161
1154
            ThrowFileException(exception,CorruptImageError,
1162
1155
              "UnexpectedEndOfFile",image->filename);
1163
1156
 
1164
1157
        /*
1165
 
      gssize_t         base = info->cp;
 
1158
      glong         base = info->cp;
1166
1159
      GimpParasite *p;
1167
1160
 
1168
1161
      while (info->cp - base < prop_size)
1180
1173
    case PROP_UNIT:
1181
1174
      {
1182
1175
        /* BOGUS: ignore for now... */
1183
 
      /*size_t unit =  */ (void) ReadBlobMSBLong(image);
 
1176
      /*unsigned long unit =  */ (void) ReadBlobMSBLong(image);
1184
1177
      }
1185
1178
      break;
1186
1179
 
1187
1180
    case PROP_PATHS:
1188
1181
      {
1189
1182
      /* BOGUS: just skip it for now */
1190
 
        for (i=0; i< (ssize_t) prop_size; i++ )
 
1183
        for (i=0; i< (long) prop_size; i++ )
1191
1184
          if (ReadBlobByte(image) == EOF)
1192
1185
            ThrowFileException(exception,CorruptImageError,
1193
1186
              "UnexpectedEndOfFile",image->filename);
1204
1197
        char  unit_string[1000];
1205
1198
        /*BOGUS: ignored for now */
1206
1199
        /*float  factor = (float) */ (void) ReadBlobMSBLong(image);
1207
 
        /* size_t digits =  */ (void) ReadBlobMSBLong(image);
 
1200
        /* unsigned long digits =  */ (void) ReadBlobMSBLong(image);
1208
1201
        for (i=0; i<5; i++)
1209
1202
         (void) ReadBlobStringWithLongSize(image, unit_string,
1210
1203
           sizeof(unit_string));
1214
1207
      default:
1215
1208
      {
1216
1209
        int buf[16];
1217
 
        ssize_t amount;
 
1210
        long amount;
1218
1211
 
1219
1212
      /* read over it... */
1220
1213
      while ((prop_size > 0) && (EOFBlob(image) == MagickFalse))
1221
1214
      {
1222
 
        amount=(ssize_t) MagickMin(16, prop_size);
1223
 
        amount=(ssize_t) ReadBlob(image,(size_t) amount,(unsigned char *) &buf);
 
1215
        amount=(long) MagickMin(16, prop_size);
 
1216
        amount=(long) ReadBlob(image,(size_t) amount,(unsigned char *) &buf);
1224
1217
        if (!amount)
1225
1218
          ThrowReaderException(CorruptImageError,"CorruptImage");
1226
 
        prop_size -= (size_t) MagickMin(16,(size_t) amount);
 
1219
        prop_size -= (unsigned long) MagickMin(16,(size_t) amount);
1227
1220
      }
1228
1221
    }
1229
1222
    break;
1254
1247
      */
1255
1248
      do
1256
1249
      {
1257
 
        ssize_t offset = (ssize_t) ReadBlobMSBLong(image);
 
1250
        long offset = (long) ReadBlobMSBLong(image);
1258
1251
        if (offset == 0)
1259
1252
          foundAllLayers=MagickTrue;
1260
1253
        else
1452
1445
%
1453
1446
%  The format of the RegisterXCFImage method is:
1454
1447
%
1455
 
%      size_t RegisterXCFImage(void)
 
1448
%      unsigned long RegisterXCFImage(void)
1456
1449
%
1457
1450
*/
1458
 
ModuleExport size_t RegisterXCFImage(void)
 
1451
ModuleExport unsigned long RegisterXCFImage(void)
1459
1452
{
1460
1453
  MagickInfo
1461
1454
    *entry;