You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

66 lines
1.8 KiB

  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. """ Libcaca Python bindings """
  15. import ctypes
  16. from caca import _lib
  17. class _Dither(object):
  18. """ Model for Dither object.
  19. """
  20. def __init__(self):
  21. self._dither = 0
  22. def from_param(self):
  23. """ Required by ctypes module to call object as parameter of
  24. a C function.
  25. """
  26. return self._dither
  27. def __del__(self):
  28. if self._dither > 0:
  29. self._free()
  30. def __str__(self):
  31. return "<CacaDither>"
  32. def _free(self):
  33. """ Free a libcaca dither.
  34. """
  35. _lib.caca_free_font.argtypes = [_Dither]
  36. _lib.caca_free_font.restype = ctypes.c_int
  37. return _lib.caca_free_font(self)
  38. class Dither(_Dither):
  39. """ Dither object, methods are libcaca functions with caca_dither_t as first
  40. argument.
  41. """
  42. def __init__(self, bpp, width, height, pitch, rmask, gmask, bmask, amask):
  43. """ Dither constructor
  44. bpp -- bitmap depth in bits per pixels
  45. width -- bitmap width in pixels
  46. height -- bitmap height in pixels
  47. pitch -- bitmap pitch in bytes
  48. rmask -- bitmask for red values
  49. gmask -- bitmask for green values
  50. bmask -- bitmask for blue values
  51. amask -- bitmask for alpha values
  52. """
  53. pass