a
    §ˆc�
  ã                   @   sJ   d Z ddlZddlmZmZ ddlmZmZ eeƒG dd„ deeƒƒZdS )z$ Enthought pyface package component
é    N)Ú	HasTraitsÚprovides)ÚIImageCacheÚMImageCachec                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	Ú
ImageCachezy The toolkit specific implementation of an ImageCache.  See the
    IImageCache interface for the API documentation.
    c                 C   s   || _ || _i | _i | _d S ©N)Ú_widthÚ_heightÚ_imagesÚ_bitmaps)ÚselfÚwidthÚheight© r   ú[/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/ui/wx/image_cache.pyÚ__init__#   s
    zImageCache.__init__c                 C   s\   | j  |¡}|d u rXt |tj¡}| ¡ | jks>| ¡ | jkrN| 	| j| j¡ || j |< |S r   )
r
   ÚgetÚwxZImageZBITMAP_TYPE_ANYZGetWidthr   Z	GetHeightr	   ZRescale)r   ÚfilenameÚimager   r   r   Ú	get_image3   s    ÿþ
zImageCache.get_imagec                 C   s<   | j  |¡}|d u r8|  |¡}| ¡  | ¡ }|| j |< |S r   )r   r   r   ZConvertAlphaToMaskZConvertToBitmap)r   r   Zbmpr   r   r   r   Ú
get_bitmapJ   s    

zImageCache.get_bitmapN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r      s   r   )	r   r   Z
traits.apir   r   Zpyface.i_image_cacher   r   r   r   r   r   r   Ú<module>   s
   