mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-31 03:03:09 +03:00
re-enable PyImaging_MapBuffer
This commit is contained in:
parent
936439b481
commit
a4fab132d0
|
@ -206,9 +206,6 @@ class ImageFile(Image.Image):
|
|||
except AttributeError:
|
||||
seek = self.fp.seek
|
||||
|
||||
# XXX hack202406 disable unmodified code path
|
||||
use_mmap = False
|
||||
|
||||
if use_mmap:
|
||||
# try memory mapping
|
||||
decoder_name, extents, offset, args = self.tile[0]
|
||||
|
@ -230,7 +227,7 @@ class ImageFile(Image.Image):
|
|||
msg = "buffer is not large enough"
|
||||
raise OSError(msg)
|
||||
self.im = Image.core.map_buffer(
|
||||
self.map, self.size, decoder_name, offset, args
|
||||
self.map, self.size, decoder_name, offset, args, *self.newconfig
|
||||
)
|
||||
readonly = 1
|
||||
# After trashing self.im,
|
||||
|
|
|
@ -1417,8 +1417,6 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
logger.debug("- size: %s", self.size)
|
||||
|
||||
sample_format = self.tag_v2.get(SAMPLEFORMAT, (1,))
|
||||
logger.debug("- sample_format: %s", sample_format)
|
||||
|
||||
bps_tuple = self.tag_v2.get(BITSPERSAMPLE, (1,))
|
||||
extra_tuple = self.tag_v2.get(EXTRASAMPLES, ())
|
||||
if photo in (2, 6, 8): # RGB, YCbCr, LAB
|
||||
|
|
|
@ -94,10 +94,9 @@
|
|||
#include <math.h>
|
||||
|
||||
/* Configuration stuff. Feel free to undef things you don't need. */
|
||||
#define WITH_IMAGECHOPS /* ImageChops support */
|
||||
#define WITH_IMAGEDRAW /* ImageDraw support */
|
||||
// XXX hack202406 disable unmodified code path
|
||||
// #define WITH_MAPPING /* use memory mapping to read some file formats */
|
||||
#define WITH_IMAGECHOPS /* ImageChops support */
|
||||
#define WITH_IMAGEDRAW /* ImageDraw support */
|
||||
#define WITH_MAPPING /* use memory mapping to read some file formats */
|
||||
#define WITH_IMAGEPATH /* ImagePath stuff */
|
||||
#define WITH_ARROW /* arrow graphics stuff (experimental) */
|
||||
#define WITH_EFFECTS /* special effects */
|
||||
|
|
15
src/map.c
15
src/map.c
|
@ -61,10 +61,11 @@ PyImaging_MapBuffer(PyObject *self, PyObject *args) {
|
|||
int xsize, ysize;
|
||||
int stride;
|
||||
int ystep;
|
||||
int depth = -1, bands = -1;
|
||||
|
||||
if (!PyArg_ParseTuple(
|
||||
args,
|
||||
"O(ii)sn(sii)",
|
||||
"O(ii)sn(sii)|ii",
|
||||
&target,
|
||||
&xsize,
|
||||
&ysize,
|
||||
|
@ -72,7 +73,9 @@ PyImaging_MapBuffer(PyObject *self, PyObject *args) {
|
|||
&offset,
|
||||
&mode,
|
||||
&stride,
|
||||
&ystep)) {
|
||||
&ystep,
|
||||
&depth,
|
||||
&bands)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -82,10 +85,12 @@ PyImaging_MapBuffer(PyObject *self, PyObject *args) {
|
|||
}
|
||||
|
||||
if (stride <= 0) {
|
||||
if (!strcmp(mode, "L") || !strcmp(mode, "P")) {
|
||||
if (strcmp(mode, "L") == 0 || strcmp(mode, "P") == 0) {
|
||||
stride = xsize;
|
||||
} else if (!strncmp(mode, "I;16", 4)) {
|
||||
} else if (strncmp(mode, "I;16", 4) == 0) {
|
||||
stride = xsize * 2;
|
||||
} else if (strcmp(mode, IMAGING_MODE_MB) == 0) {
|
||||
stride = xsize * depth * bands;
|
||||
} else {
|
||||
stride = xsize * 4;
|
||||
}
|
||||
|
@ -120,7 +125,7 @@ PyImaging_MapBuffer(PyObject *self, PyObject *args) {
|
|||
}
|
||||
|
||||
im = ImagingNewPrologueSubtype(
|
||||
mode, xsize, ysize, -1, -1, sizeof(ImagingBufferInstance));
|
||||
mode, xsize, ysize, depth, bands, sizeof(ImagingBufferInstance));
|
||||
if (!im) {
|
||||
PyBuffer_Release(&view);
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue
Block a user