mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-12 17:40:51 +03:00
Hopefully corrected bpp issue with older .cur
This commit is contained in:
parent
569feeec12
commit
69b4ebf89b
|
@ -113,8 +113,6 @@ def _accept(prefix):
|
|||
|
||||
##
|
||||
# Image plugin for Windows Cursor files.
|
||||
|
||||
|
||||
class CurFile(IcoImagePlugin.IcoFile):
|
||||
def __init__(self, buf):
|
||||
"""
|
||||
|
@ -152,11 +150,17 @@ class CurFile(IcoImagePlugin.IcoFile):
|
|||
if not icon_header[j]:
|
||||
icon_header[j] = 256
|
||||
|
||||
# cursor files have transparency, hence 32 bpp
|
||||
icon_header["bpp"] = 32
|
||||
|
||||
icon_header["dim"] = (icon_header["width"], icon_header["height"])
|
||||
icon_header["square"] = icon_header["width"] * icon_header["height"]
|
||||
|
||||
# TODO: This needs further investigation. Cursor files do not really specify their bpp
|
||||
# like ICO's as those bits are used for the y_hotspot. For now, bpp is calculated by
|
||||
# subtracting the AND mask (equal to number of pixels * 1bpp) and dividing by the number
|
||||
# of pixels.
|
||||
BITMAP_INFO_HEADER_SIZE = 40
|
||||
icon_header["bpp"] = (icon_header["size"] - BITMAP_INFO_HEADER_SIZE) * 8 - (icon_header["square"]) // icon_header["square"]
|
||||
|
||||
self.entry.append(icon_header)
|
||||
|
||||
self.entry = sorted(self.entry, key=lambda x: x["square"])
|
||||
|
|
Loading…
Reference in New Issue
Block a user