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

« back to all changes in this revision

Viewing changes to coders/jbig.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-private.h"
45
45
#include "magick/cache.h"
46
46
#include "magick/color-private.h"
47
 
#include "magick/colormap.h"
48
47
#include "magick/colorspace.h"
49
48
#include "magick/constitute.h"
50
49
#include "magick/exception.h"
111
110
  IndexPacket
112
111
    index;
113
112
 
114
 
  ssize_t
 
113
  long
115
114
    length,
116
115
    y;
117
116
 
121
120
  register IndexPacket
122
121
    *indexes;
123
122
 
124
 
  register ssize_t
 
123
  register long
125
124
    x;
126
125
 
127
126
  register PixelPacket
179
178
  status=JBG_EAGAIN;
180
179
  do
181
180
  {
182
 
    length=(ssize_t) ReadBlob(image,MagickMaxBufferExtent,buffer);
 
181
    length=(long) ReadBlob(image,MagickMaxBufferExtent,buffer);
183
182
    if (length == 0)
184
183
      break;
185
184
    p=buffer;
191
190
 
192
191
      status=jbg_dec_in(&jbig_info,p,length,&count);
193
192
      p+=count;
194
 
      length-=(ssize_t) count;
 
193
      length-=(long) count;
195
194
    }
196
195
  } while ((status == JBG_EAGAIN) || (status == JBG_EOK));
197
196
  /*
221
220
    Convert X bitmap image to pixel packets.
222
221
  */
223
222
  p=jbg_dec_getimage(&jbig_info,0);
224
 
  for (y=0; y < (ssize_t) image->rows; y++)
 
223
  for (y=0; y < (long) image->rows; y++)
225
224
  {
226
225
    q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
227
226
    if (q == (PixelPacket *) NULL)
229
228
    indexes=GetAuthenticIndexQueue(image);
230
229
    bit=0;
231
230
    byte=0;
232
 
    for (x=0; x < (ssize_t) image->columns; x++)
 
231
    for (x=0; x < (long) image->columns; x++)
233
232
    {
234
233
      if (bit == 0)
235
234
        byte=(*p++);
239
238
      if (bit == 8)
240
239
        bit=0;
241
240
      indexes[x]=index;
242
 
      *q++=image->colormap[(ssize_t) index];
 
241
      *q++=image->colormap[(long) index];
243
242
    }
244
243
    if (SyncAuthenticPixels(image,exception) == MagickFalse)
245
244
      break;
246
 
    status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
247
 
                image->rows);
 
245
    status=SetImageProgress(image,LoadImageTag,y,image->rows);
248
246
    if (status == MagickFalse)
249
247
      break;
250
248
  }
278
276
%
279
277
%  The format of the RegisterJBIGImage method is:
280
278
%
281
 
%      size_t RegisterJBIGImage(void)
 
279
%      unsigned long RegisterJBIGImage(void)
282
280
%
283
281
*/
284
 
ModuleExport size_t RegisterJBIGImage(void)
 
282
ModuleExport unsigned long RegisterJBIGImage(void)
285
283
{
286
284
#define JBIGDescription  "Joint Bi-level Image experts Group interchange format"
287
285
 
397
395
  double
398
396
    version;
399
397
 
400
 
  ssize_t
 
398
  long
401
399
    y;
402
400
 
403
401
  MagickBooleanType
412
410
  register const PixelPacket
413
411
    *p;
414
412
 
415
 
  register ssize_t
 
413
  register long
416
414
    x;
417
415
 
418
416
  register unsigned char
426
424
    byte,
427
425
    *pixels;
428
426
 
429
 
  size_t
 
427
  unsigned long
430
428
    number_packets;
431
429
 
432
430
  /*
460
458
    */
461
459
    (void) SetImageType(image,BilevelType);
462
460
    q=pixels;
463
 
    for (y=0; y < (ssize_t) image->rows; y++)
 
461
    for (y=0; y < (long) image->rows; y++)
464
462
    {
465
463
      p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
466
464
      if (p == (const PixelPacket *) NULL)
468
466
      indexes=GetVirtualIndexQueue(image);
469
467
      bit=0;
470
468
      byte=0;
471
 
      for (x=0; x < (ssize_t) image->columns; x++)
 
469
      for (x=0; x < (long) image->columns; x++)
472
470
      {
473
471
        byte<<=1;
474
472
        if (PixelIntensity(p) < (QuantumRange/2.0))
486
484
        *q++=byte << (8-bit);
487
485
      if (image->previous == (Image *) NULL)
488
486
        {
489
 
          status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
490
 
                image->rows);
 
487
          status=SetImageProgress(image,SaveImageTag,y,image->rows);
491
488
          if (status == MagickFalse)
492
489
            break;
493
490
        }
495
492
    /*
496
493
      Initialize JBIG info structure.
497
494
    */
498
 
    jbg_enc_init(&jbig_info,(unsigned long) image->columns,(unsigned long)
499
 
      image->rows,1,&pixels,(void (*)(unsigned char *,size_t,void *))
500
 
      JBIGEncode,image);
 
495
    jbg_enc_init(&jbig_info,image->columns,image->rows,1,&pixels,
 
496
      (void (*)(unsigned char *,size_t,void *)) JBIGEncode,image);
501
497
    if (image_info->scene != 0)
502
498
      jbg_enc_layers(&jbig_info,(int) image_info->scene);
503
499
    else
504
500
      {
505
 
        ssize_t
 
501
        long
506
502
          sans_offset;
507
503
 
508
 
        size_t
 
504
        unsigned long
509
505
          x_resolution,
510
506
          y_resolution;
511
507
 
528
524
          }
529
525
        if (image->units == PixelsPerCentimeterResolution)
530
526
          {
531
 
            x_resolution=(size_t) (100.0*2.54*x_resolution+0.5)/100.0;
532
 
            y_resolution=(size_t) (100.0*2.54*y_resolution+0.5)/100.0;
 
527
            x_resolution*=2.54;
 
528
            y_resolution*=2.54;
533
529
          }
534
 
        (void) jbg_enc_lrlmax(&jbig_info,(unsigned long) x_resolution,
535
 
          (unsigned long) y_resolution);
 
530
        (void) jbg_enc_lrlmax(&jbig_info,x_resolution,y_resolution);
536
531
      }
537
532
    (void) jbg_enc_lrange(&jbig_info,-1,-1);
538
533
    jbg_enc_options(&jbig_info,JBG_ILEAVE | JBG_SMID,JBG_TPDON | JBG_TPBON |