"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "python/caca/dither.py" between
libcaca-0.99.beta19.tar.gz and libcaca-0.99.beta20.tar.bz2

About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).

dither.py  (libcaca-0.99.beta19):dither.py  (libcaca-0.99.beta20.tar.bz2)
skipping to change at line 22 skipping to change at line 22
# http://www.wtfpl.net/ for more details. # http://www.wtfpl.net/ for more details.
# #
""" Libcaca Python bindings """ """ Libcaca Python bindings """
import ctypes import ctypes
from caca import _lib from caca import _lib
from caca.canvas import _Canvas from caca.canvas import _Canvas
class _DitherStruct(ctypes.Structure):
pass
class _Dither(object): class _Dither(object):
""" Model for Dither object. """ Model for Dither object.
""" """
def __init__(self): def __init__(self):
self._dither = 0 self._dither = None
def from_param(self): def from_param(self):
""" Required by ctypes module to call object as parameter of """ Required by ctypes module to call object as parameter of
a C function. a C function.
""" """
return self._dither return self._dither
def __del__(self): def __del__(self):
if self._dither > 0: if self._dither:
self._free() self._free()
def __str__(self): def __str__(self):
return "<CacaDither>" return "<CacaDither>"
def _free(self): def _free(self):
""" Free a libcaca dither. """ Free a libcaca dither.
""" """
_lib.caca_free_dither.argtypes = [_Dither] _lib.caca_free_dither.argtypes = [_Dither]
_lib.caca_free_dither.restype = ctypes.c_int _lib.caca_free_dither.restype = ctypes.c_int
skipping to change at line 69 skipping to change at line 72
pitch -- bitmap pitch in bytes pitch -- bitmap pitch in bytes
rmask -- bitmask for red values rmask -- bitmask for red values
gmask -- bitmask for green values gmask -- bitmask for green values
bmask -- bitmask for blue values bmask -- bitmask for blue values
amask -- bitmask for alpha values amask -- bitmask for alpha values
""" """
_lib.caca_create_dither.argtypes = [ _lib.caca_create_dither.argtypes = [
ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int,
ctypes.c_uint, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint,
] ]
_lib.caca_create_dither.restype = ctypes.POINTER(_DitherStruct)
self._dither = _lib.caca_create_dither(bpp, width, height, pitch, self._dither = _lib.caca_create_dither(bpp, width, height, pitch,
rmask, gmask, bmask, amask) rmask, gmask, bmask, amask)
if self._dither == 0: if self._dither == 0:
raise DitherError("Failed to create dither object") raise DitherError("Failed to create dither object")
def set_palette(self, red, green, blue, alpha): def set_palette(self, red, green, blue, alpha):
""" Set the palette of an 8 bits per pixel bitmap. Values should be """ Set the palette of an 8 bits per pixel bitmap. Values should be
between 0 and 4095 (0xfff). between 0 and 4095 (0xfff).
 End of changes. 4 change blocks. 
2 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)