mirror of
https://github.com/quantum5/win2xcur.git
synced 2025-04-24 02:01:57 -04:00
Fix mypy typing
This commit is contained in:
parent
5c03c08a61
commit
a89e52a286
1
mypy.ini
1
mypy.ini
|
@ -1,3 +1,4 @@
|
|||
[mypy]
|
||||
ignore_missing_imports = True
|
||||
strict = true
|
||||
plugins = numpy.typing.mypy_plugin
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
from typing import cast
|
||||
from typing import Any
|
||||
|
||||
import numpy
|
||||
import numpy as np
|
||||
|
||||
|
||||
def premultiply_alpha(source: bytes) -> bytes:
|
||||
buffer = numpy.frombuffer(source, dtype=numpy.uint8).astype(numpy.double)
|
||||
buffer: np.ndarray[Any, np.dtype[np.double]] = np.frombuffer(source, dtype=np.uint8).astype(np.double)
|
||||
alpha = buffer[3::4] / 255.0
|
||||
buffer[0::4] *= alpha
|
||||
buffer[1::4] *= alpha
|
||||
buffer[2::4] *= alpha
|
||||
return cast(bytes, buffer.astype(numpy.uint8).tobytes())
|
||||
return buffer.astype(np.uint8).tobytes()
|
||||
|
|
Loading…
Reference in a new issue