Changeset 4403 for libcaca/trunk


Ignore:
Timestamp:
May 30, 2010, 8:59:39 PM (9 years ago)
Author:
Alex Foulon
Message:
  • Bind import functions.
File:
1 edited

Legend:

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

    r4402 r4403  
    785785        return _lib.caca_free_frame(self, idx)
    786786
    787     def import_from_memory(self, data, length, fmt):
    788         """ Import a memory buffer into the given libcaca canvas's current frame.
    789         The current frame is resized accordingly and its contents are replaced
    790         with the imported data.
    791 
    792             data    -- a memory area containing the data to be loaded into the canvas
    793             length  -- the size in bytes of the memory area
    794             fmt     -- a string describing the input format
    795         """
    796 
     787    def import_from_memory(self, data, fmt):
     788        """ Import a memory buffer into a canvas.
     789
     790            data -- a memory area containing the data to be loaded into the canvas
     791            fmt  -- a string describing the input format
     792
     793            Valid values for format are:
     794              - "": attempt to autodetect the file format.
     795              - caca: import native libcaca files.
     796              - text: import ASCII text files.
     797              - ansi: import ANSI files.
     798              - utf8: import UTF-8 files with ANSI colour codes.
     799        """
     800        #set data size
     801        length = ctypes.c_size_t(len(data))
    797802        _lib.caca_import_canvas_from_memory.argtypes = [
    798             Canvas, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p
     803            Canvas, ctypes.c_char_p, ctypes.c_size_t, ctypes.c_char_p
    799804        ]
    800805        _lib.caca_import_canvas_from_memory.restype  = ctypes.c_int
    801806
    802807        return _lib.caca_import_canvas_from_memory(self, data, length, fmt)
     808
     809    def import_from_file(self, filename, fmt):
     810        """ Import a file into a canvas.
     811
     812            filename -- the name of the file to load
     813            fmt      -- a string describing the input format
     814
     815            Valid values for format are:
     816              - "": attempt to autodetect the file format.
     817              - caca: import native libcaca files.
     818              - text: import ASCII text files.
     819              - ansi: import ANSI files.
     820              - utf8: import UTF-8 files with ANSI colour codes.
     821        """
     822        _lib.caca_import_canvas_from_file.argtypes = [
     823            _Canvas, ctypes.c_char_p, ctypes.c_char_p
     824        ]
     825        _lib.caca_import_canvas_from_file.restype  = ctypes.c_int
     826
     827        return _lib.caca_import_canvas_from_file(self, filename, fmt)
     828
     829    def import_area_from_memory(self, x, y, data, fmt):
     830        """ Import a memory buffer into a canvas area.
     831
     832            x    -- the leftmost coordinate of the area to import to
     833            y    -- the topmost coordinate of the area to import to
     834            data -- a memory area containing the data to be loaded into the canvas
     835            fmt  -- a string describing the input format
     836
     837            Valid values for format are:
     838              - "": attempt to autodetect the file format.
     839              - caca: import native libcaca files.
     840              - text: import ASCII text files.
     841              - ansi: import ANSI files.
     842              - utf8: import UTF-8 files with ANSI colour codes.
     843        """
     844        #set data size
     845        length = ctypes.c_size_t(len(data))
     846        _lib.caca_import_area_from_memory.argtypes = [
     847            _Canvas, ctypes.c_int, ctypes.c_int,
     848            ctypes.c_char_p, ctypes.c_size_t, ctypes.c_char_p
     849        ]
     850        _lib.caca_import_area_from_memory.restype  = ctypes.c_int
     851
     852        return _lib.caca_import_area_from_memory(self, x, y, data, length, fmt)
     853
     854    def import_area_from_file(self, x, y, filename, fmt):
     855        """ Import a file into a canvas area.
     856
     857            x        -- the leftmost coordinate of the area to import to
     858            y        -- the topmost coordinate of the area to import to
     859            filename -- the name of the file to be load
     860            fmt      -- a string describing the input format
     861
     862            Valid values for format are:
     863              - "": attempt to autodetect the file format.
     864              - caca: import native libcaca files.
     865              - text: import ASCII text files.
     866              - ansi: import ANSI files.
     867              - utf8: import UTF-8 files with ANSI colour codes.
     868        """
     869        _lib.caca_import_area_from_file.argtypes = [
     870            _Canvas, ctypes.c_int, ctypes.c_int,
     871            ctypes.c_char_p, ctypes.c_char_p
     872        ]
     873        _lib.caca_import_area_from_file.restype  = ctypes.c_int
     874
     875        return _lib.caca_import_area_from_file(self, x, y, filename, fmt)
    803876
    804877    def export_to_memory(self, fmt):
Note: See TracChangeset for help on using the changeset viewer.