
    h                        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/env/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                      \ rS rSrSr S     SS jjrSS jr S       SS jjrSS j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Uc  Sn[        U5      e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 z+If first argument is mode, size is required)1LPRGB)
isinstancestr
ValueErrormodesizer   getmodebasecoredisplayimagepaste)r   r<   r8   r7   msgs        r   r   Dib.__init__H   s     eS!!DE|C o%  ::D::D--$$T*DZZ''3
		!%----JJu r   c                `   [        U5      n[        U[        5      (       aS  U R                  R	                  U5      n U R                  R                  U5        U R                  R                  X#5        gU R                  R                  U5        g! 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.
N)r   r4   r#   r<   getdcexpose	releasedc)r   handle
handle_intr   s       r   rB   
Dib.expose]   s     [
fd##!!*-B5

!!"%

$$Z4JJj) 

$$Z4s   B B-c                   Uc  SU R                   -   n[        U5      n[        U[        5      (       aT  U R                  R                  U5      n U R                  R                  XRU5        U R                  R                  XE5        gU R                  R                  XBU5        g! U R                  R                  XE5        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.
N)r   r   )r8   r   r4   r#   r<   rA   drawrC   )r   rD   dstsrcrE   r   s         r   rH   Dib.drawo   s     ;499$C[
fd##!!*-B5

-

$$Z4JJOOJS1 

$$Z4s   B$ $Cc                d   [        U5      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: The number of entries that were changed (if one or more entries,
         this indicates that the image should be redrawn).
)r   r4   r#   r<   rA   query_paletterC   )r   rD   rE   results       r   rM   Dib.query_palette   s     [
fd##ZZ%%j1F511&9

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

$$V4s   B B/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)loadr7   convertr<   r=   im)r   rS   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   rW   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   r[   Dib.tobytes   s     zz!!##r   )r<   r7   r8   r
   )r<   zImage.Image | strr8   ztuple[int, int] | Noner   r   )rD   int | HDC | HWNDr   r   )rD   r]   rI   ztuple[int, int, int, int]rJ    tuple[int, int, int, int] | Noner   r   )rD   r]   r   r   )rS   zImage.ImagerT   r^   r   r   )rX   bytesr   r   )r   r_   )r   r   r   r   r   r   rB   rH   rM   r=   rW   r[   r    r!   r   r   r,   r,   4   s    ( HL&.D	**, 15	2 2 '2 .	2
 
266 HL$$$D$	$,%$r   r,   c                  |    \ rS rSrSr S       SS jjrSS jrSS jrSS jrSS jr	SS	 jr
SS
 j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   r:   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   g )N
ui_handle_)getattr)r   actionargss      r   __dispatcherWindow.__dispatcher   s    
6(+,d3r   c                    g r
   r!   r   r   x0y0x1y1s         r   ui_handle_clearWindow.ui_handle_clear       r   c                    g r
   r!   )r   rt   ru   rv   rw   s        r   ui_handle_damageWindow.ui_handle_damage   rz   r   c                    g r
   r!   r   s    r   ui_handle_destroyWindow.ui_handle_destroy   rz   r   c                    g r
   r!   rs   s         r   ui_handle_repairWindow.ui_handle_repair   rz   r   c                    g r
   r!   )r   rh   ri   s      r   ui_handle_resizeWindow.ui_handle_resize   rz   r   c                @    [         R                  R                  5         g r
   )r   r:   	eventloopr   s    r   mainloopWindow.mainloop   s    

r   )rf   )PILNN)rg   r5   rh   
int | Noneri   r   r   r   )rn   r5   ro   r   r   r   r   r   rt   r   ru   r   rv   r   rw   r   r   r   )
rt   r   ru   r   rv   r   rw   r   r   r   )r   r   )rh   r   ri   r   r   r   )r   r   r   r   r   r   re   rx   r|   r   r   r   r   r    r!   r   r   ra   ra      sT    4 RV

)3
DN
	
4r   ra   c                  >   ^  \ rS rSrSrSSU 4S jjjrSS j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)rh   ri   )r4   r,   r<   r8   superr   )r   r<   rg   rh   ri   	__class__s        r   r   ImageWindow.__init__   s;    %%%JE


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

,-r   )r<   )r   )r<   zImage.Image | Dibrg   r5   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,   ra   r   r!   r   r   <module>r      sE   & #   U$ U$p @.& .r   