3
7ßL]·  ã               @   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   ú</tmp/pip-install-5sebvq2j/pyface/pyface/ui/wx/image_cache.pyÚ__init__)   s
    zImageCache.__init__c             C   s\   | j j|ƒ}|d krXtj|tjƒ}|jƒ | jks>|jƒ | jkrN|j	| j| jƒ || j |< |S )N)
r	   ÚgetÚwxZImageZBITMAP_TYPE_ANYZGetWidthr   Z	GetHeightr   ZRescale)r   ÚfilenameÚimager   r   r   Ú	get_image9   s    
zImageCache.get_imagec             C   s<   | j j|ƒ}|d kr8| j|ƒ}|jƒ  |jƒ }|| j |< |S )N)r
   r   r   ZConvertAlphaToMaskZConvertToBitmap)r   r   Zbmpr   r   r   r   Ú
get_bitmapM   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
   