mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge pull request #47 from d-schmidt/master
Solved issue #46 and picked the last missing py3k changes
This commit is contained in:
commit
1b119b3f41
|
@ -614,7 +614,11 @@ class Image:
|
|||
self.palette.mode = "RGB"
|
||||
self.palette.rawmode = None
|
||||
if "transparency" in self.info:
|
||||
self.im.putpalettealpha(self.info["transparency"], 0)
|
||||
if self.info["transparency_palette"]:
|
||||
self.im.putpalettealpha(0, 0, self.info["transparency_palette"])
|
||||
else:
|
||||
self.im.putpalettealpha(self.info["transparency"], 0)
|
||||
|
||||
self.palette.mode = "RGBA"
|
||||
if self.im:
|
||||
return self.im.pixel_access(self.readonly)
|
||||
|
|
|
@ -254,6 +254,7 @@ class PngStream(ChunkStream):
|
|||
i = s.find(b"\0")
|
||||
if i >= 0:
|
||||
self.im_info["transparency"] = i
|
||||
self.im_info["transparency_palette"] = s
|
||||
elif self.im_mode == "L":
|
||||
self.im_info["transparency"] = i16(s)
|
||||
elif self.im_mode == "RGB":
|
||||
|
|
25
_imaging.c
25
_imaging.c
|
@ -733,13 +733,13 @@ _convert(ImagingObject* self, PyObject* args)
|
|||
return NULL;
|
||||
if (paletteimage != NULL) {
|
||||
if (!PyImaging_Check(paletteimage)) {
|
||||
PyObject_Print((PyObject *)paletteimage, stderr, 0);
|
||||
PyErr_SetString(PyExc_ValueError, "palette argument must be image with mode 'P'");
|
||||
return NULL;
|
||||
PyObject_Print((PyObject *)paletteimage, stderr, 0);
|
||||
PyErr_SetString(PyExc_ValueError, "palette argument must be image with mode 'P'");
|
||||
return NULL;
|
||||
}
|
||||
if (paletteimage->image->palette == NULL) {
|
||||
PyErr_SetString(PyExc_ValueError, "null palette");
|
||||
return NULL;
|
||||
PyErr_SetString(PyExc_ValueError, "null palette");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1407,7 +1407,9 @@ _putpalettealpha(ImagingObject* self, PyObject* args)
|
|||
{
|
||||
int index;
|
||||
int alpha = 0;
|
||||
if (!PyArg_ParseTuple(args, "i|i", &index, &alpha))
|
||||
char* tpalette = NULL;
|
||||
int tpaletteSize = 0;
|
||||
if (!PyArg_ParseTuple(args, "i|i"PY_ARG_BYTES_LENGTH, &index, &alpha, &tpalette, &tpaletteSize))
|
||||
return NULL;
|
||||
|
||||
if (!self->image->palette) {
|
||||
|
@ -1421,7 +1423,15 @@ _putpalettealpha(ImagingObject* self, PyObject* args)
|
|||
}
|
||||
|
||||
strcpy(self->image->palette->mode, "RGBA");
|
||||
self->image->palette->palette[index*4+3] = (UINT8) alpha;
|
||||
|
||||
if (tpaletteSize > 0) {
|
||||
for (index = 0; index < tpaletteSize; index++) {
|
||||
self->image->palette->palette[index*4+3] = (UINT8) tpalette[index];
|
||||
}
|
||||
}
|
||||
else {
|
||||
self->image->palette->palette[index*4+3] = (UINT8) alpha;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
|
@ -3391,3 +3401,4 @@ init_imaging(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -483,7 +483,7 @@ cms_get_display_profile_win32(PyObject* self, PyObject* args)
|
|||
}
|
||||
|
||||
if (ok)
|
||||
return PyString_FromStringAndSize(filename, filename_size-1);
|
||||
return PyUnicode_FromStringAndSize(filename, filename_size-1);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
|
|
14
display.c
14
display.c
|
@ -346,7 +346,7 @@ PyImaging_GrabScreenWin32(PyObject* self, PyObject* args)
|
|||
|
||||
/* step 3: extract bits from bitmap */
|
||||
|
||||
buffer = PyString_FromStringAndSize(NULL, height * ((width*3 + 3) & -4));
|
||||
buffer = PyBytes_FromStringAndSize(NULL, height * ((width*3 + 3) & -4));
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
|
@ -355,7 +355,7 @@ PyImaging_GrabScreenWin32(PyObject* self, PyObject* args)
|
|||
core.bcHeight = height;
|
||||
core.bcPlanes = 1;
|
||||
core.bcBitCount = 24;
|
||||
if (!GetDIBits(screen_copy, bitmap, 0, height, PyString_AS_STRING(buffer),
|
||||
if (!GetDIBits(screen_copy, bitmap, 0, height, PyBytes_AS_STRING(buffer),
|
||||
(BITMAPINFO*) &core, DIB_RGB_COLORS))
|
||||
goto error;
|
||||
|
||||
|
@ -386,11 +386,11 @@ static BOOL CALLBACK list_windows_callback(HWND hwnd, LPARAM lParam)
|
|||
/* get window title */
|
||||
title_size = GetWindowTextLength(hwnd);
|
||||
if (title_size > 0) {
|
||||
title = PyString_FromStringAndSize(NULL, title_size);
|
||||
title = PyUnicode_FromStringAndSize(NULL, title_size);
|
||||
if (title)
|
||||
GetWindowText(hwnd, PyString_AS_STRING(title), title_size+1);
|
||||
GetWindowText(hwnd, PyUnicode_AS_UNICODE(title), title_size+1);
|
||||
} else
|
||||
title = PyString_FromString("");
|
||||
title = PyUnicode_FromString("");
|
||||
if (!title)
|
||||
return 0;
|
||||
|
||||
|
@ -545,7 +545,7 @@ PyImaging_GrabClipboardWin32(PyObject* self, PyObject* args)
|
|||
size = wcslen(data) * 2;
|
||||
#endif
|
||||
|
||||
result = PyString_FromStringAndSize(data, size);
|
||||
result = PyBytes_FromStringAndSize(data, size);
|
||||
|
||||
GlobalUnlock(handle);
|
||||
|
||||
|
@ -853,7 +853,7 @@ PyImaging_DrawWmf(PyObject* self, PyObject* args)
|
|||
|
||||
GdiFlush();
|
||||
|
||||
buffer = PyString_FromStringAndSize(ptr, height * ((width*3 + 3) & -4));
|
||||
buffer = PyBytes_FromStringAndSize(ptr, height * ((width*3 + 3) & -4));
|
||||
|
||||
error:
|
||||
DeleteEnhMetaFile(meta);
|
||||
|
|
|
@ -157,7 +157,7 @@ def testimage():
|
|||
|
||||
def check_module(feature, module):
|
||||
try:
|
||||
__import__("PIL." + module)
|
||||
__import__(module)
|
||||
except ImportError:
|
||||
print("***", feature, "support not installed")
|
||||
else:
|
||||
|
|
2
setup.py
2
setup.py
|
@ -95,7 +95,7 @@ class pil_build_ext(build_ext):
|
|||
#
|
||||
# add configured kits
|
||||
|
||||
for root in (TCL_ROOT, JPEG_ROOT, TCL_ROOT, TIFF_ROOT, ZLIB_ROOT,
|
||||
for root in (TCL_ROOT, JPEG_ROOT, TIFF_ROOT, ZLIB_ROOT,
|
||||
FREETYPE_ROOT, LCMS_ROOT):
|
||||
if isinstance(root, type(())):
|
||||
lib_root, include_root = root
|
||||
|
|
Loading…
Reference in New Issue
Block a user