#----------------------------------------------------------------------
# Name:        wx.lib.images
# Purpose:     A class used for embedding images in Python code 
#
# Author:      Anthony Tuininga
#
# Created:     24-Nov-2007
# RCS-ID:      $Id: statbmp.py 42816 2006-10-31 08:50:17Z RD $
# Copyright:   (c) 2007 by Anthony Tuininga
# Licence:     wxWindows license
#----------------------------------------------------------------------

import base64
import cStringIO
import wx

class PyEmbeddedImage(object):

    def __init__(self, data):
        self.data = data

    def GetBitmap(self):
        return wx.BitmapFromImage(self.GetImage())

    def GetIcon(self):
        icon = wx.EmptyIcon()
        icon.CopyFromBitmap(self.GetBitmap())
        return icon

    def GetImage(self):
        data = base64.b64decode(self.data)
        stream = cStringIO.StringIO(data)
        return wx.ImageFromStream(stream)

    # added for backwards compatibility
    getBitmap = GetBitmap
    getIcon = GetIcon
    getImage = GetImage

    # define properties, for convenience
    Bitmap = property(GetBitmap)
    Icon = property(GetIcon)
    Image = property(GetImage)

