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__
|
#define __MODE_H__
|
||||||
|
|
||||||
|
|
||||||
// Maximum length (including null terminator) for both mode and rawmode names.
|
|
||||||
#define IMAGING_MODE_LENGTH 6+1
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char * const name;
|
const char * const name;
|
||||||
} Mode;
|
} Mode;
|
||||||
|
|
|
@ -21,13 +21,13 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
ImagingPalette
|
ImagingPalette
|
||||||
ImagingPaletteNew(const char *mode) {
|
ImagingPaletteNew(const Mode *mode) {
|
||||||
/* Create a palette object */
|
/* Create a palette object */
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
ImagingPalette palette;
|
ImagingPalette palette;
|
||||||
|
|
||||||
if (strcmp(mode, "RGB") && strcmp(mode, "RGBA")) {
|
if (mode != IMAGING_MODE_RGB && mode != IMAGING_MODE_RGBA) {
|
||||||
return (ImagingPalette)ImagingError_ModeError();
|
return (ImagingPalette)ImagingError_ModeError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,8 +36,7 @@ ImagingPaletteNew(const char *mode) {
|
||||||
return (ImagingPalette)ImagingError_MemoryError();
|
return (ImagingPalette)ImagingError_MemoryError();
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(palette->mode, mode, IMAGING_MODE_LENGTH - 1);
|
palette->mode = mode;
|
||||||
palette->mode[IMAGING_MODE_LENGTH - 1] = 0;
|
|
||||||
|
|
||||||
palette->size = 0;
|
palette->size = 0;
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
|
@ -54,7 +53,7 @@ ImagingPaletteNewBrowser(void) {
|
||||||
int i, r, g, b;
|
int i, r, g, b;
|
||||||
ImagingPalette palette;
|
ImagingPalette palette;
|
||||||
|
|
||||||
palette = ImagingPaletteNew("RGB");
|
palette = ImagingPaletteNew(IMAGING_MODE_RGB);
|
||||||
if (!palette) {
|
if (!palette) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user