~ubuntu-branches/debian/squeeze/python-imaging/squeeze

« back to all changes in this revision

Viewing changes to libImaging/Palette.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-08-28 23:14:10 UTC
  • mfrom: (2.1.5 edgy)
  • Revision ID: james.westby@ubuntu.com-20060828231410-lca9enmne3ecmkup
Tags: 1.1.5-11
* python-imaging-sane: Depend on python-numarray. Closes: #382190.
* Add dependencies on ${shlibs:Depends}, lost in -6. Closes: #378596.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * The Python Imaging Library
3
 
 * $Id: //modules/pil/libImaging/Palette.c#2 $
 
3
 * $Id: Palette.c 2289 2005-02-09 21:29:01Z fredrik $
4
4
 *
5
5
 * imaging palette object
6
6
 *
7
7
 * history:
8
 
 * 96-05-05 fl: Added to library
9
 
 * 96-05-27 fl: Added colour mapping stuff
10
 
 * 97-05-12 fl: Support RGBA palettes
 
8
 * 1996-05-05 fl   Added to library
 
9
 * 1996-05-27 fl   Added colour mapping stuff
 
10
 * 1997-05-12 fl   Support RGBA palettes
 
11
 * 2005-02-09 fl   Removed grayscale entries from web palette
11
12
 *
12
 
 * Copyright (c) Fredrik Lundh 1995-97.
13
 
 * Copyright (c) Secret Labs AB 1997.
 
13
 * Copyright (c) Secret Labs AB 1997-2005.  All rights reserved.
 
14
 * Copyright (c) Fredrik Lundh 1995-1997.
14
15
 *
15
16
 * See the README file for information on usage and redistribution.
16
17
 */
17
18
 
18
19
 
 
20
#include "Imaging.h"
 
21
 
19
22
#include <math.h>
20
23
 
21
 
#include "Imaging.h"
22
 
 
23
24
 
24
25
ImagingPalette
25
26
ImagingPaletteNew(const char* mode)
61
62
    if (!palette)
62
63
        return NULL;
63
64
 
 
65
    /* Blank out unused entries */
 
66
    /* FIXME: Add 10-level windows palette here? */
 
67
 
 
68
    for (i = 0; i < 10; i++) {
 
69
        palette->palette[i*4+0] =
 
70
        palette->palette[i*4+1] =
 
71
        palette->palette[i*4+2] = 0;
 
72
    }
 
73
 
64
74
    /* Simple 6x6x6 colour cube */
65
75
 
66
 
    i = 10;
67
76
    for (b = 0; b < 256; b += 51)
68
77
        for (g = 0; g < 256; g += 51)
69
78
            for (r = 0; r < 256; r += 51) {
73
82
                i++;
74
83
            }
75
84
 
 
85
    /* Blank out unused entries */
 
86
    /* FIXME: add 30-level greyscale wedge here? */
 
87
 
 
88
    for (; i < 256; i++) {
 
89
        palette->palette[i*4+0] =
 
90
        palette->palette[i*4+1] =
 
91
        palette->palette[i*4+2] = 0;
 
92
    }
 
93
 
76
94
    return palette;
77
95
}
78
96