Changeset 4402 for libcaca/trunk


Ignore:
Timestamp:
May 30, 2010, 2:47:28 PM (9 years ago)
Author:
Alex Foulon
Message:
  • Bind export functions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/python/caca/canvas.py

    r4398 r4402  
    802802        return _lib.caca_import_canvas_from_memory(self, data, length, fmt)
    803803
     804    def export_to_memory(self, fmt):
     805        """ Export a canvas into a foreign format.
     806
     807            fmt -- a string describing the input format
     808
     809            Valid values for format are:
     810              - caca: export native libcaca files.
     811              - ansi: export ANSI art (CP437 charset with ANSI colour codes).
     812              - html: export an HTML page with CSS information.
     813              - html3: export an HTML table that should be compatible with
     814                       most navigators, including textmode ones.
     815              - irc: export UTF-8 text with mIRC colour codes.
     816              - ps: export a PostScript document.
     817              - svg: export an SVG vector image.
     818              - tga: export a TGA image.
     819        """
     820        #initialize pointer
     821        p_size_t = ctypes.POINTER(ctypes.c_size_t)
     822
     823        _lib.caca_export_canvas_to_memory.argtypes = [
     824                _Canvas, ctypes.c_char_p, p_size_t
     825        ]
     826        _lib.caca_export_canvas_to_memory.restype  = ctypes.c_void_p
     827
     828        ret = _lib.caca_export_canvas_to_memory(self, fmt,
     829                                                p_size_t(ctypes.c_size_t()))
     830        return ctypes.c_char_p(ret).value
     831
     832    def export_area_to_memory(self, x, y, width, height, fmt):
     833        """ Export a canvas portion into a foreign format.
     834
     835            x       -- the leftmost coordinate of the area to export
     836            y       -- the topmost coordinate of the area to export
     837            width   -- the width of the area to export
     838            height  -- the height of the area to export
     839            fmt     -- a string describing the input format
     840
     841            Valid values for format are:
     842              - caca: export native libcaca files.
     843              - ansi: export ANSI art (CP437 charset with ANSI colour codes).
     844              - html: export an HTML page with CSS information.
     845              - html3: export an HTML table that should be compatible with
     846                       most navigators, including textmode ones.
     847              - irc: export UTF-8 text with mIRC colour codes.
     848              - ps: export a PostScript document.
     849              - svg: export an SVG vector image.
     850              - tga: export a TGA image.
     851        """
     852        #initialize pointer
     853        p_size_t = ctypes.POINTER(ctypes.c_size_t)
     854
     855        _lib.caca_export_area_to_memory.argtypes = [
     856                _Canvas, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int,
     857                ctypes.c_char_p, p_size_t
     858        ]
     859        _lib.caca_export_area_to_memory.restype  = ctypes.c_void_p
     860
     861        ret = _lib.caca_export_area_to_memory(self, x, y, width, height,
     862                                              fmt, p_size_t(ctypes.c_size_t()))
     863        return ctypes.c_char_p(ret).value
     864
    804865class NullCanvas(_Canvas):
    805866    """ Represent a NULL canvas_t, eg to use as canvas mask for blit operations.
Note: See TracChangeset for help on using the changeset viewer.