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