K iddlmZddlmZGddZGddZGdd ZGd d ZGd d eZy)) annotations)Imagec eZdZdZddZddZy)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. c||_yNdc)selfr s R/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/PIL/ImageWin.py__init__z HDC.__init__s c|jSr r r s r __int__z HDC.__int__"s wwrN)r intreturnNonerr__name__ __module__ __qualname____doc__rrrr rrs rrc eZdZdZddZddZy)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. c||_yr wnd)r r!s r rz HWND.__init__-s rc|jSr r rs r rz HWND.__int__0s xxrN)r!rrrrrrrr rr&s rrcveZdZdZ d d dZd dZ d d dZddZ d ddZddZ dd Z y)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 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^t|tr|}d}|%d}t||j}|j}|dvrt j |}t jj|||_ ||_||_|r$t|trJ|j|yy)Nz+If first argument is mode, size is required)1LPRGB) isinstancestr ValueErrormodesizer getmodebasecoredisplayimagepaste)r r3r/r.msgs r rz Dib.__init__Hs eS !DE|C o%::D::D - -$$T*DZZ''d3   !%- -- JJu  rcZt|}t|trT|jj |} |jj ||jj ||y|jj |y#|jj ||wxYw)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. N)rr+rr3getdcexpose releasedc)r handle handle_intr s r r8z Dib.expose]s[ fd #!!*-B 5 !!"% $$Z4 JJ  j ) $$Z4s B B*c|d|jz}t|}t|trV|jj |} |jj ||||jj||y|jj |||y#|jj||wxYw)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. N)rr)r/rr+rr3r7drawr9)r r:dstsrcr;r s r r=zDib.drawos ;499$C[ fd #!!*-B 5 C- $$Z4 JJOOJS 1 $$Z4s B!!B?c^t|}t|trU|jj |} |jj |}|jj |||S|jj |}|S#|jj ||wxYw)at 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). )rr+rr3r7 query_paletter9)r r:r;results r rAzDib.query_palettes[ fd #ZZ%%j1F 511&9 $$VV4 ZZ--j9F  $$VV4s BB,c(|j|j|jk7r|j|j}|r'|jj |j |y|jj |j y)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.convertr3r4im)r rFboxs r r4z Dib.pastes`  99 DII&B  JJ  RUUC ( JJ  RUU #rc:|jj|y)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)r3 frombytes)r buffers r rIz Dib.frombytess V$rc6|jjS)zy Copy display memory contents to bytes object. :return: A bytes object containing display data. )r3tobytesrs r rLz Dib.tobytess zz!!##rr )r3zImage.Image | strr/ztuple[int, int] | Nonerr)r:int | HDC | HWNDrr)r:rMr>ztuple[int, int, int, int]r? tuple[int, int, int, int] | Nonerr)r:rMrr)rFz Image.ImagerGrNrr)rJbytesrr)rrO) rrrrrr8r=rAr4rIrLrrr r$r$4s(HL&.D **,15 2 2'2. 2  266HL$$$D$ $,%$rr$cbeZdZdZ d d dZd dZddZddZddZddZ dd Z dd Z y)Windowz*Create a Window with the given title size.Ncvtjj||j|xsd|xsd|_y)Nr)rr1 createwindow_Window__dispatcherhwnd)r titlewidthheights r rzWindow.__init__s1JJ++ 4$$ejq&+A  rc(t|d||y)N ui_handle_)getattr)r actionargss r __dispatcherzWindow.__dispatchers, 6(+,d3rcyr rr r x0y0x1y1s r ui_handle_clearzWindow.ui_handle_clear rcyr r)r rarbrcrds r ui_handle_damagezWindow.ui_handle_damagerfrcyr rrs r ui_handle_destroyzWindow.ui_handle_destroyrfrcyr rr`s r ui_handle_repairzWindow.ui_handle_repairrfrcyr r)r rWrXs r ui_handle_resizezWindow.ui_handle_resizerfrc@tjjyr )rr1 eventlooprs r mainloopzWindow.mainloops r)PILNN)rVr,rW int | NonerXrsrr)r\r,r]rrr r rrarrbrrcrrdrrr) rarrbrrcrrdrrr)rr)rWrrXrrr) rrrrrrTrerhrjrlrnrqrrr rQrQsT4RV  )3 DN  4     rrQc.eZdZdZddfd ZddZxZS) ImageWindowz6Create an image window which displays the given image.ct|ts t|}||_|j\}}t||||y)N)rWrX)r+r$r3r/superr)r r3rVrWrX __class__s r rzImageWindow.__init__s>%%JE  v eF;rcD|jj|||||fyr )r3r=r`s r rlzImageWindow.ui_handle_repairs RR,-r)rr)r3zImage.Image | DibrVr,rrrt)rrrrrrl __classcell__)rys@r rvrvs@<.rrvN) __future__rr&rrrr$rQrvrrr r}sE&#    U$U$p@ .& .r