
    (phc                        S SK Jr  SSKJr   " S S5      r " S S5      r " S S	5      r " S
 S5      r " S S\5      rg)    )annotations   )Imagec                  ,    \ rS rSrSrSS jrSS jrSrg)	HDC   z
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.
c                    Xl         g Ndc)selfr   s     ?/var/www/html/venv/lib/python3.13/site-packages/PIL/ImageWin.py__init__HDC.__init__   s        c                    U R                   $ r
   r   r   s    r   __int__HDC.__int__"   s    wwr   r   N)r   intreturnNoner   r   __name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r      s    r   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	HWND&   z
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.
c                    Xl         g r
   wnd)r   r'   s     r   r   HWND.__init__-   s    r   c                    U R                   $ r
   r&   r   s    r   r   HWND.__int__0   s    xxr   r&   N)r'   r   r   r   r   r   r!   r   r   r#   r#   &   s    r   r#   c                  v    \ rS rSrSr S     SS jjrS rSS jrS r S     SS jjr	SS	 jr
SS
 jrSrg)Dib4   a  
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 graylevels
are allocated. For an "RGB" image, a 6x6x6 colour cube is used, together
with 20 graylevels.

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.
Nc                `   [        U[        5      (       a  UnSnOUR                  nUR                  nUS;  a  [        R
                  " U5      n[        R                  R                  X25      U l        X0l        X l        U(       a)  [        U[        5      (       a   eU R                  U5        g g )N )1LPRGB)

isinstancestrmodesizer   getmodebasecoredisplayimagepaste)r   r;   r7   r6   s       r   r   Dib.__init__H   s     eS!!DE::D::D--$$T*DZZ''3
		!%----JJu r   c                N   [        U[        5      (       aT  U R                  R                  U5      n U R                  R	                  U5      nU R                  R                  X5        U$ U R                  R	                  U5      nU$ ! U R                  R                  X5        f = f)z
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.
)r4   r#   r;   getdcexpose	releasedc)r   handler   results       r   r@   
Dib.exposeZ   s     fd##!!&)B1**2.

$$V0  ZZ&&v.F 

$$V0   B B$c                ~   U(       d  SU R                   -   n[        U[        5      (       aU  U R                  R	                  U5      n U R                  R                  XBU5      nU R                  R                  X5        U$ U R                  R                  XU5      nU$ ! U R                  R                  X5        f = f)a5  
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   r   )r7   r4   r#   r;   r?   drawrA   )r   rB   dstsrcr   rC   s         r   rG   Dib.drawl   s     499$Cfd##!!&)B1#6

$$V0  ZZ__V#6F 

$$V0s   B B<c                N   [        U[        5      (       aT  U R                  R                  U5      n U R                  R	                  U5      nU R                  R                  X5        U$ U R                  R	                  U5      nU$ ! U R                  R                  X5        f = f)a  
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).
)r4   r#   r;   r?   query_paletterA   )r   rB   rC   s      r   rL   Dib.query_palette   s     fd##ZZ%%f-F511&9

$$V4  ZZ--f5F 

$$V4rE   c                4   UR                  5         U R                  UR                  :w  a  UR                  U R                  5      nU(       a'  U R                  R	                  UR
                  U5        gU R                  R	                  UR
                  5        g)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)loadr6   convertr;   r<   im)r   rQ   boxs      r   r<   	Dib.paste   s`     		99DII&BJJRUUC(JJRUU#r   c                :    U R                   R                  U5        g)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`)
N)r;   	frombytes)r   buffers     r   rU   Dib.frombytes   s     	

V$r   c                6    U R                   R                  5       $ )za
Copy display memory contents to bytes object.

:return: A bytes object containing display data.
)r;   tobytesr   s    r   rY   Dib.tobytes   s     zz!!##r   )r;   r6   r7   r
   )r;   zImage.Image | strr7   z"tuple[int, int] | list[int] | Noner   r   )rQ   zImage.ImagerR   z tuple[int, int, int, int] | Noner   r   )rV   bytesr   r   )r   r[   )r   r   r   r   r   r   r@   rG   rL   r<   rU   rY   r    r!   r   r   r,   r,   4   sh    ( TX&.P	$$,4 HL$$$D$	$,%$r   r,   c                  h    \ rS rSrSr S       SS jjrS rS rS rSS jr	S	 r
S
 rSS jrSrg)Window   z*Create a Window with the given title size.Nc                    [         R                  R                  XR                  U=(       d    SU=(       d    S5      U l        g )Nr   )r   r9   createwindow_Window__dispatcherhwnd)r   titlewidthheights       r   r   Window.__init__   s/     JJ++$$ejq&+A
	r   c                &    [        U SU 35      " U6 $ )N
ui_handle_)getattr)r   actionargss      r   __dispatcherWindow.__dispatcher   s    tz&23T::r   c                    g r
   r!   r   r   x0y0x1y1s         r   ui_handle_clearWindow.ui_handle_clear       r   c                    g r
   r!   )r   rp   rq   rr   rs   s        r   ui_handle_damageWindow.ui_handle_damage   rv   r   c                    g r
   r!   r   s    r   ui_handle_destroyWindow.ui_handle_destroy   rv   r   c                    g r
   r!   ro   s         r   ui_handle_repairWindow.ui_handle_repair   rv   r   c                    g r
   r!   )r   rd   re   s      r   ui_handle_resizeWindow.ui_handle_resize   rv   r   c                @    [         R                  R                  5         g r
   )r   r9   	eventloopr   s    r   mainloopWindow.mainloop   s    

r   )rb   )PILNN)rc   r5   rd   
int | Nonere   r   r   r   )r   r   )r   r   r   r   r   r   ra   rt   rx   r{   r~   r   r   r    r!   r   r   r]   r]      sT    4 RV

)3
DN
	
;r   r]   c                  6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )ImageWindow   z6Create an image window which displays the given image.c                   > [        U[        5      (       d  [        U5      nXl        UR                  u  p4[        TU ]  X#US9  g )N)rd   re   )r4   r,   r;   r7   superr   )r   r;   rc   rd   re   	__class__s        r   r   ImageWindow.__init__   s;    %%%JE


F;r   c                @    U R                   R                  XX4U45        g r
   )r;   rG   ro   s         r   r~   ImageWindow.ui_handle_repair   s    

,-r   )r;   )r   )	r   r   r   r   r   r   r~   r    __classcell__)r   s   @r   r   r      s    @<. .r   r   N)	
__future__r   r/   r   r   r#   r,   r]   r   r!   r   r   <module>r      sE   & #   L$ L$^ @.& .r   