zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
U
T±dýã@sXddlmZGdd„dƒZGdd„dƒZGdd„dƒZGdd    „d    ƒZGd
d „d eƒZd S) é)ÚImagec@s eZdZdZdd„Zdd„ZdS)ÚHDCz¤
    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`
    methods.
    cCs
||_dS©N©Údc)Úselfr©rúCd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PIL/ImageWin.pyÚ__init__sz HDC.__init__cCs|jSrr©rrrr    Ú__int__!sz HDC.__int__N©Ú__name__Ú
__module__Ú __qualname__Ú__doc__r
r rrrr    rsrc@s eZdZdZdd„Zdd„ZdS)ÚHWNDz¶
    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`
    methods, instead of a DC.
    cCs
||_dSr©Úwnd)rrrrr    r
,sz HWND.__init__cCs|jSrrr rrr    r /sz HWND.__int__Nr rrrr    r%src@sNeZdZdZddd„Zdd„Zddd„Zd    d
„Zdd d „Zd d„Z    dd„Z
dS)ÚDiba&
    A Windows bitmap with the given mode and size.  The mode can be one of "1",
    "L", "P", or "RGB".
 
    If the display requires a palette, this constructor creates a suitable
    palette and associates it with the image. For an "L" image, 128 greylevels
    are allocated. For an "RGB" image, a 6x6x6 colour cube is used, together
    with 20 greylevels.
 
    To make sure that palettes work properly under Windows, you must call the
    ``palette`` method upon certain events from Windows.
 
    :param image: Either a PIL image, or a mode string. If a mode string is
                  used, a size must also be given.  The mode can be one of "1",
                  "L", "P", or "RGB".
    :param size: If the first argument is a mode string, this
                 defines the size of the image.
    NcCsjt|dƒr"t|dƒr"|j}|j}n|}d}|dkr<t |¡}tj ||¡|_||_||_|rf| |¡dS)NÚmodeÚsize)Ú1ÚLÚPÚRGB)    ÚhasattrrrrZ getmodebaseÚcoreZdisplayÚimageÚpaste)rrrrrrr    r
Gs
z Dib.__init__c
CsJt|tƒr:|j |¡}z|j |¡}W5|j ||¡Xn |j |¡}|S)a 
        Copy the bitmap contents to a device context.
 
        :param handle: Device context (HDC), cast to a Python integer, or an
                       HDC or HWND instance.  In PythonWin, you can use
                       ``CDC.GetHandleAttrib()`` to get a suitable handle.
        )Ú
isinstancerrÚgetdcÚ    releasedcÚexpose)rÚhandlerÚresultrrr    r#Vs
  z
Dib.exposec
Cs`|sd|j}t|tƒrL|j |¡}z|j |||¡}W5|j ||¡Xn|j |||¡}|S)am
        Same as expose, but allows you to specify where to draw the image, and
        what part of it to draw.
 
        The destination and source areas are given as 4-tuple rectangles. If
        the source is omitted, the entire image is copied. If the source and
        the destination have different sizes, the image is resized as
        necessary.
        )ér&)rr rrr!r"Údraw)rr$ÚdstÚsrcrr%rrr    r'hs
 
 
 zDib.drawc
CsJt|tƒr:|j |¡}z|j |¡}W5|j ||¡Xn |j |¡}|S)ae
        Installs the palette associated with the image in the given device
        context.
 
        This method should be called upon **QUERYNEWPALETTE** and
        **PALETTECHANGED** events from Windows. If this method returns a
        non-zero value, one or more display palette entries were changed, and
        the image should be redrawn.
 
        :param handle: Device context (HDC), cast to a Python integer, or an
                       HDC or HWND instance.
        :return: A true value if one or more entries were changed (this
                 indicates that the image should be redrawn).
        )r rrr!r"Ú query_palette)rr$r%rrr    r*~s
  zDib.query_palettecCsH| ¡|j|jkr | |j¡}|r6|j |j|¡n|j |j¡dS)aõ
        Paste a PIL image into the bitmap image.
 
        :param im: A PIL image.  The size must match the target region.
                   If the mode does not match, the image is converted to the
                   mode of the bitmap image.
        :param box: A 4-tuple defining the left, upper, right, and
                    lower pixel coordinate.  See :ref:`coordinate-system`. If
                    None is given instead of a tuple, all of the image is
                    assumed.
        N)ÚloadrÚconvertrrÚim)rr-Zboxrrr    r—s   z    Dib.pastecCs |j |¡S)zÐ
        Load display memory contents from byte data.
 
        :param buffer: A buffer containing display data (usually
                       data returned from :py:func:`~PIL.ImageWin.Dib.tobytes`)
        )rÚ    frombytes)rÚbufferrrr    r.«sz Dib.frombytescCs
|j ¡S)zy
        Copy display memory contents to bytes object.
 
        :return: A bytes object containing display data.
        )rÚtobytesr rrr    r0´sz Dib.tobytes)N)N)N) rrrrr
r#r'r*rr.r0rrrr    r3s
 
 
    rc@sReZdZdZddd„Zdd„Zdd    „Zd
d „Zd d „Zdd„Z    dd„Z
dd„Z dS)ÚWindowz*Create a Window with the given title size.ÚPILNcCs"tj ||j|pd|pd¡|_dS)Nr&)rrZ createwindowÚ_Window__dispatcherZhwnd)rÚtitleÚwidthÚheightrrr    r
Às ÿzWindow.__init__cGst|d|ƒ|ŽS)NZ
ui_handle_)Úgetattr)rÚactionÚargsrrr    Z __dispatcherÅszWindow.__dispatchercCsdSrr©rrÚx0Úy0Úx1Úy1rrr    Úui_handle_clearÈszWindow.ui_handle_clearcCsdSrr)rr;r<r=r>rrr    Úui_handle_damageËszWindow.ui_handle_damagecCsdSrrr rrr    Úui_handle_destroyÎszWindow.ui_handle_destroycCsdSrrr:rrr    Úui_handle_repairÑszWindow.ui_handle_repaircCsdSrr)rr5r6rrr    Úui_handle_resizeÔszWindow.ui_handle_resizecCstj ¡dSr)rrZ    eventloopr rrr    Úmainloop×szWindow.mainloop)r2NN) rrrrr
r3r?r@rArBrCrDrrrr    r1½s
r1cs*eZdZdZd‡fdd„    Zdd„Z‡ZS)Ú ImageWindowz6Create an image window which displays the given image.r2cs8t|tƒst|ƒ}||_|j\}}tƒj|||ddS)N)r5r6)r rrrÚsuperr
)rrr4r5r6©Ú    __class__rr    r
Þs
 
 
zImageWindow.__init__cCs|j |||||f¡dSr)rr'r:rrr    rBåszImageWindow.ui_handle_repair)r2)rrrrr
rBÚ __classcell__rrrGr    rEÛsrEN)Úrrrrr1rErrrr    Ú<module>s