'Returns the image converted to an X11 bitmap.
.. note:: This method only works for mode "1" images.
:param name: The name prefix to use for the bitmap variables.
:returns: A string containing an X11 bitmap.
:raises ValueError: If the mode is not "1"'

def tobitmap(self, name='image'):

    self.load()
    if (self.mode != '1'):
        raise ValueError('not    a    bitmap')
    data = self.tobytes('xbm')
    return ''.join([('#define    %s_width    %d\n' % (name, self.size[0])).encode('ascii'), ('#define    %s_height    %d\n' % (name, self.size[1])).encode('ascii'), ('static    char    %s_bits[]    =    {\n' % name).encode('ascii'), data, '};'])
