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

« back to all changes in this revision

Viewing changes to coders/rle.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:
44
44
#include "magick/blob.h"
45
45
#include "magick/blob-private.h"
46
46
#include "magick/cache.h"
47
 
#include "magick/colormap.h"
48
47
#include "magick/exception.h"
49
48
#include "magick/exception-private.h"
50
49
#include "magick/image.h"
141
140
    operand,
142
141
    status;
143
142
 
144
 
  ssize_t
 
143
  long
145
144
    y;
146
145
 
147
146
  MagickStatusType
153
152
  register IndexPacket
154
153
    *indexes;
155
154
 
156
 
  register ssize_t
 
155
  register long
157
156
    x;
158
157
 
159
158
  register PixelPacket
160
159
    *q;
161
160
 
162
 
  register ssize_t
 
161
  register long
163
162
    i;
164
163
 
165
164
  register unsigned char
175
174
    plane,
176
175
    *rle_pixels;
177
176
 
178
 
  size_t
 
177
  unsigned long
179
178
    bits_per_pixel,
180
179
    map_length,
181
180
    number_colormaps,
182
 
    number_planes,
183
 
    one;
 
181
    number_planes;
184
182
 
185
183
  /*
186
184
    Open image file.
219
217
    number_planes=1UL*ReadBlobByte(image);
220
218
    bits_per_pixel=1UL*ReadBlobByte(image);
221
219
    number_colormaps=1UL*ReadBlobByte(image);
222
 
    one=1;
223
 
    map_length=one << ReadBlobByte(image);
 
220
    map_length=1UL << ReadBlobByte(image);
224
221
    if ((number_planes == 0) || (number_planes == 2) || (bits_per_pixel != 8) ||
225
222
        (image->columns == 0))
226
223
      ThrowReaderException(CorruptImageError,"ImproperImageHeader");
229
226
        /*
230
227
          No background color-- initialize to black.
231
228
        */
232
 
        for (i=0; i < (ssize_t) number_planes; i++)
 
229
        for (i=0; i < (long) number_planes; i++)
233
230
          background_color[i]=0;
234
231
        (void) ReadBlobByte(image);
235
232
      }
239
236
          Initialize background color.
240
237
        */
241
238
        p=background_color;
242
 
        for (i=0; i < (ssize_t) number_planes; i++)
 
239
        for (i=0; i < (long) number_planes; i++)
243
240
          *p++=(unsigned char) ReadBlobByte(image);
244
241
      }
245
242
    if ((number_planes & 0x01) == 0)
255
252
        if (colormap == (unsigned char *) NULL)
256
253
          ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
257
254
        p=colormap;
258
 
        for (i=0; i < (ssize_t) number_colormaps; i++)
259
 
          for (x=0; x < (ssize_t) map_length; x++)
 
255
        for (i=0; i < (long) number_colormaps; i++)
 
256
          for (x=0; x < (long) map_length; x++)
260
257
            *p++=(unsigned char) ScaleShortToQuantum(ReadBlobLSBShort(image));
261
258
      }
262
259
    if ((flags & 0x08) != 0)
264
261
        char
265
262
          *comment;
266
263
 
267
 
        size_t
 
264
        unsigned long
268
265
          length;
269
266
 
270
267
        /*
301
298
      ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
302
299
    if ((flags & 0x01) && !(flags & 0x02))
303
300
      {
304
 
        ssize_t
 
301
        long
305
302
          j;
306
303
 
307
304
        /*
308
305
          Set background color.
309
306
        */
310
307
        p=rle_pixels;
311
 
        for (i=0; i < (ssize_t) number_pixels; i++)
 
308
        for (i=0; i < (long) number_pixels; i++)
