)Ej ddlmZddlZddlmZddlmZddlmZm Z dZ e rddl m Z dd Z ddZGddZGddZddZdS)) annotationsN)BytesIO)Any)Image ImageFileF) CapsuleTypekwdict[str, Any]returnImageFile.ImageFile | Nonecd}d|vr|d}n&d|vr"t|d}|sdStj|S)Nfiledata)poprropen)r sources =C:\PYTHON\MyICR_Suite\python\Lib\site-packages\PIL/ImageTk.py_get_image_from_kwr+s^ F || 2(( t :f  commandstrphotoPhotoImage | tkinter.PhotoImageptrr Nonec,|j} |||t|dS#tj$rUddlm}|||||t|YdSwxYw)Nr) _imagingtk) tkcallreprtkinterTclErrorrtkinit interpaddr)rrrrrs r_pyimagingtkcallr'6s B+ S *****  +++ !     "--//*** S ****** +s$/A BBcHeZdZdZ ddd Zdd ZddZddZddZddZ dS) PhotoImagea3 A Tkinter-compatible photo image. This can be used everywhere Tkinter expects an image object. If the image is an RGBA image, pixels having alpha 0 are treated as transparent. The constructor takes either a PIL image, or a mode and a size. Alternatively, you can use the ``file`` or ``data`` options to initialize the photo image object. :param image: Either a PIL image, or a mode string. If a mode string is used, a size must also be given. :param size: If the first argument is a mode string, this defines the size of the image. :keyword file: A filename to load the image from (using ``Image.open(file)``). :keyword data: An 8-bit string containing image data (as loaded from an image file). NimageImage.Image | str | Nonesizetuple[int, int] | Noner rr rc ,|t|}|d}t|t|tr|}d}|d}t|n\|j}|dkr=|||jr |jjnd}|j}|\|d<|d<|dvrtj |}||_ ||_ tjdi||_|jj|_|r||dSdS) NImage is requiredz+If first argument is mode, size is requiredPRGBwidthheight)1Lr1RGBA)r ValueError isinstancermodeapply_transparencyloadpaletter,r getmodebase_PhotoImage__mode_PhotoImage__sizer"r)_PhotoImage__photorpaste)selfr*r,r msgr:s r__init__zPhotoImage.__init__]s: =&r**E =%CS// ! s # # -DE|C oo% :Ds{{((*** -2]Eu})):D(, %BwKH 0 0 0$T**D  )//B// ,/   JJu       rc |jj}n#t$rYdSwxYwd|j_ |jjdd|dS#t $rYdSwxYwNr*delete)rAnameAttributeErrorrr ExceptionrCrIs r__del__zPhotoImage.__del__ <$DD    FF     LO (D 9 9 9 9 9    DD   !A AArc*t|jS)z Get the Tkinter photo image identifier. This method is automatically called by Tkinter whenever a PhotoImage object is passed to a Tkinter method. :return: A Tkinter photo image identifier (a string). )rrArCs r__str__zPhotoImage.__str__4<   rintc|jdSzU Get the width of the image. :return: The width, in pixels. rr@rQs rr2zPhotoImage.width {1~rc|jdSzW Get the height of the image. :return: The height, in pixels. rrWrQs rr3zPhotoImage.heightrXrim Image.Imagec>|}|j}|r|j|jkrGt j|j|j}| |||j }td|j |dS)aF Paste a PIL image into the photo image. Note that this can be very slow if the photo image is displayed. :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. PyImagingPhotoN) getimr[isblockr:r?rcore new_blockr,convert2rr'rA)rCr[rr*blocks rrBzPhotoImage.pasteshhjj}} "'T["8"8J((bg>>E NN5% ( ( ()C)4<=====r)NN)r*r+r,r-r rr rr rr rr rT)r[r\r r) __name__ __module__ __qualname____doc__rErMrRr2r3rBr7rrr)r)Is*+/'+'''''R    !!!!>>>>>>rr)c<eZdZdZddd Zdd Zdd Zdd ZddZdS) BitmapImagea A Tkinter-compatible bitmap image. This can be used everywhere Tkinter expects an image object. The given image must have mode "1". Pixels having value 0 are treated as transparent. Options, if any, are passed on to Tkinter. The most commonly used option is ``foreground``, which is used to specify the color for the non-transparent parts. See the Tkinter documentation for information on how to specify colours. :param image: A PIL image. Nr*Image.Image | Noner rr rc |t|}|d}t||j|_|j|_t jdd|i||_ dS)Nr/rr7) rr8r:_BitmapImage__moder,_BitmapImage__sizer"rmtobitmap_BitmapImage__photo)rCr*r rDs rrEzBitmapImage.__init__sg =&r**E =%CS// !j j *GG0@0@GBGG rc |jj}n#t$rYdSwxYwd|j_ |jjdd|dS#t $rYdSwxYwrG)rsrIrJrr rKrLs rrMzBitmapImage.__del__rNrOrTc|jdSrVrqrQs rr2zBitmapImage.widthrXrc|jdSrZrvrQs rr3zBitmapImage.heightrXrrc*t|jS)z Get the Tkinter bitmap image identifier. This method is automatically called by Tkinter whenever a BitmapImage object is passed to a Tkinter method. :return: A Tkinter bitmap image identifier (a string). )rrsrQs rrRzBitmapImage.__str__rSr)N)r*rnr rr rrergrf) rhrirjrkrErMr2r3rRr7rrrmrms   H H H H H    !!!!!!rrmr\ctjd||f}t d|||S)z:Copies the contents of a PhotoImage to a PIL image memory.r6PyImagingPhotoGet)rnewr2r3r'r_)rr[s rgetimager|sH 6EKKMM5<<>>: ; ;B(%<<< Ir)r r r r )rrrrrr r r)rr)r r\) __future__rr"iortypingrr$rr TYPE_CHECKING_typingr rr'r)rmr|r7rrrs6#""""" %$$$$$$  + + + +&s>s>s>s>s>s>s>s>t>!>!>!>!>!>!>!>!Br