mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 16:07:30 +03:00 
			
		
		
		
	fix zero size images
This commit is contained in:
		
							parent
							
								
									6007e818a9
								
							
						
					
					
						commit
						0054743100
					
				|  | @ -385,6 +385,12 @@ class TestImage(PillowTestCase): | |||
|         im = Image.new('L', (0, 0)) | ||||
|         self.assertEqual(im.size, (0, 0)) | ||||
| 
 | ||||
|         im = Image.new('L', (0, 100)) | ||||
|         self.assertEqual(im.size, (0, 100)) | ||||
| 
 | ||||
|         im = Image.new('L', (100, 0)) | ||||
|         self.assertEqual(im.size, (100, 0)) | ||||
| 
 | ||||
|         self.assertTrue(Image.new('RGB', (1, 1))) | ||||
|         # Should pass lists too | ||||
|         i = Image.new('RGB', [1, 1]) | ||||
|  |  | |||
|  | @ -278,6 +278,9 @@ _get_block(int requested_size, int dirty) | |||
|     if ( ! _blocks) { | ||||
|         _blocks = calloc(sizeof(void*), MEMORY_CACHE_BLOCKS); | ||||
|     } | ||||
|     if ( ! requested_size) { | ||||
|         requested_size = 1; | ||||
|     } | ||||
|     if (_blocks_free > 0) { | ||||
|         _blocks_free -= 1; | ||||
|         // printf("get block: %p %d; _blocks_free: %d\n",
 | ||||
|  | @ -341,9 +344,11 @@ ImagingAllocateArray(Imaging im, int dirty) | |||
|     int linesize, lines_per_block, blocks_count; | ||||
| 
 | ||||
|     linesize = (im->linesize + MEMORY_ALIGN_LINES - 1) & -MEMORY_ALIGN_LINES; | ||||
|     lines_per_block = MEMORY_BLOCK_SIZE / linesize; | ||||
|     if (lines_per_block <= 0) | ||||
|     if ( ! linesize || linesize > MEMORY_BLOCK_SIZE) { | ||||
|         lines_per_block = 1; | ||||
|     } else { | ||||
|         lines_per_block = MEMORY_BLOCK_SIZE / linesize; | ||||
|     } | ||||
|     blocks_count = (im->ysize + lines_per_block - 1) / lines_per_block; | ||||
|     // printf("NEW size: %dx%d, ls: %d, lpb: %d, blocks: %d\n",
 | ||||
|     //        im->xsize, im->ysize, linesize, lines_per_block, blocks_count);
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user