source: libcaca/trunk/python/caca/dither.py @ 4398

Last change on this file since 4398 was 4398, checked in by Sam Hocevar, 11 years ago

New improved ctypes-based Python bindings, by Alex Foulon <alxf@lavabit.com>.

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# libcaca       Colour ASCII-Art library
4#               Python language bindings
5# Copyright (c) 2010 Alex Foulon <alxf@lavabit.com>
6#               All Rights Reserved
7#
8# This library is free software. It comes without any warranty, to
9# the extent permitted by applicable law. You can redistribute it
10# and/or modify it under the terms of the Do What The Fuck You Want
11# To Public License, Version 2, as published by Sam Hocevar. See
12# http://sam.zoy.org/wtfpl/COPYING for more details.
13#
14
15""" Libcaca Python bindings """
16
17import ctypes
18
19from caca import _lib
20
21class _Dither(object):
22    """ Model for Dither object.
23    """
24    def __init__(self):
25        self._dither = 0
26
27    def from_param(self):
28        """ Required by ctypes module to call object as parameter of
29            a C function.
30        """
31        return self._dither
32
33    def __del__(self):
34        if self._dither > 0:
35            self._free()
36
37    def __str__(self):
38        return "<CacaDither>"
39
40    def _free(self):
41        """ Free a libcaca dither.
42        """
43        _lib.caca_free_font.argtypes = [_Dither]
44        _lib.caca_free_font.restype = ctypes.c_int
45
46        return _lib.caca_free_font(self)
47
48class Dither(_Dither):
49    """ Dither object, methods are libcaca functions with caca_dither_t as first
50        argument.
51    """
52    def __init__(self, bpp, width, height, pitch, rmask, gmask, bmask, amask):
53        """ Dither constructor
54
55            bpp     -- bitmap depth in bits per pixels
56            width   -- bitmap width in pixels
57            height  -- bitmap height in pixels
58            pitch   -- bitmap pitch in bytes
59            rmask   -- bitmask for red values
60            gmask   -- bitmask for green values
61            bmask   -- bitmask for blue values
62            amask   -- bitmask for alpha values
63        """
64        pass
65
Note: See TracBrowser for help on using the repository browser.