mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
add type hints to ImageCms.get_display_profile
This commit is contained in:
parent
0630ef061f
commit
a1a687c261
|
@ -4,13 +4,14 @@ import datetime
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
import sys
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from PIL import Image, ImageMode, features
|
from PIL import Image, ImageMode, ImageWin, features
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image,
|
assert_image,
|
||||||
|
@ -213,6 +214,10 @@ def test_display_profile() -> None:
|
||||||
# try fetching the profile for the current display device
|
# try fetching the profile for the current display device
|
||||||
ImageCms.get_display_profile()
|
ImageCms.get_display_profile()
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
ImageCms.get_display_profile(ImageWin.HDC(0))
|
||||||
|
ImageCms.get_display_profile(ImageWin.HWND(0))
|
||||||
|
|
||||||
|
|
||||||
def test_lab_color_profile() -> None:
|
def test_lab_color_profile() -> None:
|
||||||
ImageCms.createProfile("LAB", 5000)
|
ImageCms.createProfile("LAB", 5000)
|
||||||
|
|
|
@ -23,7 +23,7 @@ import operator
|
||||||
import sys
|
import sys
|
||||||
from enum import IntEnum, IntFlag
|
from enum import IntEnum, IntFlag
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from typing import Any, BinaryIO
|
from typing import Any, BinaryIO, SupportsInt
|
||||||
|
|
||||||
from . import Image, __version__
|
from . import Image, __version__
|
||||||
from ._deprecate import deprecate
|
from ._deprecate import deprecate
|
||||||
|
@ -341,7 +341,7 @@ class ImageCmsTransform(Image.ImagePointHandler):
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
||||||
def get_display_profile(handle=None):
|
def get_display_profile(handle: SupportsInt | None = None) -> ImageCmsProfile | None:
|
||||||
"""
|
"""
|
||||||
(experimental) Fetches the profile for the current display device.
|
(experimental) Fetches the profile for the current display device.
|
||||||
|
|
||||||
|
@ -351,12 +351,12 @@ def get_display_profile(handle=None):
|
||||||
if sys.platform != "win32":
|
if sys.platform != "win32":
|
||||||
return None
|
return None
|
||||||
|
|
||||||
from . import ImageWin
|
from . import ImageWin # type: ignore[unused-ignore, unreachable]
|
||||||
|
|
||||||
if isinstance(handle, ImageWin.HDC):
|
if isinstance(handle, ImageWin.HDC):
|
||||||
profile = core.get_display_profile_win32(handle, 1)
|
profile = core.get_display_profile_win32(int(handle), 1)
|
||||||
else:
|
else:
|
||||||
profile = core.get_display_profile_win32(handle or 0)
|
profile = core.get_display_profile_win32(int(handle or 0))
|
||||||
if profile is None:
|
if profile is None:
|
||||||
return None
|
return None
|
||||||
return ImageCmsProfile(profile)
|
return ImageCmsProfile(profile)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user