This commit is contained in:
hugovk 2014-07-06 00:43:22 +03:00
parent 315134eff3
commit 2de67423eb

View File

@ -23,23 +23,26 @@ from PIL import Image
class HDC: class HDC:
""" """
Wraps a HDC integer. The resulting object can be passed to the Wraps an HDC integer. The resulting object can be passed to the
:py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose` :py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`
methods. methods.
""" """
def __init__(self, dc): def __init__(self, dc):
self.dc = dc self.dc = dc
def __int__(self): def __int__(self):
return self.dc return self.dc
class HWND: class HWND:
""" """
Wraps a HWND integer. The resulting object can be passed to the Wraps an HWND integer. The resulting object can be passed to the
:py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose` :py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`
methods, instead of a DC. methods, instead of a DC.
""" """
def __init__(self, wnd): def __init__(self, wnd):
self.wnd = wnd self.wnd = wnd
def __int__(self): def __int__(self):
return self.wnd return self.wnd
@ -79,13 +82,12 @@ class Dib:
if image: if image:
self.paste(image) self.paste(image)
def expose(self, handle): def expose(self, handle):
""" """
Copy the bitmap contents to a device context. Copy the bitmap contents to a device context.
:param handle: Device context (HDC), cast to a Python integer, or a HDC :param handle: Device context (HDC), cast to a Python integer, or an
or HWND instance. In PythonWin, you can use the HDC or HWND instance. In PythonWin, you can use the
:py:meth:`CDC.GetHandleAttrib` to get a suitable handle. :py:meth:`CDC.GetHandleAttrib` to get a suitable handle.
""" """
if isinstance(handle, HWND): if isinstance(handle, HWND):
@ -120,7 +122,6 @@ class Dib:
result = self.image.draw(handle, dst, src) result = self.image.draw(handle, dst, src)
return result return result
def query_palette(self, handle): def query_palette(self, handle):
""" """
Installs the palette associated with the image in the given device Installs the palette associated with the image in the given device
@ -146,7 +147,6 @@ class Dib:
result = self.image.query_palette(handle) result = self.image.query_palette(handle)
return result return result
def paste(self, im, box=None): def paste(self, im, box=None):
""" """
Paste a PIL image into the bitmap image. Paste a PIL image into the bitmap image.
@ -166,7 +166,6 @@ class Dib:
else: else:
self.image.paste(im.im) self.image.paste(im.im)
def frombytes(self, buffer): def frombytes(self, buffer):
""" """
Load display memory contents from byte data. Load display memory contents from byte data.
@ -176,7 +175,6 @@ class Dib:
""" """
return self.image.frombytes(buffer) return self.image.frombytes(buffer)
def tobytes(self): def tobytes(self):
""" """
Copy display memory contents to bytes object. Copy display memory contents to bytes object.
@ -204,6 +202,7 @@ class Dib:
) )
return self.tobytes() return self.tobytes()
## ##
# Create a Window with the given title size. # Create a Window with the given title size.
@ -235,6 +234,7 @@ class Window:
def mainloop(self): def mainloop(self):
Image.core.eventloop() Image.core.eventloop()
## ##
# Create an image window which displays the given image. # Create an image window which displays the given image.