)Ej ddlmZddlmZGddZGddZGdd ZGd d ZGd d eZdS)) annotations)Imagec"eZdZdZd dZd dZdS) 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. dcintreturnNonec||_dSNr)selfrs >C:\PYTHON\MyICR_Suite\python\Lib\site-packages\PIL/ImageWin.py__init__z HDC.__init__s c|jSr rrs r__int__z HDC.__int__"s wrN)rr r r r r __name__ __module__ __qualname____doc__rrrrrrsF rrc"eZdZdZd dZd dZdS) 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. wndr r r c||_dSr r)rrs rrz HWND.__init__-s rc|jSr r!rs rrz HWND.__int__0s xrN)rr r r rrrrrrr&sF rrcVeZdZdZ ddd Zdd Z dd dZd!dZ dd"dZd#dZ d$dZ 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 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. NimageImage.Image | strsizetuple[int, int] | Noner r crt|tr|}d}|d}t|n|j}|j}|dvrt j|}t j|||_ ||_||_|r.t|trJ| |dSdS)Nz+If first argument is mode, size is required)1LPRGB) isinstancestr ValueErrormoder'r getmodebasecoredisplayr%paste)rr%r'r2msgs rrz Dib.__init__Hs eS ! ! DE|C oo%:D:D - - -$T**DZ''d33    !%-- - -- JJu       rhandleint | HDC | HWNDcft|}t|trr|j|} |j||j||dS#|j||wxYw|j|dS)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)r r/rr%getdcexpose releasedc)rr8 handle_intrs rr<z Dib.expose]s[[ fd # # *!!*--B 5 !!"%%% $$Z44444 $$Z4444 J  j ) ) ) ) )s A77Bdsttuple[int, int, int, int]src tuple[int, int, int, int] | Nonec| d|jz}t|}t|trt|j|} |j||||j||dS#|j||wxYw|j|||dS)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'r r/rr%r;drawr=)rr8r?rAr>rs rrDzDib.drawos ;49$C[[ fd # # 2!!*--B 5 C--- $$Z44444 $$Z4444 JOOJS 1 1 1 1 1s BB"r cdt|}t|trq|j|} |j|}|j||n:#|j||wxYw|j|}|S)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). )r r/rr%r; query_paletter=)rr8r>results rrFzDib.query_palettes[[ fd # # :Z%%j11F 511&99 $$VV4444 $$VV4444Z--j99F s A66Bim Image.Imageboxc||j|jkr||j}|r"|j|j|dS|j|jdS)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)loadr2convertr%r6rH)rrHrJs rr6z Dib.pastesy  9  DI&&B  $ J  RUC ( ( ( ( ( J  RU # # # # #rbufferbytes | memoryviewc:|j|dS)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)rrNs rrQz Dib.frombytess  V$$$$$rbytesc4|jS)zy Copy display memory contents to bytes object. :return: A bytes object containing display data. )r%tobytesrs rrTz Dib.tobytess z!!###rr )r%r&r'r(r r )r8r9r r )r8r9r?r@rArBr r )r8r9r r )rHrIrJrBr r )rNrOr r )r rR) rrrrrr<rDrFr6rQrTrrrr$r$4s(HL*****,15 2222266HL$$$$$,%%%%$$$$$$rr$cVeZdZdZ ddd ZddZddZddZd dZddZ d!dZ d dZ dS)"Windowz*Create a Window with the given title size.PILNtitler0width int | Noneheightr r cftj||j|pd|pd|_dS)Nr)rr4 createwindow_Window__dispatcherhwnd)rrXrYr[s rrzWindow.__init__s5J++ 4$ejq&+A   ractionargsr c2t|d||dS)N ui_handle_)getattr)rr`ras r __dispatcherzWindow.__dispatchers(,+6++,,d3333rrx0y0x1y1cdSr rrrrfrgrhris rui_handle_clearzWindow.ui_handle_clear rcdSr r)rrfrgrhris rui_handle_damagezWindow.ui_handle_damagermrcdSr rrs rui_handle_destroyzWindow.ui_handle_destroyrmrcdSr rrks rui_handle_repairzWindow.ui_handle_repairrmrcdSr r)rrYr[s rui_handle_resizezWindow.ui_handle_resizermrcBtjdSr )rr4 eventlooprs rmainloopzWindow.mainloops r)rWNN)rXr0rYrZr[rZr r )r`r0rar r r rr rfr rgr rhr rir r r ) rfr rgr rhr rir r r )r r )rYr r[r r r ) rrrrrr^rlrorqrsrurxrrrrVrVs44RV     4444                    rrVc.eZdZdZddfd ZddZxZS) ImageWindowz6Create an image window which displays the given image.rWr%Image.Image | DibrXr0r r ct|tst|}||_|j\}}t |||dS)N)rYr[)r/r$r%r'superr)rr%rXrYr[ __class__s rrzImageWindow.__init__sW%%% JJE  v eF;;;;;rrr rfrgrhricD|j|||||fdSr )r%rDrks rrszImageWindow.ui_handle_repairs' RR,-----r)rW)r%r|rXr0r r ry)rrrrrrs __classcell__)rs@rr{r{s\@@<<<<<<<........rr{N) __future__rr*rrrr$rVr{rrrrs &#"""""                U$U$U$U$U$U$U$U$p@ . . . . .& . . . . .r