Merge pull request #325 from manisandro/bytearray

Fix bytes which should be bytearray
This commit is contained in:
Alex Clark ☺ 2013-08-29 02:14:49 -07:00
commit e5279a284b
2 changed files with 7 additions and 1 deletions

View File

@ -706,7 +706,7 @@ class Image:
if self.mode == "L" and mode == "RGBA" and "transparency" in self.info:
from PIL import ImagePalette
self.mode = "P"
bytePalette = bytes([i//3 for i in range(768)])
bytePalette = bytes(bytearray([i//3 for i in range(768)]))
self.palette = ImagePalette.raw("RGB", bytePalette)
self.palette.dirty = 1
self.load()

View File

@ -287,6 +287,7 @@ static const char* wrong_mode = "unrecognized image mode";
static const char* wrong_raw_mode = "unrecognized raw mode";
static const char* outside_image = "image index out of range";
static const char* outside_palette = "palette index out of range";
static const char* wrong_palette_size = "invalid palette size";
static const char* no_palette = "image has no palette";
static const char* readonly = "image is readonly";
/* static const char* no_content = "image has no content"; */
@ -1413,6 +1414,11 @@ _putpalette(ImagingObject* self, PyObject* args)
return NULL;
}
if ( palettesize * 8 / bits > 256) {
PyErr_SetString(PyExc_ValueError, wrong_palette_size);
return NULL;
}
ImagingPaletteDelete(self->image->palette);
strcpy(self->image->mode, "P");