~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to toolbin/tests/fuzzy.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * Fuzzy comparison utility. Copyright 2001-2003 Artifex Software, Inc.
 
2
 * Fuzzy comparison utility. Copyright 2001-2008 Artifex Software, Inc.
3
3
 **/
4
4
 
5
5
#include <stdio.h>
211
211
  val[3] = (uchar)((v >> 24) & 0xff);
212
212
  fwrite(val, 4, 1, f);
213
213
}
214
 
    
 
214
 
215
215
static int
216
216
seek_bmp_image(Image *self, int y)
217
217
{
266
266
        int k;
267
267
 
268
268
        memset(linebuf, 0, raster);
269
 
        
 
269
 
270
270
        for (k = 0; k < pnm->super.height; k++)
271
271
            fwrite(linebuf, 1, raster, pnm->f);
272
 
        
 
272
 
273
273
        free(linebuf);
274
274
    }
275
275
  }
276
 
  
 
276
 
277
277
  return pnm;
278
278
}
279
279
 
355
355
      if (fgets (linebuf, sizeof(linebuf), image->f) == NULL)
356
356
          return 1;
357
357
      if (linebuf[0] == '#')
358
 
          continue; 
 
358
          continue;
359
359
      if (sscanf(linebuf, "%d", &maxval) != 1 || maxval <= 0 || maxval > 255)
360
360
          return 1;
361
361
    }
487
487
  if (image_out != NULL)
488
488
    {
489
489
      out_buf = malloc(out_buffer_size);
490
 
      if (out_buf == NULL) 
 
490
      if (out_buf == NULL)
491
491
        printf ("Can't allocate output buffer.\n");
492
492
    }
493
493
 
494
494
  /* Read rows ahead for half window : */
495
 
  for (y = 0; y < MIN(half_win, height); y++) 
 
495
  for (y = 0; y < MIN(half_win, height); y++)
496
496
    {
497
497
       if (image_get_rgb_scan_line_with_error (image1, buf1[half_win - y], 1, y, &rcode))
498
498
            goto ex;
501
501
    }
502
502
  /* Initialie remaining scanlines if height < half_win */
503
503
  for (; y < half_win; y++) {
504
 
    memcpy(buf1[half_win - y], buf1[half_win], width * 3); 
 
504
    memcpy(buf1[half_win - y], buf1[half_win], width * 3);
505
505
    memcpy(buf2[half_win - y], buf2[half_win], width * 3);
506
506
  }
507
507
 
514
514
  }
515
515
 
516
516
  /* Do compare : */
517
 
  freport->n_diff = 0;
518
 
  freport->n_outof_tolerance = 0;
519
 
  freport->n_outof_window = 0;
520
 
 
521
517
  for (y = 0; y < height; y++)
522
518
    {
523
519
      int x;
536
532
      if (out_buf)
537
533
        memset(out_buf, 0, out_buffer_size);
538
534
 
539
 
      if (memcmp(rowmid1, rowmid2, width * 3)) 
 
535
      if (memcmp(rowmid1, rowmid2, width * 3))
540
536
        {
541
537
          for (x = 0; x < width; x++)
542
538
            {
557
553
                          out_buf[x * 3 + 1] = abs(rowmid1[x * 3 + 1]- rowmid2[x * 3 + 1]);
558
554
                          out_buf[x * 3 + 2] = abs(rowmid1[x * 3 + 2]- rowmid2[x * 3 + 2]);
559
555
                        }
560
 
                        if (fparams->report_coordinates && 
 
556
                        if (fparams->report_coordinates &&
561
557
                            (abs(x - x0) > 1 && y == y0 || y - y0 > 1))
562
558
                          {
563
559
                            /* fixme : a contiguity test wanted. */
609
605
  free_window (buf2, window_size);
610
606
  if (out_buf)
611
607
    free(out_buf);
612
 
  if (image_out)
613
 
    fclose(image_out->f);
614
608
  return rcode;
615
609
}
616
610
 
706
700
      }
707
701
  }
708
702
 
709
 
  while (!image1->feof_(image1) || !image2->feof_(image2)) 
710
 
  { 
711
 
    if (image1->feof_(image1)) 
 
703
  while (!image1->feof_(image1) || !image2->feof_(image2))
 
704
  {
 
705
    if (image1->feof_(image1))
712
706
    {
713
707
      printf ("Extra data (maybe pages) in the image file 2.\n");
714
708
      return 1;
715
709
    }
716
 
    if (image2->feof_(image2)) 
 
710
    if (image2->feof_(image2))
717
711
    {
718
712
      printf ("Extra data (maybe pages) in the image file 1.\n");
719
713
      return 1;
730
724
      return 1;
731
725
    }
732
726
    if (image1->width != image2->width) {
733
 
        printf("Diffenert image width for page %d\n", page);
 
727
        printf("Different image width for page %d\n", page);
734
728
        rcode = MAX(rcode, 1);
735
729
    }
736
730
    if (image1->height != image2->height) {
737
 
        printf("Diffenert image height for page %d\n", page);
 
731
        printf("Different image height for page %d\n", page);
738
732
        rcode = MAX(rcode, 1);
739
733
    }
740
734
    if (out_fn != NULL) {
754
748
          out_fn[i + 4] = c;
755
749
      } else
756
750
          sprintf(out_fn + l, "-%03d", page);
757
 
      image_out = 
 
751
      image_out =
758
752
       (!strcmp(fn[2]+ strlen(fn[2]) - 4, ".bmp") ? create_bmp_image
759
753
                                                  : create_pnm_image)
760
754
           (image1, out_fn);
761
755
    } else
762
756
      image_out = NULL;
 
757
 
 
758
    freport.n_diff = 0;
 
759
    freport.n_outof_tolerance = 0;
 
760
    freport.n_outof_window = 0;
763
761
    if (fuzzy_diff_images (image1, image2, &fparams, &freport, image_out))
764
762
        return 1;
765
763
    if (image_out)