mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-30 23:47:27 +03:00 
			
		
		
		
	added tests to cover save of four different png transparencies
This commit is contained in:
		
							parent
							
								
									638889cae0
								
							
						
					
					
						commit
						5303f0ea66
					
				
							
								
								
									
										
											BIN
										
									
								
								Tests/images/l_trns.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/l_trns.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.1 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Tests/images/p_trns_single.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/p_trns_single.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.9 KiB | 
|  | @ -128,6 +128,34 @@ def test_load_transparent_p(): | ||||||
|     # image has 124 uniqe qlpha values |     # image has 124 uniqe qlpha values | ||||||
|     assert_equal(len(im.split()[3].getcolors()), 124) |     assert_equal(len(im.split()[3].getcolors()), 124) | ||||||
| 
 | 
 | ||||||
|  | def test_save_p_transparent_palette(): | ||||||
|  |     in_file = "Tests/images/pil123p.png" | ||||||
|  |     im = Image.open(in_file) | ||||||
|  | 
 | ||||||
|  |     file = tempfile("temp.png") | ||||||
|  |     assert_no_exception(lambda: im.save(file)) | ||||||
|  | 
 | ||||||
|  | def test_save_p_single_transparency(): | ||||||
|  |     in_file = "Tests/images/p_trns_single.png" | ||||||
|  |     im = Image.open(in_file) | ||||||
|  | 
 | ||||||
|  |     file = tempfile("temp.png") | ||||||
|  |     assert_no_exception(lambda: im.save(file)) | ||||||
|  | 
 | ||||||
|  | def test_save_l_transparency(): | ||||||
|  |     in_file = "Tests/images/l_trns.png" | ||||||
|  |     im = Image.open(in_file) | ||||||
|  | 
 | ||||||
|  |     file = tempfile("temp.png") | ||||||
|  |     assert_no_exception(lambda: im.save(file)) | ||||||
|  | 
 | ||||||
|  | def test_save_rgb_single_transparency(): | ||||||
|  |     in_file = "Tests/images/caption_6_33_22.png" | ||||||
|  |     im = Image.open(in_file) | ||||||
|  | 
 | ||||||
|  |     file = tempfile("temp.png") | ||||||
|  |     assert_no_exception(lambda: im.save(file)) | ||||||
|  | 
 | ||||||
| def test_load_verify(): | def test_load_verify(): | ||||||
|     # Check open/load/verify exception (@PIL150) |     # Check open/load/verify exception (@PIL150) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										22
									
								
								_imaging.c
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								_imaging.c
									
									
									
									
									
								
							|  | @ -742,16 +742,16 @@ _convert(ImagingObject* self, PyObject* args) | ||||||
|     ImagingObject *paletteimage = NULL; |     ImagingObject *paletteimage = NULL; | ||||||
| 
 | 
 | ||||||
|     if (!PyArg_ParseTuple(args, "s|iO", &mode, &dither, &paletteimage)) |     if (!PyArg_ParseTuple(args, "s|iO", &mode, &dither, &paletteimage)) | ||||||
|     return NULL; |       return NULL; | ||||||
|     if (paletteimage != NULL) { |     if (paletteimage != NULL) { | ||||||
|       if (!PyImaging_Check(paletteimage)) { |       if (!PyImaging_Check(paletteimage)) { | ||||||
|     PyObject_Print((PyObject *)paletteimage, stderr, 0); |         PyObject_Print((PyObject *)paletteimage, stderr, 0); | ||||||
|     PyErr_SetString(PyExc_ValueError, "palette argument must be image with mode 'P'"); |         PyErr_SetString(PyExc_ValueError, "palette argument must be image with mode 'P'"); | ||||||
|     return NULL; |         return NULL; | ||||||
|       } |       } | ||||||
|       if (paletteimage->image->palette == NULL) { |       if (paletteimage->image->palette == NULL) { | ||||||
|     PyErr_SetString(PyExc_ValueError, "null palette"); |         PyErr_SetString(PyExc_ValueError, "null palette"); | ||||||
|     return NULL; |         return NULL; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -1431,16 +1431,16 @@ _putpalettealpha(ImagingObject* self, PyObject* args) | ||||||
|     int index; |     int index; | ||||||
|     int alpha = 0; |     int alpha = 0; | ||||||
|     if (!PyArg_ParseTuple(args, "i|i", &index, &alpha)) |     if (!PyArg_ParseTuple(args, "i|i", &index, &alpha)) | ||||||
|     return NULL; |         return NULL; | ||||||
| 
 | 
 | ||||||
|     if (!self->image->palette) { |     if (!self->image->palette) { | ||||||
|     PyErr_SetString(PyExc_ValueError, no_palette); |         PyErr_SetString(PyExc_ValueError, no_palette); | ||||||
|     return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (index < 0 || index >= 256) { |     if (index < 0 || index >= 256) { | ||||||
|     PyErr_SetString(PyExc_ValueError, outside_palette); |         PyErr_SetString(PyExc_ValueError, outside_palette); | ||||||
|     return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     strcpy(self->image->palette->mode, "RGBA"); |     strcpy(self->image->palette->mode, "RGBA"); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user