~ubuntu-branches/ubuntu/trusty/netpbm-free/trusty

« back to all changes in this revision

Viewing changes to ppm/ppmtobmp.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2004-07-29 20:25:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040729202546-9o69r65403wvtla5
Tags: 2:10.0-5
* build-depends against libtiff4.
* fix typo in ppmtowinicon. Closes: #261999.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*\
2
 
 * $Id: ppmtobmp.c,v 1.2 2003/08/14 19:38:51 aba-guest Exp $
 
2
 * $Id: ppmtobmp.c,v 1.4 2004/01/17 09:10:18 aba-guest Exp $
3
3
 *
4
4
 * ppmtobmp.c - Converts from a PPM file to a Microsoft Windows or OS/2
5
5
 * .BMP file.
17
17
 * without express or implied warranty.
18
18
 *
19
19
 * $Log: ppmtobmp.c,v $
 
20
 * Revision 1.4  2004/01/17 09:10:18  aba-guest
 
21
 * tab -> space
 
22
 *
 
23
 * Revision 1.3  2004/01/17 08:20:56  aba-guest
 
24
 * fixed bbp-values
 
25
 *
20
26
 * Revision 1.2  2003/08/14 19:38:51  aba-guest
21
27
 * First part to 9.25 update; could now be really broken
22
28
 *
496
502
}
497
503
 
498
504
 
 
505
#define adjust_minimum_bpp(bpp) \
 
506
        ((bpp <= 1) ? 1 : \
 
507
        (bpp <= 4) ? 4 : \
 
508
        (bpp <= 8) ? 8 : \
 
509
         24)
 
510
 
499
511
 
500
512
static void
501
513
analyze_colors(const pixel ** const pixels, 
538
550
        *minimum_bpp_p = 24;
539
551
        *cht_p = NULL;
540
552
    } else {
541
 
        *minimum_bpp_p = pm_maxvaltobits(*colors_p-1);
 
553
        *minimum_bpp_p = adjust_minimum_bpp(pm_maxvaltobits(*colors_p-1));
542
554
        pm_message("%d colors found", *colors_p);
543
555
        /*
544
556
         * Now scale the maxval to 255 as required by BMP format.