diff --git a/src/PIL/ImageFile.py b/src/PIL/ImageFile.py index 6c92ea4f5..967bd392b 100644 --- a/src/PIL/ImageFile.py +++ b/src/PIL/ImageFile.py @@ -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, diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index a829e8db5..efc14e783 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -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 diff --git a/src/_imaging.c b/src/_imaging.c index 4eee912f6..6bd2a1aaa 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -94,10 +94,9 @@ #include /* 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 */ diff --git a/src/map.c b/src/map.c index 7b4514751..46db0aede 100644 --- a/src/map.c +++ b/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;