mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-29 11:26:17 +03:00
use mode structs in Palette.c
This commit is contained in:
parent
c906098fec
commit
c587ad10ab
|
@ -2,10 +2,6 @@
|
|||
#define __MODE_H__
|
||||
|
||||
|
||||
// Maximum length (including null terminator) for both mode and rawmode names.
|
||||
#define IMAGING_MODE_LENGTH 6+1
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char * const name;
|
||||
} Mode;
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
#include <math.h>
|
||||
|
||||
ImagingPalette
|
||||
ImagingPaletteNew(const char *mode) {
|
||||
ImagingPaletteNew(const Mode *mode) {
|
||||
/* Create a palette object */
|
||||
|
||||
int i;
|
||||
ImagingPalette palette;
|
||||
|
||||
if (strcmp(mode, "RGB") && strcmp(mode, "RGBA")) {
|
||||
if (mode != IMAGING_MODE_RGB && mode != IMAGING_MODE_RGBA) {
|
||||
return (ImagingPalette)ImagingError_ModeError();
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,7 @@ ImagingPaletteNew(const char *mode) {
|
|||
return (ImagingPalette)ImagingError_MemoryError();
|
||||
}
|
||||
|
||||
strncpy(palette->mode, mode, IMAGING_MODE_LENGTH - 1);
|
||||
palette->mode[IMAGING_MODE_LENGTH - 1] = 0;
|
||||
palette->mode = mode;
|
||||
|
||||
palette->size = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
|
@ -54,7 +53,7 @@ ImagingPaletteNewBrowser(void) {
|
|||
int i, r, g, b;
|
||||
ImagingPalette palette;
|
||||
|
||||
palette = ImagingPaletteNew("RGB");
|
||||
palette = ImagingPaletteNew(IMAGING_MODE_RGB);
|
||||
if (!palette) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user