312
309
        {
313
310
          if (image->matte == MagickFalse)
314
 
            for (j=0; j < (ssize_t) number_planes; j++)
 
311
            for (j=0; j < (long) number_planes; j++)
315
312
              *p++=background_color[j];
316
313
          else
317
314
            {
318
 
              for (j=0; j < (ssize_t) (number_planes-1); j++)
 
315
              for (j=0; j < (long) (number_planes-1); j++)
319
316
                *p++=background_color[j];
320
317
              *p++=0;  /* initialize matte channel */
321
318
            }
366
363
          p=rle_pixels+((image->rows-y-1)*image->columns*number_planes)+
367
364
            x*number_planes+plane;
368
365
          operand++;
369
 
          for (i=0; i < (ssize_t) operand; i++)
 
366
          for (i=0; i < (long) operand; i++)
370
367
          {
371
368
            pixel=(unsigned char) ReadBlobByte(image);
372
 
            if ((y < (ssize_t) image->rows) && ((x+i) < (ssize_t) image->columns))
 
369
            if ((y < (long) image->rows) && ((x+i) < (long) image->columns))
373
370
              *p=pixel;
374
371
            p+=number_planes;
375
372
          }
388
385
          operand++;
389
386
          p=rle_pixels+((image->rows-y-1)*image->columns*number_planes)+
390
387
            x*number_planes+plane;
391
 
          for (i=0; i < (ssize_t) operand; i++)
 
388
          for (i=0; i < (long) operand; i++)
392
389
          {
393
 
            if ((y < (ssize_t) image->rows) && ((x+i) < (ssize_t) image->columns))
 
390
            if ((y < (long) image->rows) && ((x+i) < (long) image->columns))
394
391
              *p=pixel;
395
392
            p+=number_planes;
396
393
          }
413
410
        mask=(MagickStatusType) (map_length-1);
414
411
        p=rle_pixels;
415
412
        if (number_colormaps == 1)
416
 
          for (i=0; i < (ssize_t) number_pixels; i++)
 
413
          for (i=0; i < (long) number_pixels; i++)
417
414
          {
418
415
            *p=colormap[*p & mask];
419
416
            p++;
420
417
          }
421
418
        else
422
419
          if ((number_planes >= 3) && (number_colormaps >= 3))
423
 
            for (i=0; i < (ssize_t) number_pixels; i++)
424
 
              for (x=0; x < (ssize_t) number_planes; x++)
 
420
            for (i=0; i < (long) number_pixels; i++)
 
421
              for (x=0; x < (long) number_planes; x++)
425
422
              {
426
423
                *p=colormap[x*map_length+(*p & mask)];
427
424
                p++;
436
433
          Convert raster image to DirectClass pixel packets.
437
434
        */
438
435
        p=rle_pixels;
439
 
        for (y=0; y < (ssize_t) image->rows; y++)
 
436
        for (y=0; y < (long) image->rows; y++)
440
437
        {
441
438
          q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
442
439
          if (q == (PixelPacket *) NULL)
443
440
            break;
444
 
          for (x=0; x < (ssize_t) image->columns; x++)
 
441
          for (x=0; x < (long) image->columns; x++)
445
442
          {
446
443
            q->red=ScaleCharToQuantum(*p++);
447
444
            q->green=ScaleCharToQuantum(*p++);
454
451
            break;
455
452
          if (image->previous == (Image *) NULL)
456
453
            {
457
 
              status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
458
 
                image->rows);
 
454
              status=SetImageProgress(image,LoadImageTag,y,image->rows);
459
455
              if (status == MagickFalse)
460
456
                break;
461
457
            }
472
468
          ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
473
469
        p=colormap;
474
470
        if (number_colormaps == 1)
475
 
          for (i=0; i < (ssize_t) image->colors; i++)
 
471
          for (i=0; i < (long) image->colors; i++)
476
472
          {
477
473
            /*
478
474
              Pseudocolor.
483
479
          }
484
480
        else
485
481
          if (number_colormaps > 1)
486
 
            for (i=0; i < (ssize_t) image->colors; i++)
 
482
            for (i=0; i < (long) image->colors; i++)
487
483
            {
488
484
              image->colormap[i].red=ScaleCharToQuantum(*p);
489
485
              image->colormap[i].green=ScaleCharToQuantum(*(p+map_length));
496
492
            /*
497
493
              Convert raster image to PseudoClass pixel packets.
498
494
            */
499
 
            for (y=0; y < (ssize_t) image->rows; y++)
 
495
            for (y=0; y < (long) image->rows; y++)
500
496
            {
501
497
              q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
502
498
              if (q == (PixelPacket *) NULL)
503
499
                break;
504
500
              indexes=GetAuthenticIndexQueue(image);
505
 
              for (x=0; x < (ssize_t) image->columns; x++)
 
501
              for (x=0; x < (long) image->columns; x++)
506
502
                indexes[x]=(IndexPacket) (*p++);
507
503
              if (SyncAuthenticPixels(image,exception) == MagickFalse)
508
504
                break;
509
505
              if (image->previous == (Image *) NULL)
510
506
                {
511
 
                  status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
512
 
                image->rows);
 
507
                  status=SetImageProgress(image,LoadImageTag,y,image->rows);
513
508
                  if (status == MagickFalse)
514
509
                    break;
515
510
                }
521
516
            /*
522
517
              Image has a matte channel-- promote to DirectClass.
523
518
            */
524
 
            for (y=0; y < (ssize_t) image->rows; y++)
 
519
            for (y=0; y < (long) image->rows; y++)
525
520
            {
526
521
              q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
527
522
              if (q == (PixelPacket *) NULL)
528
523
                break;
529
 
              for (x=0; x < (ssize_t) image->columns; x++)
 
524
              for (x=0; x < (long) image->columns; x++)
530
525
              {
531
526
                q->red=image->colormap[*p++].red;
532
527
                q->green=image->colormap[*p++].green;
538
533
                break;
539
534
              if (image->previous == (Image *) NULL)
540
535
                {
541
 
                  status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
542
 
                image->rows);
 
536
                  status=SetImageProgress(image,LoadImageTag,y,image->rows);
543
537
                  if (status == MagickFalse)
544
538
                    break;
545
539
                }
609
603
%
610
604
%  The format of the RegisterRLEImage method is:
611
605
%
612
 
%      size_t RegisterRLEImage(void)
 
606
%      unsigned long RegisterRLEImage(void)
613
607
%
614
608
*/
615
 
ModuleExport size_t RegisterRLEImage(void)
 
609
ModuleExport unsigned long RegisterRLEImage(void)
616
610
{
617
611
  MagickInfo
618
612
    *entry;