mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	DXT1 supports 8-bit alpha
This commit is contained in:
		
							parent
							
								
									320dff834d
								
							
						
					
					
						commit
						3f09f9b5cc
					
				| 
						 | 
					@ -15,7 +15,7 @@ from __future__ import annotations
 | 
				
			||||||
import struct
 | 
					import struct
 | 
				
			||||||
from enum import IntEnum, IntFlag
 | 
					from enum import IntEnum, IntFlag
 | 
				
			||||||
from math import ceil, log
 | 
					from math import ceil, log
 | 
				
			||||||
from typing import IO, NamedTuple
 | 
					from typing import IO, NamedTuple, cast
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from . import Image, ImageFile
 | 
					from . import Image, ImageFile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -294,6 +294,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
 | 
				
			||||||
    flags = CompiledVtfFlags(0)
 | 
					    flags = CompiledVtfFlags(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if pixel_format in (
 | 
					    if pixel_format in (
 | 
				
			||||||
 | 
					        VtfPF.DXT1,
 | 
				
			||||||
        VtfPF.DXT3,
 | 
					        VtfPF.DXT3,
 | 
				
			||||||
        VtfPF.DXT5,
 | 
					        VtfPF.DXT5,
 | 
				
			||||||
        VtfPF.RGBA8888,
 | 
					        VtfPF.RGBA8888,
 | 
				
			||||||
| 
						 | 
					@ -360,9 +361,11 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
 | 
				
			||||||
    min_size = 4 if pixel_format in BLOCK_COMPRESSED else 1
 | 
					    min_size = 4 if pixel_format in BLOCK_COMPRESSED else 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for mip_id in range(mipmap_count - 1, 0, -1):
 | 
					    for mip_id in range(mipmap_count - 1, 0, -1):
 | 
				
			||||||
        mip_width = max(min_size, width >> mip_id)
 | 
					        size = cast(
 | 
				
			||||||
        mip_height = max(min_size, height >> mip_id)
 | 
					            tuple[int, int],
 | 
				
			||||||
        mip = im.resize((mip_width, mip_height))
 | 
					            tuple(max(min_size, dimension >> mip_id) for dimension in im.size),
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					        mip = im.resize(size)
 | 
				
			||||||
        _write_image(fp, mip, pixel_format)
 | 
					        _write_image(fp, mip, pixel_format)
 | 
				
			||||||
    _write_image(fp, im, pixel_format)
 | 
					    _write_image(fp, im, pixel_format)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user