mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 07:57:27 +03:00 
			
		
		
		
	
						commit
						243160ee78
					
				
							
								
								
									
										37
									
								
								Tests/large_memory_numpy_test.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Tests/large_memory_numpy_test.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| from tester import * | ||||
| 
 | ||||
| # This test is not run automatically. | ||||
| # | ||||
| # It requires > 2gb memory for the >2 gigapixel image generated in the | ||||
| # second test.  Running this automatically would amount to a denial of | ||||
| # service on our testing infrastructure.  I expect this test to fail | ||||
| # on any 32 bit machine, as well as any smallish things (like | ||||
| # raspberrypis). | ||||
| 
 | ||||
| from PIL import Image | ||||
| try: | ||||
|     import numpy as np | ||||
| except: | ||||
|     skip() | ||||
|      | ||||
| ydim = 32769 | ||||
| xdim = 48000 | ||||
| f = tempfile('temp.png') | ||||
| 
 | ||||
| def _write_png(xdim,ydim): | ||||
|     dtype = np.uint8 | ||||
|     a = np.zeros((xdim, ydim), dtype=dtype) | ||||
|     im = Image.fromarray(a, 'L') | ||||
|     im.save(f) | ||||
|     success() | ||||
| 
 | ||||
| def test_large(): | ||||
|     """ succeeded prepatch""" | ||||
|     _write_png(xdim,ydim) | ||||
| def test_2gpx(): | ||||
|     """failed prepatch""" | ||||
|     _write_png(xdim,xdim) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | @ -325,15 +325,15 @@ Imaging | |||
| ImagingNewBlock(const char *mode, int xsize, int ysize) | ||||
| { | ||||
|     Imaging im; | ||||
|     int y, i; | ||||
|     int bytes; | ||||
|     Py_ssize_t y, i; | ||||
|     Py_ssize_t bytes; | ||||
| 
 | ||||
|     im = ImagingNewPrologue(mode, xsize, ysize); | ||||
|     if (!im) | ||||
|         return NULL; | ||||
| 
 | ||||
|     /* Use a single block */ | ||||
|     bytes = im->ysize * im->linesize; | ||||
|     bytes = (Py_ssize_t) im->ysize * im->linesize; | ||||
|     if (bytes <= 0) | ||||
|         /* some platforms return NULL for malloc(0); this fix
 | ||||
|            prevents MemoryError on zero-sized images on such | ||||
|  |  | |||
							
								
								
									
										8
									
								
								map.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								map.c
									
									
									
									
									
								
							|  | @ -323,7 +323,7 @@ mapping_destroy_buffer(Imaging im) | |||
| PyObject* | ||||
| PyImaging_MapBuffer(PyObject* self, PyObject* args) | ||||
| { | ||||
|     int y, size; | ||||
|     Py_ssize_t y, size; | ||||
|     Imaging im; | ||||
| 
 | ||||
|     PyObject* target; | ||||
|  | @ -331,12 +331,12 @@ PyImaging_MapBuffer(PyObject* self, PyObject* args) | |||
|     char* mode; | ||||
|     char* codec; | ||||
|     PyObject* bbox; | ||||
|     int offset; | ||||
|     Py_ssize_t offset; | ||||
|     int xsize, ysize; | ||||
|     int stride; | ||||
|     int ystep; | ||||
| 
 | ||||
|     if (!PyArg_ParseTuple(args, "O(ii)sOi(sii)", &target, &xsize, &ysize, | ||||
|     if (!PyArg_ParseTuple(args, "O(ii)sOn(sii)", &target, &xsize, &ysize, | ||||
|                           &codec, &bbox, &offset, &mode, &stride, &ystep)) | ||||
|         return NULL; | ||||
| 
 | ||||
|  | @ -354,7 +354,7 @@ PyImaging_MapBuffer(PyObject* self, PyObject* args) | |||
|             stride = xsize * 4; | ||||
|     } | ||||
| 
 | ||||
|     size = ysize * stride; | ||||
|     size = (Py_ssize_t) ysize * stride; | ||||
| 
 | ||||
|     /* check buffer size */ | ||||
|     if (PyImaging_GetBuffer(target, &view) < 0) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user